diff --git a/features/admin.branding.v1/components/screen-dropdown.tsx b/features/admin.branding.v1/components/screen-dropdown.tsx index dee0c95b5ac..2cc64f948c9 100644 --- a/features/admin.branding.v1/components/screen-dropdown.tsx +++ b/features/admin.branding.v1/components/screen-dropdown.tsx @@ -16,11 +16,14 @@ * under the License. */ +import { AppState } from "@wso2is/admin.core.v1/store"; import { PreviewScreenType } from "@wso2is/common.branding.v1/models/branding-preferences"; import { IdentifiableComponentInterface } from "@wso2is/core/models"; import React, { FunctionComponent, ReactElement, useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; +import { useSelector } from "react-redux"; import { DropdownProps, Form, Select } from "semantic-ui-react"; +import { BRANDING_PREVIEW_SCREEN_ID } from "../constants/preview-screen-constants"; /** * Prop types for the language dropdown component. @@ -57,6 +60,7 @@ const ScreenDropdown: FunctionComponent = ( ): ReactElement => { const { onChange, defaultScreen, screens, required, ["data-componentid"]: componentId } = props; + const { t } = useTranslation(); const [ selectedScreen, setSelectedScreen ] = useState(defaultScreen); @@ -66,6 +70,9 @@ const ScreenDropdown: FunctionComponent = ( onChange(defaultScreen); }, [ defaultScreen ]); + const disabledFeatures: string[] = useSelector((state: AppState) => + state?.config?.ui?.features?.branding?.disabledFeatures) || []; + const supportedScreens: { key: string; text: string; @@ -75,13 +82,14 @@ const ScreenDropdown: FunctionComponent = ( return []; } - return screens.map((screen: string) => { - return { - key: screen, - text: t(`branding:screens.${ screen }`), - value: screen - }; - }); + return screens.filter((screen: string) => !disabledFeatures.includes(BRANDING_PREVIEW_SCREEN_ID+screen)). + map((screen: string) => { + return { + key: screen, + text: t(`branding:screens.${ screen }`), + value: screen + }; + }); }, [ screens ]); return ( diff --git a/features/admin.branding.v1/constants/preview-screen-constants.ts b/features/admin.branding.v1/constants/preview-screen-constants.ts new file mode 100644 index 00000000000..55a77b45586 --- /dev/null +++ b/features/admin.branding.v1/constants/preview-screen-constants.ts @@ -0,0 +1,19 @@ +/** + * 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 const BRANDING_PREVIEW_SCREEN_ID: string = "branding.preview.screens.";