Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix administrator settings route not working when console settings for root organizations in enabled in managed deployment #6964

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/clean-beans-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/admin.administrators.v1": patch
"@wso2is/console": patch
---

Fix administrator settings route not working when console settings for root organizations in enabled in managed deployment
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
1 change: 1 addition & 0 deletions apps/console/src/extensions/i18n/models/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3325,6 +3325,7 @@ export interface Extensions {
administratorSettingsSubtitle: string;
administratorSettingsTitle: string;
backButton: string;
backButtonConsoleSettings: string;
disableToggleMessage: string;
enableToggleMessage: string;
error: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4027,6 +4027,7 @@ export const extensions: Extensions = {
administratorSettingsSubtitle: "Settings related to organizational administrators.",
administratorSettingsTitle: "Administrator Settings",
backButton: "Go back to administrators",
backButtonConsoleSettings: "Go back to console settings",
disableToggleMessage: "Enable users to manage the organization",
enableToggleMessage: "Disable users to manage the organization",
error: {
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
? t("extensions:manage.users.administratorSettings.backButtonConsoleSettings")
: t("extensions:manage.users.administratorSettings.backButton")
} }
bottomMargin={ false }
contentTopMargin={ true }
Expand Down
Loading