Restore feature flags and hidden menu items. (#20912)

Fixes #19683
This commit is contained in:
Stan Silvert 2023-06-13 10:16:41 -04:00 committed by GitHub
parent 7e2565c9fe
commit e4cc7825f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 4 deletions

View file

@ -92,7 +92,20 @@
"realm": "${realm.name}",
"resourceUrl": "${resourceUrl}",
"logo": "${properties.logo!""}",
"logoUrl": "${properties.logoUrl!""}"
"logoUrl": "${properties.logoUrl!""}",
"features": {
"isRegistrationEmailAsUsername": ${realm.registrationEmailAsUsername?c},
"isEditUserNameAllowed": ${realm.editUsernameAllowed?c},
"isInternationalizationEnabled": ${realm.isInternationalizationEnabled()?c},
"isLinkedAccountsEnabled": ${realm.identityFederationEnabled?c},
"isEventsEnabled": ${isEventsEnabled?c},
"isMyResourcesEnabled": ${(realm.userManagedAccessAllowed && isAuthorizationEnabled)?c},
"isTotpConfigured": ${isTotpConfigured?c},
"deleteAccountAllowed": ${deleteAccountAllowed?c},
"updateEmailFeatureEnabled": ${updateEmailFeatureEnabled?c},
"updateEmailActionEnabled": ${updateEmailActionEnabled?c},
"isViewGroupsEnabled": ${isViewGroupsEnabled?c}
}
}
</script>
</body>

View file

@ -11,6 +11,20 @@ export type Environment = {
logo: string;
/** Indicates the url to be followed when Brand image is clicked */
logoUrl: string;
/** Feature flags */
features: {
isRegistrationEmailAsUsername: boolean;
isEditUserNameAllowed: boolean;
isInternationalizationEnabled: boolean;
isLinkedAccountsEnabled: boolean;
isEventsEnabled: boolean;
isMyResourcesEnabled: boolean;
isTotpConfigured: boolean;
deleteAccountAllowed: boolean;
updateEmailFeatureEnabled: boolean;
updateEmailActionEnabled: boolean;
isViewGroupsEnabled: boolean;
};
};
// The default environment, used during development.
@ -21,6 +35,19 @@ const defaultEnvironment: Environment = {
resourceUrl: "http://localhost:8080",
logo: "/logo.svg",
logoUrl: "/",
features: {
isRegistrationEmailAsUsername: false,
isEditUserNameAllowed: true,
isInternationalizationEnabled: true,
isLinkedAccountsEnabled: true,
isEventsEnabled: true,
isMyResourcesEnabled: true,
isTotpConfigured: true,
deleteAccountAllowed: true,
updateEmailFeatureEnabled: true,
updateEmailActionEnabled: true,
isViewGroupsEnabled: true,
},
};
// Merge the default and injected environment variables together.

View file

@ -19,15 +19,18 @@ import {
useLinkClickHandler,
useLocation,
} from "react-router-dom";
import { environment } from "../environment";
type RootMenuItem = {
label: TFuncKey;
path: string;
isHidden?: boolean;
};
type MenuItemWithChildren = {
label: TFuncKey;
children: MenuItem[];
isHidden?: boolean;
};
type MenuItem = RootMenuItem | MenuItemWithChildren;
@ -61,10 +64,12 @@ const menuItems: MenuItem[] = [
{
label: "groups",
path: "groups",
isHidden: !environment.features.isViewGroupsEnabled,
},
{
label: "resources",
path: "resources",
isHidden: !environment.features.isMyResourcesEnabled,
},
];
@ -73,7 +78,9 @@ export const PageNav = () => (
nav={
<Nav>
<NavList>
{menuItems.map((menuItem) => (
{menuItems
.filter((menuItem) => !menuItem.isHidden)
.map((menuItem) => (
<NavMenuItem key={menuItem.label} menuItem={menuItem} />
))}
</NavList>