From b578931b840fdd009899c96ef79e46d04baecfd9 Mon Sep 17 00:00:00 2001 From: Darya Umrikhina Date: Wed, 28 Aug 2024 19:08:20 +0400 Subject: [PATCH] Login:App:TenantList: move client components and page styles --- .../tenant-list/_sub-components/Item.tsx | 76 +++++++++++++ .../app/(root)/tenant-list/page.client.tsx | 71 ++++++++++++ .../src/app/(root)/tenant-list/page.styled.ts | 106 ++++++++++++++++++ .../TenantList/TenantList.styled.ts | 78 ------------- .../components/TenantList/TenantList.types.ts | 12 -- .../TenantList/sub-components/Item.tsx | 44 -------- packages/login/src/types/index.ts | 2 + 7 files changed, 255 insertions(+), 134 deletions(-) create mode 100644 packages/login/src/app/(root)/tenant-list/_sub-components/Item.tsx create mode 100644 packages/login/src/app/(root)/tenant-list/page.client.tsx create mode 100644 packages/login/src/app/(root)/tenant-list/page.styled.ts delete mode 100644 packages/login/src/components/TenantList/TenantList.styled.ts delete mode 100644 packages/login/src/components/TenantList/TenantList.types.ts delete mode 100644 packages/login/src/components/TenantList/sub-components/Item.tsx diff --git a/packages/login/src/app/(root)/tenant-list/_sub-components/Item.tsx b/packages/login/src/app/(root)/tenant-list/_sub-components/Item.tsx new file mode 100644 index 0000000000..a7c8f294dd --- /dev/null +++ b/packages/login/src/app/(root)/tenant-list/_sub-components/Item.tsx @@ -0,0 +1,76 @@ +// (c) Copyright Ascensio System SIA 2009-2024 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +/* eslint-disable @next/next/no-img-element */ + +"use client"; + +import { Text } from "@docspace/shared/components/text"; +import { IconButton } from "@docspace/shared/components/icon-button"; +import { deleteCookie, getCookie } from "@docspace/shared/utils/cookie"; + +import ArrowRightSvrUrl from "PUBLIC_DIR/images/arrow.right.react.svg?url"; +import DefaultLogoUrl from "PUBLIC_DIR/images/logo/leftmenu.svg?url"; +import { TPortal } from "@/types"; + +type ItemProps = { + portal: TPortal; + baseDomain: string; +}; + +const Item = ({ portal, baseDomain }: ItemProps) => { + const name = portal.portalName.includes(baseDomain) + ? portal.portalName + : `${portal.portalName}.${baseDomain}`; + + const onClick = () => { + const redirectUrl = getCookie("x-redirect-authorization-uri")?.replace( + window.location.origin, + name, + ); + deleteCookie("x-redirect-authorization-uri"); + + window.open(`${portal.portalLink}&referenceUrl=${redirectUrl}`, "_self"); + }; + + return ( +
+
+ Portal favicon + + {name.replace("http://", "").replace("https://", "")} + +
+ +
+ ); +}; + +export default Item; diff --git a/packages/login/src/app/(root)/tenant-list/page.client.tsx b/packages/login/src/app/(root)/tenant-list/page.client.tsx new file mode 100644 index 0000000000..a04dddfdea --- /dev/null +++ b/packages/login/src/app/(root)/tenant-list/page.client.tsx @@ -0,0 +1,71 @@ +// (c) Copyright Ascensio System SIA 2009-2024 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +"use client"; + +import { useRouter } from "next/navigation"; +import { useTranslation } from "react-i18next"; + +import { Text } from "@docspace/shared/components/text"; +import { Button } from "@docspace/shared/components/button"; + +import { TPortal } from "@/types"; + +import StyledTenantList from "./page.styled"; +import Item from "./_sub-components/Item"; + +type TenantListProps = { + baseDomain: string; + clientId: string; + portals: TPortal[]; +}; + +const TenantList = ({ portals, clientId, baseDomain }: TenantListProps) => { + const router = useRouter(); + const { t } = useTranslation(["TenantList"]); + + const goToLogin = () => { + router.push(`/?type=oauth2&client_id=${clientId}`); + }; + + return ( + + {t("MorePortals")} +
+ {portals.map((item) => ( + + ))} +
+