Skip to content

Commit

Permalink
Conditionally display the back button text of administrator settings …
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
pavinduLakshan committed Oct 14, 2024
1 parent 239ec66 commit 5e492dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
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 @@ -3326,6 +3326,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 @@ -4026,6 +4026,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

0 comments on commit 5e492dc

Please sign in to comment.