Skip to content

Commit 3b5f1b2

Browse files
authored
change the realm selector into a section (keycloak#38169)
* change the realm selector into a section fixes: keycloak#38112 Signed-off-by: Erik Jan de Wit <[email protected]> make realms a section and remove realm selector Signed-off-by: Erik Jan de Wit <[email protected]> * pr feedback Signed-off-by: Erik Jan de Wit <[email protected]> * fixed tests Signed-off-by: Erik Jan de Wit <[email protected]> * fixed realm test Signed-off-by: Erik Jan de Wit <[email protected]> * update nav items Signed-off-by: Erik Jan de Wit <[email protected]> * fixed markup Signed-off-by: Erik Jan de Wit <[email protected]> * fix test Signed-off-by: Erik Jan de Wit <[email protected]> * only show manage when you are logged in via master realm Signed-off-by: Erik Jan de Wit <[email protected]> * add fallback for when no realm access still see manage realms Signed-off-by: Erik Jan de Wit <[email protected]> * change link to go to realm dashboard Signed-off-by: Erik Jan de Wit <[email protected]> * change recent realms to go to dashboard Signed-off-by: Erik Jan de Wit <[email protected]> --------- Signed-off-by: Erik Jan de Wit <[email protected]>
1 parent 1d6ef3c commit 3b5f1b2

File tree

18 files changed

+395
-379
lines changed

18 files changed

+395
-379
lines changed

js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ eventTypes.RESTART_AUTHENTICATION.description=Restart authentication
17191719
scopePermissions.users.manage-group-membership-description=Policies that decide if an administrator can manage group membership for all users in the realm. This is used in conjunction with specific group policy
17201720
loginTheme=Login theme
17211721
eventTypes.UPDATE_PASSWORD_ERROR.description=Update password error
1722-
deleteConfirmRealmSetting=If you delete this realm, all associated data will be removed.
1722+
deleteConfirmRealmSetting=If you delete a realm, all associated data will be removed.
17231723
scope=Scope
17241724
evaluateExplain=This page allows you to see all protocol mappers and role scope mappings
17251725
providerCreateError=Could not create client policy due to {{error}}
@@ -3449,6 +3449,11 @@ grantedScope=Granted scope:
34493449
deniedScope=Denied scope:
34503450
evaluatedPolicy={{name}} voted to {{status}}
34513451
permissionEvaluationAlertTitle=The selected user does not have access to the selected resource(s)
3452+
deleteConfirmRealm_one=Delete realm {{name}}?
3453+
deleteConfirmRealm_other=Delete {{count}} realms?
3454+
recentRealms=Recent realms
3455+
manageRealms=Manage realms
3456+
cantDeleteMasterRealm=You can not delete the master realm!
34523457
selectRole=Select role
34533458
selectUsers=Select user
34543459
selectClient=Select client

js/apps/admin-ui/src/PageHeader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { useTranslation } from "react-i18next";
99
import { Link, useHref } from "react-router-dom";
1010
import { PageHeaderClearCachesModal } from "./PageHeaderClearCachesModal";
1111
import { HelpHeader } from "./components/help-enabler/HelpHeader";
12-
import { RealmPanel } from "./components/realm-selector/RealmPanel";
1312
import { useAccess } from "./context/access/Access";
1413
import { useRealm } from "./context/realm-context/RealmContext";
1514
import { toDashboard } from "./dashboard/routes/Dashboard";
@@ -122,7 +121,6 @@ export const Header = () => {
122121
}}
123122
dropdownItems={userDropdownItems(isMasterRealm, isManager)}
124123
kebabDropdownItems={kebabDropdownItems(isMasterRealm, isManager)}
125-
toolbar={<RealmPanel />}
126124
toolbarItems={[
127125
<ToolbarItem
128126
key="help"

js/apps/admin-ui/src/PageNav.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { label, useEnvironment } from "@keycloak/keycloak-ui-shared";
12
import {
3+
Label,
24
Nav,
35
NavGroup,
46
PageSidebar,
@@ -10,13 +12,18 @@ import { NavLink, useNavigate } from "react-router-dom";
1012
import { useAccess } from "./context/access/Access";
1113
import { useRealm } from "./context/realm-context/RealmContext";
1214
import { useServerInfo } from "./context/server-info/ServerInfoProvider";
15+
import { Environment } from "./environment";
1316
import { toPage } from "./page/routes";
1417
import { routes } from "./routes";
1518
import useIsFeatureEnabled, { Feature } from "./utils/useIsFeatureEnabled";
1619

1720
import "./page-nav.css";
1821

19-
type LeftNavProps = { title: string; path: string; id?: string };
22+
type LeftNavProps = {
23+
title: string;
24+
path: string;
25+
id?: string;
26+
};
2027

2128
const LeftNav = ({ title, path, id }: LeftNavProps) => {
2229
const { t } = useTranslation();
@@ -35,7 +42,7 @@ const LeftNav = ({ title, path, id }: LeftNavProps) => {
3542
: hasAccess(route.handle.access));
3643

3744
if (!accessAllowed) {
38-
return null;
45+
return undefined;
3946
}
4047

4148
const name = "nav-item" + path.replace("/", "-");
@@ -57,13 +64,14 @@ const LeftNav = ({ title, path, id }: LeftNavProps) => {
5764

5865
export const PageNav = () => {
5966
const { t } = useTranslation();
67+
const { environment } = useEnvironment<Environment>();
6068
const { hasSomeAccess } = useAccess();
6169
const { componentTypes } = useServerInfo();
6270
const isFeatureEnabled = useIsFeatureEnabled();
6371
const pages =
6472
componentTypes?.["org.keycloak.services.ui.extend.UiPageProvider"];
6573
const navigate = useNavigate();
66-
const { realmRepresentation } = useRealm();
74+
const { realm, realmRepresentation } = useRealm();
6775

6876
type SelectedItem = {
6977
groupId: number | string;
@@ -91,10 +99,26 @@ export const PageNav = () => {
9199
"view-identity-providers",
92100
);
93101

102+
const showManageRealm = environment.masterRealm === environment.realm;
103+
94104
return (
95105
<PageSidebar className="keycloak__page_nav__nav">
96106
<PageSidebarBody>
97107
<Nav onSelect={(_event, item) => onSelect(item as SelectedItem)}>
108+
<h2
109+
className="pf-v5-c-nav__section-title"
110+
style={{ wordWrap: "break-word" }}
111+
>
112+
<span data-testid="currentRealm">
113+
{label(t, realmRepresentation?.displayName, realm)}
114+
</span>{" "}
115+
<Label color="blue">{t("currentRealm")}</Label>
116+
</h2>
117+
{showManageRealm && (
118+
<NavGroup>
119+
<LeftNav title={t("manageRealms")} path="/realms" />
120+
</NavGroup>
121+
)}
98122
{showManage && (
99123
<NavGroup aria-label={t("manage")} title={t("manage")}>
100124
{isFeatureEnabled(Feature.Organizations) &&

js/apps/admin-ui/src/components/realm-selector/RealmPanel.tsx

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)