Skip to content

Commit

Permalink
Fix administrator settings route not working when console settings fo…
Browse files Browse the repository at this point in the history
…r root organizations in enabled in managed deployment
  • Loading branch information
pavinduLakshan committed Oct 7, 2024
1 parent 31a096d commit 062ce0f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
19 changes: 18 additions & 1 deletion apps/console/src/configs/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export const getAppViewRoutes = (): RouteInterface[] => {
const showStatusLabelForNewAuthzRuntimeFeatures: boolean =
window["AppUtils"]?.getConfig()?.ui?.showStatusLabelForNewAuthzRuntimeFeatures;

const isPrivilegedUsersInConsoleSettingsEnabled: boolean =
!window["AppUtils"]?.getConfig()?.ui?.features?.consoleSettings?.disabledFeatures?.includes(
"consoleSettings.privilegedUsers"
);

const defaultRoutes: RouteInterface[] = [
{
category: "extensions:manage.sidePanel.categories.userManagement",
Expand All @@ -90,7 +95,7 @@ export const getAppViewRoutes = (): RouteInterface[] => {
protected: true,
showOnSidePanel: false
},
{
!isPrivilegedUsersInConsoleSettingsEnabled && {
component: lazy(() => import("@wso2is/admin.administrators.v1/pages/administrator-settings")),
exact: true,
icon: {
Expand Down Expand Up @@ -1191,6 +1196,18 @@ export const getAppViewRoutes = (): RouteInterface[] => {
path: AppConstants.getPaths().get("CONSOLE_ADMINISTRATORS_EDIT"),
protected: true,
showOnSidePanel: false
},
isPrivilegedUsersInConsoleSettingsEnabled && {
component: lazy(() => import("@wso2is/admin.administrators.v1/pages/administrator-settings")),
exact: true,
icon: {
icon: getSidePanelIcons().childIcon
},
id: "administrator-settings-edit",
name: "administrator-settings-edit",
path: AppConstants.getPaths().get("ADMINISTRATOR_SETTINGS"),
protected: true,
showOnSidePanel: false
}
],
component: lazy(() => import("@wso2is/admin.console-settings.v1/pages/console-settings-page")),
Expand Down
21 changes: 17 additions & 4 deletions features/admin.administrators.v1/pages/administrator-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
* under the License.
*/

import { history, store } from "@wso2is/admin.core.v1";
import { FeatureAccessConfigInterface } from "@wso2is/access-control";
import { AppConstants, AppState, history, store } from "@wso2is/admin.core.v1";
import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import { DocumentationLink, PageLayout, useDocumentation } from "@wso2is/react-components";
import { AxiosError } from "axios";
import React, { FunctionComponent, ReactElement, SyntheticEvent, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { Dispatch } from "redux";
import { Checkbox, CheckboxProps, Icon, Message } from "semantic-ui-react";
import { updateOrganizationConfigV2 } from "../api/updateOrganizationConfigV2";
Expand Down Expand Up @@ -55,6 +56,14 @@ export const AdminSettingsPage: FunctionComponent<AdminSettingsPageInterface> =

const dispatch: Dispatch = useDispatch();

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

const useOrgConfig: UseOrganizationConfigType = useOrganizationConfigV2;
const updateOrgConfig: (isEnterpriseLoginEnabled: OrganizationInterface) =>
Promise<any> = updateOrganizationConfigV2;
Expand Down Expand Up @@ -155,7 +164,9 @@ export const AdminSettingsPage: FunctionComponent<AdminSettingsPageInterface> =
* This handles back button navigation
*/
const handleBackButtonClick = () => {
history.push(AdministratorConstants.getPaths().get("COLLABORATOR_USERS_PATH"));
history.push(isPrivilegedUsersInConsoleSettingsEnabled
? AppConstants.getPaths().get("CONSOLE_SETTINGS")
: AdministratorConstants.getPaths().get("COLLABORATOR_USERS_PATH"));
};

/**
Expand Down Expand Up @@ -197,7 +208,9 @@ export const AdminSettingsPage: FunctionComponent<AdminSettingsPageInterface> =
backButton={ {
"data-componentid": `${ testId }-page-back-button`,
onClick: handleBackButtonClick,
text: t("extensions:manage.users.administratorSettings.backButton")
text: isPrivilegedUsersInConsoleSettingsEnabled
? "Go back to console settings"
: "Go back to administrators"
} }
bottomMargin={ false }
contentTopMargin={ true }
Expand Down

0 comments on commit 062ce0f

Please sign in to comment.