From 3412baf852d0f382e7e60ea6a507e4945051fc7d Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Fri, 28 Jun 2024 13:53:43 +0530 Subject: [PATCH] Refactor code --- .../components/branding-preference-tabs.tsx | 2 +- .../fragments/password-recovery/index.tsx | 25 ----------------- .../preview/sign-in-box/sign-in-box.tsx | 10 +++---- .../components/screen-variation-dropdown.tsx | 2 +- .../models/custom-text-preference.ts | 27 ++++++++++--------- 5 files changed, 20 insertions(+), 46 deletions(-) delete mode 100644 features/admin.branding.v1/components/preview/sign-in-box/fragments/password-recovery/index.tsx diff --git a/features/admin.branding.v1/components/branding-preference-tabs.tsx b/features/admin.branding.v1/components/branding-preference-tabs.tsx index 158cbc78c04..e3359033fe4 100644 --- a/features/admin.branding.v1/components/branding-preference-tabs.tsx +++ b/features/admin.branding.v1/components/branding-preference-tabs.tsx @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2021-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/features/admin.branding.v1/components/preview/sign-in-box/fragments/password-recovery/index.tsx b/features/admin.branding.v1/components/preview/sign-in-box/fragments/password-recovery/index.tsx deleted file mode 100644 index becb8d37189..00000000000 --- a/features/admin.branding.v1/components/preview/sign-in-box/fragments/password-recovery/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export { default as PasswordRecoveryEmailLinkFragment } from "./password-recovery-email-link-fragment"; -export { default as PasswordRecoverySMSFragment } from "./password-recovery-sms-otp-fragment"; -export { default as PasswordRecoveryMultiOptionFragment } from "./password-recovery-multi-option-fragment"; - -export * from "./password-recovery-email-link-fragment"; -export * from "./password-recovery-sms-otp-fragment"; -export * from "./password-recovery-multi-option-fragment"; diff --git a/features/admin.branding.v1/components/preview/sign-in-box/sign-in-box.tsx b/features/admin.branding.v1/components/preview/sign-in-box/sign-in-box.tsx index bef3a57e476..c4d2ff3dfbb 100644 --- a/features/admin.branding.v1/components/preview/sign-in-box/sign-in-box.tsx +++ b/features/admin.branding.v1/components/preview/sign-in-box/sign-in-box.tsx @@ -20,7 +20,7 @@ import { BrandingPreferenceInterface, PreviewScreenType, PreviewScreenVariationType - } from "@wso2is/common.branding.v1/models"; +} from "@wso2is/common.branding.v1/models"; import { IdentifiableComponentInterface } from "@wso2is/core/models"; import React, { FunctionComponent, @@ -30,11 +30,9 @@ import BasicAuthFragment from "./fragments/basic-auth-fragment"; import CommonFragment from "./fragments/common-fragment"; import EmailLinkExpiryFragment from "./fragments/email-link-expiry-fragment"; import EmailOTPFragment from "./fragments/email-otp-fragment"; -import { - PasswordRecoveryEmailLinkFragment, - PasswordRecoveryMultiOptionFragment, - PasswordRecoverySMSFragment -} from "./fragments/password-recovery"; +import PasswordRecoveryEmailLinkFragment from "./fragments/password-recovery/password-recovery-email-link-fragment"; +import PasswordRecoveryMultiOptionFragment from "./fragments/password-recovery/password-recovery-multi-option-fragment"; +import PasswordRecoverySMSFragment from "./fragments/password-recovery/password-recovery-sms-otp-fragment"; import PasswordResetFragment from "./fragments/password-reset-fragment"; import PasswordResetSuccessFragment from "./fragments/password-reset-success-fragment"; import SignUpFragment from "./fragments/sign-up-fragment"; diff --git a/features/admin.branding.v1/components/screen-variation-dropdown.tsx b/features/admin.branding.v1/components/screen-variation-dropdown.tsx index 84340779295..2a83d2d0c2b 100644 --- a/features/admin.branding.v1/components/screen-variation-dropdown.tsx +++ b/features/admin.branding.v1/components/screen-variation-dropdown.tsx @@ -16,12 +16,12 @@ * under the License. */ +import { PreviewScreenType, PreviewScreenVariationType } from "@wso2is/common.branding.v1/models"; import { IdentifiableComponentInterface } from "@wso2is/core/models"; import React, { FunctionComponent, ReactElement, useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { DropdownProps, Form, Select } from "semantic-ui-react"; import useBrandingPreference from "../hooks/use-branding-preference"; -import { PreviewScreenType, PreviewScreenVariationType } from "../models/branding-preferences"; import { BASE_DISPLAY_VARIATION } from "../models/custom-text-preference"; /** diff --git a/features/admin.branding.v1/models/custom-text-preference.ts b/features/admin.branding.v1/models/custom-text-preference.ts index 7e71eb51141..b0d847f9835 100644 --- a/features/admin.branding.v1/models/custom-text-preference.ts +++ b/features/admin.branding.v1/models/custom-text-preference.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -20,7 +20,7 @@ import { BrandingPreferenceTypes, PreviewScreenType, PreviewScreenVariationType - } from "@wso2is/common.branding.v1/models"; +} from "@wso2is/common.branding.v1/models"; /** * Interface for the custom text preference API response. @@ -115,15 +115,16 @@ export interface CustomTextPreferenceScreenMetaInterface { * Base variations for screens. Represents the basic state of the screen. */ export const BASE_DISPLAY_VARIATION :Record = { - "common" : PreviewScreenVariationType.BASE, - "email-otp" : PreviewScreenVariationType.BASE, - "email-template" : PreviewScreenVariationType.BASE, - "login" : PreviewScreenVariationType.BASE, - "myaccount" : PreviewScreenVariationType.BASE, - "password-recovery" : PreviewScreenVariationType.EMAIL_LINK, - "password-reset" : PreviewScreenVariationType.BASE, - "password-reset-success" : PreviewScreenVariationType.BASE, - "sign-up" : PreviewScreenVariationType.BASE, - "sms-otp" : PreviewScreenVariationType.BASE, - "totp" : PreviewScreenVariationType.BASE + [PreviewScreenType.COMMON]: PreviewScreenVariationType.BASE, + [PreviewScreenType.EMAIL_OTP]: PreviewScreenVariationType.BASE, + [PreviewScreenType.EMAIL_TEMPLATE]: PreviewScreenVariationType.BASE, + [PreviewScreenType.LOGIN]: PreviewScreenVariationType.BASE, + [PreviewScreenType.MY_ACCOUNT]: PreviewScreenVariationType.BASE, + [PreviewScreenType.PASSWORD_RECOVERY]: PreviewScreenVariationType.EMAIL_LINK, + [PreviewScreenType.PASSWORD_RESET]: PreviewScreenVariationType.BASE, + [PreviewScreenType.PASSWORD_RESET_SUCCESS]: PreviewScreenVariationType.BASE, + [PreviewScreenType.SIGN_UP]: PreviewScreenVariationType.BASE, + [PreviewScreenType.SMS_OTP]: PreviewScreenVariationType.BASE, + [PreviewScreenType.TOTP]: PreviewScreenVariationType.BASE, + [PreviewScreenType.EMAIL_LINK_EXPIRY]: PreviewScreenVariationType.BASE };