Skip to content

Commit

Permalink
Merge pull request #7634 from Yasasr1/my-account-toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan authored Feb 16, 2025
2 parents fb708fc + 7eb84bb commit 57e6da9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-pants-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.core.v1": patch
---

Hide my account switch for sub-organization users when my account is not shared.
17 changes: 17 additions & 0 deletions features/admin.core.v1/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import MenuItem from "@oxygen-ui/react/MenuItem";
import Typography from "@oxygen-ui/react/Typography";
import { DiamondIcon, DiscordIcon, StackOverflowIcon, TalkingHeadsetIcon } from "@oxygen-ui/react-icons";
import { FeatureStatus, Show, useCheckFeatureStatus, useRequiredScopes } from "@wso2is/access-control";
import { useMyAccountApplicationData } from "@wso2is/admin.applications.v1/api/application";
import { organizationConfigs } from "@wso2is/admin.extensions.v1";
import FeatureGateConstants from "@wso2is/admin.feature-gate.v1/constants/feature-gate-constants";
import { FeatureStatusLabel } from "@wso2is/admin.feature-gate.v1/models/feature-status";
Expand Down Expand Up @@ -125,6 +126,11 @@ const Header: FunctionComponent<HeaderPropsInterface> = ({
const { isOrganizationManagementEnabled } = useGlobalVariables();
const eventPublisher: EventPublisher = EventPublisher.getInstance();

const {
data: myAccountApplicationData,
isLoading: isMyAccountAppDataLoading
} = useMyAccountApplicationData(null, showAppSwitchButton);

useEffect(() => {
if (saasFeatureStatus === FeatureStatus.DISABLED) {
return;
Expand Down Expand Up @@ -303,11 +309,22 @@ const Header: FunctionComponent<HeaderPropsInterface> = ({
)
];

/**
* Check if the my account switch button should be shown.
* Will be shown if the user is logged into their resident org and
* my account application is available in that organization.
*
* @returns If the app switch button should be shown.
*/
const isShowAppSwitchButton = (): boolean => {
if (!showAppSwitchButton) {
return false;
}

if (isMyAccountAppDataLoading || myAccountApplicationData?.applications?.length === 0) {
return false;
}

return !userOrganizationID || userOrganizationID === window["AppUtils"].getConfig().organizationName;
};

Expand Down

0 comments on commit 57e6da9

Please sign in to comment.