From 696acacecde3aaec0c665431fdf19ef7531bc688 Mon Sep 17 00:00:00 2001 From: DonOmalVindula Date: Tue, 3 Sep 2024 15:36:01 +0530 Subject: [PATCH] Add config to disable add/delete actions for remote userstores --- .../admin.extensions.v1/configs/groups.tsx | 5 +-- .../configs/models/group.ts | 24 ++-------- .../edit-group/edit-group-basic.tsx | 13 +++--- .../admin.groups.v1/components/group-list.tsx | 44 ++++++++++++------- .../components/wizard/group-basics.tsx | 2 +- features/admin.groups.v1/pages/groups.tsx | 11 ++++- .../wso2is/apps/developer-portal.overrides | 1 - 7 files changed, 52 insertions(+), 48 deletions(-) diff --git a/features/admin.extensions.v1/configs/groups.tsx b/features/admin.extensions.v1/configs/groups.tsx index 9ee3fa22bb9..6546d38bc03 100644 --- a/features/admin.extensions.v1/configs/groups.tsx +++ b/features/admin.extensions.v1/configs/groups.tsx @@ -19,7 +19,6 @@ import { GroupConfig } from "./models"; export const groupConfig: GroupConfig = { - addGroupWizard: { - showUserstoreDropdown: true - } + allowGroupAddForRemoteUserstores: true, + allowGroupDeleteForRemoteUserstores: true }; diff --git a/features/admin.extensions.v1/configs/models/group.ts b/features/admin.extensions.v1/configs/models/group.ts index 91709b94549..782a3aa5e26 100644 --- a/features/admin.extensions.v1/configs/models/group.ts +++ b/features/admin.extensions.v1/configs/models/group.ts @@ -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 @@ -16,26 +16,8 @@ * under the License. */ -import { GroupsInterface } from "@wso2is/admin.groups.v1"; export interface GroupConfig { - addGroupWizard: { - requiredSteps?: string[]; - showUserstoreDropdown?: boolean; - subHeading?: string; - submitStep?: string; - }; - editGroups?: { - basicTab: { - showGroupNameLabel: boolean; - userstore: (groupObject: GroupsInterface) => string; - }; - basicTabName: string; - showRolesTab: boolean; - }; - groupsList?: { - description: string; - filterGroups: (groupResources: GroupsInterface[]) => GroupsInterface[]; - showUserstoreDropdown: boolean; - }; + allowGroupAddForRemoteUserstores: boolean; + allowGroupDeleteForRemoteUserstores: boolean; } diff --git a/features/admin.groups.v1/components/edit-group/edit-group-basic.tsx b/features/admin.groups.v1/components/edit-group/edit-group-basic.tsx index 215ddd4db61..ef0bfea69b1 100644 --- a/features/admin.groups.v1/components/edit-group/edit-group-basic.tsx +++ b/features/admin.groups.v1/components/edit-group/edit-group-basic.tsx @@ -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 @@ -23,7 +23,7 @@ import { UserStoreProperty, history } from "@wso2is/admin.core.v1"; -import { userstoresConfig } from "@wso2is/admin.extensions.v1"; +import { groupConfig, userstoresConfig } from "@wso2is/admin.extensions.v1"; import { AlertInterface, AlertLevels, @@ -97,7 +97,10 @@ export const BasicGroupDetails: FunctionComponent = (props: Bas const userStore: string = groupObject?.displayName?.split("/")?.length > 1 ? groupObject.displayName.split("/")[0] - : SharedUserStoreConstants.PRIMARY_USER_STORE; + : userstoresConfig.primaryUserstoreName; + + const isUserstoreDeleteDisabled: boolean = !groupConfig?.allowGroupDeleteForRemoteUserstores + && userStore !== userstoresConfig.primaryUserstoreName; useEffect(() => { if (groupObject && groupObject.displayName.indexOf("/") !== -1) { @@ -115,7 +118,7 @@ export const BasicGroupDetails: FunctionComponent = (props: Bas const validateGroupNamePattern = async (): Promise => { let userStoreRegEx: string = ""; - if (userStore !== SharedUserStoreConstants.PRIMARY_USER_STORE) { + if (userStore !== userstoresConfig.primaryUserstoreName) { await SharedUserStoreUtils.getUserStoreRegEx(userStore, SharedUserStoreConstants.USERSTORE_REGEX_PROPERTIES.RolenameRegEx) .then((response: string) => { @@ -352,7 +355,7 @@ export const BasicGroupDetails: FunctionComponent = (props: Bas