Skip to content

Commit

Permalink
Disable guest user and privileged user related UI elements
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan committed Oct 1, 2024
1 parent 142c4f6 commit dfde4f2
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 24 deletions.
5 changes: 4 additions & 1 deletion apps/console/src/public/deployment.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,10 @@
}
},
"consoleSettings": {
"disabledFeatures": [],
"disabledFeatures": [
"consoleSettings.invitedAdmins",
"consoleSettings.privilegedUsers"
],
"enabled": true,
"scopes": {
"create": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { GearIcon } from "@oxygen-ui/react-icons";
import {
FeatureAccessConfigInterface,
FeatureStatus,
Show,
useCheckFeatureStatus
Expand Down Expand Up @@ -144,6 +145,18 @@ const AdministratorsList: React.FunctionComponent<AdministratorsListProps> = (

const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features);

const consoleSettingsFeatureConfig: FeatureAccessConfigInterface =
useSelector((state: AppState) => state.config.ui.features.consoleSettings);

const isPrivilegedUsersInConsoleSettingsEnabled: boolean =
!consoleSettingsFeatureConfig?.disabledFeatures?.includes(
"consoleSettings.privilegedUsers"
);
const isInvitedAdminInConsoleSettingsEnabled: boolean = !consoleSettingsFeatureConfig?.disabledFeatures?.includes(
"consoleSettings.invitedAdmins"
);


const { isSubOrganization, isFirstLevelOrganization, isSuperOrganization } = useGetCurrentOrganizationType();
const { unassignAdministratorRoles } = useBulkAssignAdministratorRoles();

Expand Down Expand Up @@ -270,7 +283,7 @@ const AdministratorsList: React.FunctionComponent<AdministratorsListProps> = (

const addAdminOptions: any = [];

if (!isCurrentOrgSubOrganization) {
if (!isCurrentOrgSubOrganization && isInvitedAdminInConsoleSettingsEnabled) {
addAdminOptions.push({
"data-componentid": `${componentId}-add-external-admin-dropdown-item`,
key: 1,
Expand Down Expand Up @@ -351,6 +364,27 @@ const AdministratorsList: React.FunctionComponent<AdministratorsListProps> = (
history.push(AdministratorConstants.getPaths().get("COLLABORATOR_SETTINGS_EDIT_PATH"));
};

const renderRightActionPanel = () => {

if (isPrivilegedUsersInConsoleSettingsEnabled) {
return null;
}

if (isFirstLevelOrganization() || isSuperOrganization()) {
return (
<Dropdown
data-testid="user-mgt-user-list-userstore-dropdown"
selection
options={ availableUserStores }
onChange={ handleSelectedUserStoreChange }
defaultValue={ PRIMARY_USERSTORE }
/>
);
}

return null;
};

return (
<ListLayout
advancedSearch={ (
Expand Down Expand Up @@ -414,26 +448,19 @@ const AdministratorsList: React.FunctionComponent<AdministratorsListProps> = (
paginationOptions={ {
disableNextButton: !isNextPageAvailable
} }
rightActionPanel={
!isEnterpriseLoginEnabled && (isFirstLevelOrganization() || isSuperOrganization())
? (
<Dropdown
data-testid="user-mgt-user-list-userstore-dropdown"
selection
options={ availableUserStores }
onChange={ handleSelectedUserStoreChange }
defaultValue={ PRIMARY_USERSTORE }
/>
) : null
}
rightActionPanel={ renderRightActionPanel() }
topActionPanelExtension={ (
<Show when={ [ ...featureConfig?.users?.scopes?.create, ...featureConfig?.userRoles?.scopes?.update ] }>
{ !isSubOrganization() && isEnterpriseLoginEnabled && (<Button
data-componentid={ `${componentId}-admin-settings-button` }
icon={ GearIcon }
onClick={ handleSettingsButton }
>
</Button>) }
{ !isSubOrganization() &&
isEnterpriseLoginEnabled &&
isPrivilegedUsersInConsoleSettingsEnabled && (
<Button
data-componentid={ `${componentId}-admin-settings-button` }
icon={ GearIcon }
onClick={ handleSettingsButton }
>
</Button>
) }
{ renderAdministratorAddOptions() }
</Show>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import FormControlLabel from "@oxygen-ui/react/FormControlLabel";
import Radio from "@oxygen-ui/react/Radio";
import RadioGroup from "@oxygen-ui/react/RadioGroup";
import { FeatureStatus, useCheckFeatureStatus } from "@wso2is/access-control";
import { FeatureAccessConfigInterface, FeatureStatus, useCheckFeatureStatus } from "@wso2is/access-control";
import { useOrganizationConfigV2 } from "@wso2is/admin.administrators.v1/api/useOrganizationConfigV2";
import { UseOrganizationConfigType } from "@wso2is/admin.administrators.v1/models/organization";
import { UserStoreProperty, getAUserStore, store } from "@wso2is/admin.core.v1";
import { AppState, UserStoreProperty, getAUserStore, store } from "@wso2is/admin.core.v1";
import { userstoresConfig } from "@wso2is/admin.extensions.v1";
import FeatureGateConstants from "@wso2is/admin.feature-gate.v1/constants/feature-gate-constants";
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";
Expand All @@ -36,6 +36,7 @@ import React, {
useEffect,
useState
} from "react";
import { useSelector } from "react-redux";
import AdministratorsList from "./administrators-list/administrators-list";
import InvitedAdministratorsList from "./invited-administrators/invited-administrators-list";

Expand All @@ -57,6 +58,13 @@ const ConsoleAdministrators: FunctionComponent<ConsoleAdministratorsInterface> =

const { isFirstLevelOrganization, isSubOrganization } = useGetCurrentOrganizationType();

const consoleSettingsFeatureConfig: FeatureAccessConfigInterface =
useSelector((state: AppState) => state?.config?.ui?.features?.consoleSettings);
const isPrivilegedUsersInConsoleSettingsEnabled: boolean =
!consoleSettingsFeatureConfig?.disabledFeatures?.includes(
"consoleSettings.privilegedUsers"
);

const [ activeAdministratorGroup, setActiveAdministratorGroup ] =
useState(isSubOrganization() ? "activeUsers" : "administrators");
const [ availableUserStores, setAvailableUserStores ] = useState<UserStoreDropdownItem[]>([]);
Expand Down Expand Up @@ -163,7 +171,11 @@ const ConsoleAdministrators: FunctionComponent<ConsoleAdministratorsInterface> =
};

const renderActiveAdministratorGroups = (): ReactElement => {
if (isFirstLevelOrganization() && isEnterpriseLoginEnabled) {
if (
isFirstLevelOrganization()
&& isEnterpriseLoginEnabled
&& isPrivilegedUsersInConsoleSettingsEnabled
) {
return (
<RadioGroup
row
Expand Down
1 change: 1 addition & 0 deletions features/admin.console-settings.v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@wso2is/admin.authentication.v1": "^2.21.12",
"@wso2is/admin.core.v1": "^2.30.12",
"@wso2is/admin.extensions.v1": "^2.30.12",
"@wso2is/admin.feature-gate.v1": "^1.1.10",
"@wso2is/admin.identity-providers.v1": "^2.22.12",
"@wso2is/admin.login-flow.ai.v1": "^2.22.12",
"@wso2is/admin.organizations.v1": "^2.22.12",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dfde4f2

Please sign in to comment.