Migrate Access administration patterns
This commit is contained in:
@@ -11,7 +11,7 @@ import type {
|
||||
OrganizationFunctionPickerUiCapability
|
||||
} from "@govoplan/core-webui";
|
||||
import { fetchShellAuth } from "@govoplan/core-webui";
|
||||
import { Card } from "@govoplan/core-webui";
|
||||
import { ActionBlockerHint } from "@govoplan/core-webui";
|
||||
import { PageScrollViewport } from "@govoplan/core-webui";
|
||||
import {
|
||||
TreeSubnav,
|
||||
@@ -28,6 +28,10 @@ import ApiKeysPanel from "./ApiKeysPanel";
|
||||
import FileConnectorsPanel from "./FileConnectorsPanel";
|
||||
import MailProfilesPanel from "./MailProfilesPanel";
|
||||
import CredentialEnvelopesPanel from "./CredentialEnvelopesPanel";
|
||||
import {
|
||||
ACCESS_INTERFACE_I18N,
|
||||
ACCESS_WORKFLOW_DOCUMENTATION
|
||||
} from "./interfacePatterns";
|
||||
import {
|
||||
isViewSurfaceVisible,
|
||||
useEffectiveView,
|
||||
@@ -45,6 +49,7 @@ type OrderedAdminNavItem = {
|
||||
kind?: "management" | "settings";
|
||||
};
|
||||
type AdminNavGroup = {
|
||||
id: string;
|
||||
title: string;
|
||||
items: OrderedAdminNavItem[];
|
||||
};
|
||||
@@ -221,18 +226,32 @@ export default function AdminPage({
|
||||
if (!hasAnyScope(auth, adminReadScopes)) {
|
||||
return (
|
||||
<PageScrollViewport>
|
||||
<div className="content-pad">
|
||||
<Card title="i18n:govoplan-access.administration_unavailable.b86d4cb5">
|
||||
<p>i18n:govoplan-access.your_current_roles_do_not_grant_administrative_a.6eafee69</p>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="content-pad">
|
||||
<ActionBlockerHint
|
||||
tone="warning"
|
||||
reason={{
|
||||
summary: "i18n:govoplan-access.administration_unavailable.b86d4cb5",
|
||||
details: "i18n:govoplan-access.your_current_roles_do_not_grant_administrative_a.6eafee69",
|
||||
requiredAction: ACCESS_INTERFACE_I18N.requestAdministrationAccess,
|
||||
actor: ACCESS_INTERFACE_I18N.accessAdministrator,
|
||||
target: ACCESS_INTERFACE_I18N.accessAdministration
|
||||
}}
|
||||
labels={{
|
||||
requiredAction: ACCESS_INTERFACE_I18N.requiredAction,
|
||||
actor: ACCESS_INTERFACE_I18N.actor,
|
||||
target: ACCESS_INTERFACE_I18N.destinationLabel
|
||||
}}
|
||||
documentation={ACCESS_WORKFLOW_DOCUMENTATION}
|
||||
/>
|
||||
</div>
|
||||
</PageScrollViewport>
|
||||
);
|
||||
}
|
||||
|
||||
const adminNavGroups: AdminNavGroup[] = [
|
||||
{
|
||||
title: "ADMINISTRATION",
|
||||
id: "administration",
|
||||
title: "i18n:govoplan-access.admin.4e7afebc",
|
||||
items: sortNavItems([
|
||||
...contributedNavItems(contributedSections, available, "ROOT"),
|
||||
visibleNavItem(available, "system-modules", "i18n:govoplan-access.modules.04e9462c", 10),
|
||||
@@ -243,7 +262,8 @@ export default function AdminPage({
|
||||
])
|
||||
},
|
||||
{
|
||||
title: "GLOBAL",
|
||||
id: "global",
|
||||
title: "i18n:govoplan-access.global",
|
||||
items: sortNavItems([
|
||||
visibleNavItem(available, "system-roles", "i18n:govoplan-access.system_roles.a9461aa6", 20),
|
||||
visibleNavItem(available, "system-role-templates", "i18n:govoplan-access.tenant_role_templates", 30),
|
||||
@@ -257,7 +277,8 @@ export default function AdminPage({
|
||||
])
|
||||
},
|
||||
{
|
||||
title: "TENANT",
|
||||
id: "tenant",
|
||||
title: "i18n:govoplan-access.tenant.3ca93c78",
|
||||
items: sortNavItems([
|
||||
visibleNavItem(available, "tenant-roles", "i18n:govoplan-access.roles.47dcc27d", 10),
|
||||
visibleNavItem(available, "tenant-function-role-mappings", "i18n:govoplan-access.function_role_mappings.2b64e9c3", 20),
|
||||
@@ -271,7 +292,8 @@ export default function AdminPage({
|
||||
])
|
||||
},
|
||||
{
|
||||
title: "GROUP",
|
||||
id: "group",
|
||||
title: "i18n:govoplan-access.group.171a0606",
|
||||
items: sortNavItems([
|
||||
visibleNavItem(available, "tenant-group-file-connectors", "i18n:govoplan-access.file_connections.1e362326", 10),
|
||||
visibleNavItem(available, "tenant-group-mail-servers", "i18n:govoplan-access.mail_servers.d627326a", 20),
|
||||
@@ -280,7 +302,8 @@ export default function AdminPage({
|
||||
])
|
||||
},
|
||||
{
|
||||
title: "USER",
|
||||
id: "user",
|
||||
title: "i18n:govoplan-access.user.9f8a2389",
|
||||
items: sortNavItems([
|
||||
visibleNavItem(available, "tenant-user-file-connectors", "i18n:govoplan-access.file_connections.1e362326", 10),
|
||||
visibleNavItem(available, "tenant-user-mail-servers", "i18n:govoplan-access.mail_servers.d627326a", 20),
|
||||
@@ -398,13 +421,13 @@ function adminNavigationTree(
|
||||
byModule.set(moduleId, [...(byModule.get(moduleId) ?? []), item]);
|
||||
}
|
||||
children.push({
|
||||
branchId: `admin-${group.title.toLowerCase()}-settings`,
|
||||
branchId: `admin-${group.id}-settings`,
|
||||
label: "i18n:govoplan-core.settings.c7f73bb5",
|
||||
defaultExpanded: false,
|
||||
children: [...byModule.entries()]
|
||||
.sort(([left], [right]) => left.localeCompare(right))
|
||||
.map(([moduleId, items]) => ({
|
||||
branchId: `admin-${group.title.toLowerCase()}-settings-${moduleId}`,
|
||||
branchId: `admin-${group.id}-settings-${moduleId}`,
|
||||
label: moduleLabel(moduleId),
|
||||
defaultExpanded: items.some(
|
||||
(item) => item.id === "system-settings"
|
||||
@@ -414,16 +437,20 @@ function adminNavigationTree(
|
||||
});
|
||||
}
|
||||
return {
|
||||
branchId: `admin-${group.title.toLowerCase()}`,
|
||||
branchId: `admin-${group.id}`,
|
||||
label: group.title,
|
||||
defaultExpanded: group.title === "ADMINISTRATION",
|
||||
defaultExpanded: group.id === "administration",
|
||||
children
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function moduleLabel(moduleId: string): string {
|
||||
if (moduleId === "platform") return "Platform";
|
||||
if (moduleId === "platform") return "i18n:govoplan-access.platform_administration";
|
||||
if (moduleId === "access") return "i18n:govoplan-access.access.2f81a22d";
|
||||
if (moduleId === "admin") return "i18n:govoplan-access.admin.4e7afebc";
|
||||
if (moduleId === "files") return "i18n:govoplan-access.files.6ce6c512";
|
||||
if (moduleId === "mail") return "i18n:govoplan-access.mail_servers.d627326a";
|
||||
return moduleId
|
||||
.split(/[-_]/)
|
||||
.filter(Boolean)
|
||||
|
||||
Reference in New Issue
Block a user