Skip to content

Commit

Permalink
Add the page filetering in page drop down in branding.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malith-19 committed Nov 12, 2024
1 parent 594affc commit 7faeaa3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
22 changes: 15 additions & 7 deletions features/admin.branding.v1/components/screen-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -57,6 +60,7 @@ const ScreenDropdown: FunctionComponent<ScreenDropdownPropsInterface> = (
): ReactElement => {
const { onChange, defaultScreen, screens, required, ["data-componentid"]: componentId } = props;


const { t } = useTranslation();

const [ selectedScreen, setSelectedScreen ] = useState<PreviewScreenType>(defaultScreen);
Expand All @@ -66,6 +70,9 @@ const ScreenDropdown: FunctionComponent<ScreenDropdownPropsInterface> = (
onChange(defaultScreen);
}, [ defaultScreen ]);

const disabledFeatures: string[] = useSelector((state: AppState) =>
state?.config?.ui?.features?.branding?.disabledFeatures) || [];

const supportedScreens: {
key: string;
text: string;
Expand All @@ -75,13 +82,14 @@ const ScreenDropdown: FunctionComponent<ScreenDropdownPropsInterface> = (
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 (
Expand Down
19 changes: 19 additions & 0 deletions features/admin.branding.v1/constants/preview-screen-constants.ts
Original file line number Diff line number Diff line change
@@ -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.";

0 comments on commit 7faeaa3

Please sign in to comment.