feat(console): give each group its own routes URL

Resolve the selected group from /admin/groups/{groupId}, validate console paths, and use browser history for back navigation. Keep Groups active and let an active mobile-tab tap return to the list. Scope pending route loads to their group and retain the count beside long headings.
This commit is contained in:
翅膀 committed 2026-10-17 11:13:09 +08:00
1 parent ba95456e67
commit 535bfa98ce
11 files changed
+249 -63

No files matched your search

+2 -2
View File
@@ -18,7 +18,7 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord
- Per-group webhook ingress: optional `POST /webhook/{groupId}` with a per-group secret in KV (`tenant:{groupId}`) — Gitea/classic-GitHub/custom webhooks are verified against the group's secret instead of the operator's global ones; only that group's routes fire. The legacy `POST /webhook` (global secrets, all routes) stays untouched
- GitHub App tenant isolation: `Group.installationId` binds a group to one GitHub App installation; events whose `payload.installation.id` differs are rejected at dispatch (hard isolation on top of the optional `owners` list). The App's Setup URL points at `GET /auth/github/install`, which renders a choice page (create `inst-{installationId}` or bind to a group the signed-in user owns, verified by role); `POST /auth/github/install/bind` performs the provisioning. `installation.created` webhook events auto-provision as a fallback (create `inst-{installationId}` or bind existing groups whose `owners` match the installing account)
- GitHub OAuth: octokit (token is stored hashed for reverse lookup)
- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/logs` · `/admin/audit` · `/admin/metrics`); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies
- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/groups/{groupId}` a group's routes, members and webhook · `/admin/logs` · `/admin/audit` · `/admin/metrics`, parsed by `app/utils/admin-path.ts`; the admin page's `validate` 404s any other path); every page is a history entry, so the browser's back button returns from a group to the list (no in-page back button); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies
- Access control: every group has role-based members (`owner` / `admin` / `viewer`); super admins bypass; legacy `adminIds` are read as owners (backward compatible); owners manage members + invites; `owners` field stays super-only
- Invites: single-use 7-day links (`invite:{token}`) for joining a group as admin/viewer; `ALLOW_SELF_SIGNUP=1` gives access-less users a personal group on first login (self-service SaaS entry)
- Audit log: every admin operation (logins, group/route/member/invite changes) recorded in D1 `audit_logs`; pruned by the scheduled trigger after `AUDIT_RETENTION_DAYS` (default 90)
@@ -45,7 +45,7 @@ app/ # Vue 3 UI (Nuxt app dir)
│ # backdrop clicks), useGroups, useGroupRoutes, useFilterNode (AST helpers), useFragments, useLogs,
│ # useAudit, useInvites, useWebhook
├── types.ts # shared client types (Route, Group, Filter, ...)
└── utils/ # legal.ts (terms/privacy HTML bodies, zh/en), format.ts,
└── utils/ # legal.ts (terms/privacy HTML bodies, zh/en), format.ts, admin-path.ts (console URL parsing),
# filter-catalog.ts (bilingual filter suggestions + value/path validators)
server/ # Nitro server
├── routes/ # H3 handlers: /health, /webhook[/:groupId], /discord/interactions, /telegram/webhook,
+1 -1
View File
@@ -89,7 +89,7 @@ function fmtTime(ts: number): string {
<RcCard variant="outline" padding="none">
<div class="flex items-center justify-between border-b border-border px-5 py-4">
<h2 class="text-sm font-bold tracking-tight">{{ t("overview.recent") }}</h2>
<RcButton variant="link" size="xs" @click="router.replace('/admin/logs')">
<RcButton variant="link" size="xs" @click="router.push('/admin/logs')">
{{ t("overview.viewAll") }}
</RcButton>
</div>
+115 -49
View File
@@ -58,7 +58,7 @@
</div>
</header>
<div class="console-mobile-nav">
<div class="console-mobile-nav" @click="onMobileNavClick">
<RcTabs
:model-value="activeNav"
:items="mobileNav"
@@ -91,17 +91,19 @@
/>
<template v-else-if="selectedGroup">
<section class="console-context-bar">
<div>
<RcButton variant="ghost" size="sm" @click="exitGroup"
><ArrowLeft :size="15" />{{ t("group.back") }}</RcButton
<section class="console-context-bar console-group-bar">
<div class="console-group-heading">
<h2 :title="selectedGroup.name">{{ selectedGroup.name }}</h2>
<RcBadge
:variant="groupRoutesLoading ? 'soft' : 'success'"
size="sm"
dot
class="shrink-0"
:title="t('group.routeCount', { count: groupRoutes.length })"
>{{ groupRoutes.length }}</RcBadge
>
<p>{{ t("group.routesIn", { name: selectedGroup.name }) }}</p>
</div>
<div class="console-context-actions">
<RcBadge :variant="groupRoutesLoading ? 'soft' : 'success'" size="sm" dot>{{
groupRoutes.length
}}</RcBadge>
<template v-if="reordering">
<RcButton
variant="outline"
@@ -124,9 +126,14 @@
variant="outline"
color="neutral"
size="sm"
class="console-reorder-btn"
:disabled="groupRoutesLoading || saving"
:title="t('routes.reorder')"
:aria-label="t('routes.reorder')"
@click="startReorder"
><ArrowUpDown :size="15" />{{ t("routes.reorder") }}</RcButton
><ArrowUpDown :size="15" /><span class="console-reorder-label">{{
t("routes.reorder")
}}</span></RcButton
>
</div>
<p v-if="reordering" class="console-reorder-hint">{{ t("routes.reorderHint") }}</p>
@@ -146,7 +153,7 @@
@delete="onDelete"
/>
<section v-if="!groupRoutesLoading && !groupRoutes.length" class="console-empty">
<section v-if="groupRoutesReady && !groupRoutes.length" class="console-empty">
<RcEmptyState :title="t('routes.emptyGroup')">
<RcButton v-if="canEditRoutes(selectedGroup.id)" @click="openNew"
><Plus :size="16" />{{ t("routes.createFirst") }}</RcButton
@@ -168,6 +175,21 @@
/>
</template>
<section v-else-if="groupMissing" class="console-empty">
<RcEmptyState :title="t('group.notFound')">
<NuxtLink to="/admin/groups"
><RcButton variant="outline" color="neutral">{{
t("group.allGroups")
}}</RcButton></NuxtLink
>
</RcEmptyState>
</section>
<section v-else-if="routeGroupId" class="console-context-bar">
<p v-if="groupsError" class="err">{{ groupsError }}</p>
<RcBadge v-else variant="soft" size="sm" dot>{{ t("status.loading") }}</RcBadge>
</section>
<template v-else-if="view === 'groups'">
<section class="console-context-bar">
<div class="console-count">
@@ -274,12 +296,14 @@
class="mt-auto flex items-center justify-between pt-2 border-t border-border/70 text-xs"
>
<span class="text-faint text-[11px]">{{ t("overview.routes") }}</span>
<span
<NuxtLink
:to="groupPath(g.id)"
class="inline-flex items-center gap-1 font-semibold text-accent hover:underline"
@click.stop
>
{{ t("groups.open") }}
<ArrowRight :size="12" />
</span>
</NuxtLink>
</div>
</div>
</RcCard>
@@ -364,7 +388,6 @@
<script setup lang="ts">
import {
Activity,
ArrowLeft,
ArrowRight,
ArrowUpDown,
Check,
@@ -382,6 +405,8 @@ import {
Trash2,
} from "lucide-vue-next";
import type { Group, Route } from "~/types";
import type { AdminView } from "~/utils/admin-path";
import { adminGroupPath, parseAdminPath } from "~/utils/admin-path";
import { useAuditApi } from "~/composables/useAudit";
import WebhookPanel from "~/components/WebhookPanel.vue";
import AdminHome from "~/components/AdminHome.vue";
@@ -394,27 +419,16 @@ const router = useRouter();
/**
* The console view mirrors the URL path so navigation is deep-linkable:
* /admin (overview) · /admin/groups · /admin/logs · /admin/audit · /admin/metrics.
* Unknown slugs 404.
* /admin (overview) · /admin/groups · /admin/groups/{groupId} (a group's
* routes) · /admin/logs · /admin/audit · /admin/metrics. The page validates
* the path, so unknown slugs 404 before the console renders.
*/
type View = "overview" | "groups" | "logs" | "audit" | "metrics";
const view = computed<View | null>(() => {
const seg = route.path.split("/").filter(Boolean)[1];
if (!seg) return "overview";
if (
seg === "overview" ||
seg === "groups" ||
seg === "logs" ||
seg === "audit" ||
seg === "metrics"
)
return seg;
return null;
});
if (view.value === null) {
throw createError({ statusCode: 404, statusMessage: "Page not found", fatal: false });
}
type View = AdminView;
const adminPath = computed(() => parseAdminPath(route.params.slug));
const view = computed<View | null>(() => adminPath.value?.view ?? null);
/** Group whose routes page the URL opens (/admin/groups/{groupId}). */
const routeGroupId = computed(() => adminPath.value?.groupId ?? null);
const groupPath = adminGroupPath;
const nav = computed(() => [
{ id: "overview" as View, label: t("tab.overview"), path: "/admin" },
@@ -443,6 +457,7 @@ const activeNav = computed<View>(() => view.value ?? "overview");
const pageTitle = computed(() => {
if (selectedGroup.value) return t("group.routesIn", { name: selectedGroup.value.name });
if (routeGroupId.value) return t("tab.groups");
switch (view.value) {
case "overview":
return t("tab.overview");
@@ -484,6 +499,7 @@ const {
canEditGroup,
canEditRoutes,
loading: groupsLoading,
loaded: groupsLoaded,
needLogin,
error: groupsError,
load: loadGroups,
@@ -495,6 +511,8 @@ const {
loading: groupRoutesLoading,
error: groupRoutesError,
load: loadGroupRoutes,
clear: clearGroupRoutes,
ready: groupRoutesReady,
save: saveGroupRoutes,
} = useGroupRoutesApi();
@@ -502,7 +520,15 @@ const editorOpen = ref(false);
const editing = ref<Route | null>(null);
const saving = ref(false);
const forbidden = ref(false);
const selectedGroup = ref<Group | null>(null);
/** The group the URL opens, once the group list knows it. */
const selectedGroup = computed<Group | null>(() =>
routeGroupId.value ? (groups.value.find((g) => g.id === routeGroupId.value) ?? null) : null,
);
/** The URL names a group the signed-in user cannot see (or that does not exist). */
const groupMissing = computed(
() => !!routeGroupId.value && groupsLoaded.value && !groupsError.value && !selectedGroup.value,
);
const groupEditorOpen = ref(false);
const editingGroup = ref<Group | null>(null);
@@ -556,7 +582,16 @@ watch(
function switchView(next: View): void {
const path = next === "overview" ? "/admin" : `/admin/${next}`;
if (route.path !== path) router.replace(path);
if (route.path !== path) router.push(path);
}
/**
* The active mobile tab emits no change, so a tap on "Groups" while a group's
* routes are open leads back to the list here (the sidebar link does so itself).
*/
function onMobileNavClick(event: MouseEvent): void {
const tab = event.target instanceof Element ? event.target.closest('[role="tab"]') : null;
if (tab?.getAttribute("aria-selected") === "true" && routeGroupId.value) switchView("groups");
}
async function refreshOverview(): Promise<void> {
@@ -566,17 +601,22 @@ async function refreshOverview(): Promise<void> {
}
function enterGroup(group: Group): void {
cancelReorder();
selectedGroup.value = group;
groupRoutes.value = [];
loadGroupRoutes(group.id);
router.push(groupPath(group.id));
}
function exitGroup(): void {
cancelReorder();
selectedGroup.value = null;
loadGroups();
}
// The URL decides which group's routes are shown — on a deep link, a click
// on a group, or the browser's back/forward buttons alike.
watch(
routeGroupId,
(id, previous) => {
cancelReorder();
if (id) loadGroupRoutes(id);
else clearGroupRoutes();
// Back on the list: members or sources may have changed meanwhile.
if (!id && previous && view.value === "groups") loadGroups();
},
{ immediate: true },
);
function startReorder(): void {
if (groupRoutesLoading.value || saving.value) return;
@@ -706,13 +746,10 @@ async function onSaveGroupFromPanel(group: Group): Promise<void> {
try {
const next = groups.value.map((g) => (g.id === group.id ? group : g));
await saveGroups(next);
selectedGroup.value = group;
push(t("toast.groupSaved"));
} catch (err) {
push(t("toast.saveFailed", { msg: err instanceof Error ? err.message : String(err) }), "bad");
if (selectedGroup.value) {
loadGroups();
}
loadGroups();
} finally {
savingGroup.value = false;
}
@@ -1006,6 +1043,28 @@ async function onDeleteGroup(group: Group): Promise<void> {
gap: 0.5rem;
margin-left: auto;
}
/* A group's routes: its name with the route count right after it. The name
gives way (ellipsis) so the count and the actions keep their line. */
.console-group-bar {
position: relative;
}
.console-context-bar > .console-group-heading {
flex: 1 1 0;
min-width: 0;
gap: 0.5rem;
}
.console-group-heading h2 {
min-width: 0;
overflow: hidden;
margin: 0;
font-size: 1rem;
font-weight: 600;
text-overflow: ellipsis;
white-space: nowrap;
}
.console-group-bar .console-context-actions {
flex: none;
}
.console-context-bar .console-reorder-hint {
flex-basis: 100%;
font-size: 0.78rem;
@@ -1058,6 +1117,13 @@ async function onDeleteGroup(group: Group): Promise<void> {
}
}
@media (max-width: 620px) {
.console-reorder-label {
display: none;
}
.console-reorder-btn {
width: 2rem;
padding-inline: 0;
}
/* Title left with theme/language pinned top-right; page actions below, right-aligned. */
.console-topbar {
display: grid;
+47 -7
View File
@@ -5,30 +5,70 @@ export function useGroupRoutesApi() {
const routes = ref<Route[]>([]);
const loading = ref(false);
const error = ref("");
/** Group whose routes are shown; responses for any other group are dropped. */
const groupId = ref<string | null>(null);
/** Group whose routes were last loaded (or saved) successfully. */
const loadedId = ref<string | null>(null);
// Bumped by every load/clear, so only the latest request may land.
let request = 0;
async function load(groupId: string): Promise<void> {
/**
* The shown routes are the group's real routes. Saving replaces a group's
* whole route list, so a write is only safe from here — never from the
* empty list of a load still running or one that failed.
*/
const ready = computed(() => !!groupId.value && loadedId.value === groupId.value && !error.value);
async function load(id: string): Promise<void> {
const mine = ++request;
if (groupId.value !== id) {
routes.value = [];
loadedId.value = null;
}
groupId.value = id;
loading.value = true;
error.value = "";
needLogin.value = false;
try {
const data = await apiFetch<{ routes?: Route[] }>(
`/admin/api/groups/${encodeURIComponent(groupId)}/routes`,
`/admin/api/groups/${encodeURIComponent(id)}/routes`,
);
if (mine !== request) return;
routes.value = data.routes ?? [];
loadedId.value = id;
} catch (err) {
if (!needLogin.value) error.value = err instanceof Error ? err.message : String(err);
if (mine === request && !needLogin.value)
error.value = err instanceof Error ? err.message : String(err);
} finally {
loading.value = false;
if (mine === request) loading.value = false;
}
}
async function save(groupId: string, next: Route[]): Promise<void> {
await apiFetch(`/admin/api/groups/${encodeURIComponent(groupId)}/routes`, {
/** Forget the shown group (its page was left); late responses are ignored. */
function clear(): void {
request++;
groupId.value = null;
loadedId.value = null;
routes.value = [];
loading.value = false;
error.value = "";
}
async function save(id: string, next: Route[]): Promise<void> {
await apiFetch(`/admin/api/groups/${encodeURIComponent(id)}/routes`, {
method: "PUT",
body: JSON.stringify({ routes: next }),
});
// The page may have moved on to another group while the request ran.
if (groupId.value !== id) return;
// What was just written is the newest state: a load of this group that
// started earlier may return the old routes, so it must not land.
request++;
loading.value = false;
error.value = "";
routes.value = next;
loadedId.value = id;
}
return { routes, loading, needLogin, error, load, save };
return { routes, loading, needLogin, error, groupId, ready, load, clear, save };
}
+4
View File
@@ -8,6 +8,8 @@ export function useGroupsApi() {
const roles = ref<Record<string, GroupRole>>({});
const loading = ref(false);
const error = ref("");
/** A load has succeeded: an id missing from `groups` really is unknown. */
const loaded = ref(false);
function roleOf(groupId: string): GroupRole | undefined {
return isSuper.value ? "owner" : roles.value[groupId];
@@ -36,6 +38,7 @@ export function useGroupsApi() {
groups.value = data.groups ?? [];
isSuper.value = data.isSuper ?? false;
roles.value = data.roles ?? {};
loaded.value = true;
} catch (err) {
if (!needLogin.value) error.value = err instanceof Error ? err.message : String(err);
} finally {
@@ -67,6 +70,7 @@ export function useGroupsApi() {
canEditGroup,
canEditRoutes,
loading,
loaded,
needLogin,
error,
load,
+6 -2
View File
@@ -138,8 +138,10 @@ const en: Dict = {
"groups.myRole": "MY ROLE",
"groups.any": "any",
"groups.open": "Open",
"group.back": "Groups",
"groups.delete": "Delete group",
"group.notFound": "This group does not exist, or you have no access to it",
"group.allGroups": "All groups",
"group.routeCount": "{count} routes",
"group.routesIn": "Routes in {name}",
"routes.emptyGroup": "No routes in this group yet.",
"routes.createFirst": "Create your first route",
@@ -575,8 +577,10 @@ const zh: Dict = {
"groups.myRole": "我的角色",
"groups.any": "任意",
"groups.open": "进入",
"group.back": "返回分组",
"groups.delete": "删除分组",
"group.notFound": "分组不存在,或你没有访问权限",
"group.allGroups": "全部分组",
"group.routeCount": "{count} 条路由",
"group.routesIn": "{name} 的路由",
"routes.emptyGroup": "该分组还没有路由。",
"routes.createFirst": "创建第一个路由",
+9
View File
@@ -1,3 +1,12 @@
<script setup lang="ts">
import { parseAdminPath } from "~/utils/admin-path";
definePageMeta({
// Unknown console paths (e.g. /admin/foo, /admin/groups/a/b) 404 before rendering.
validate: (route) => parseAdminPath(route.params.slug) !== null,
});
</script>
<template>
<ConsolePage />
</template>
+27
View File
@@ -0,0 +1,27 @@
/** Top-level pages of the admin console. */
export type AdminView = "overview" | "groups" | "logs" | "audit" | "metrics";
const VIEWS: readonly string[] = ["overview", "groups", "logs", "audit", "metrics"];
/**
* Read the console page from the segments after /admin: `[]` (overview),
* `["groups"]`, `["groups", groupId]` (that group's routes), `["logs"]`,
* `["audit"]`, `["metrics"]`. Anything else is no console page (null → 404).
*/
export function parseAdminPath(
slug: string | string[] | undefined,
): { view: AdminView; groupId: string | null } | null {
// A trailing slash adds an empty segment.
const [view, groupId, ...rest] = (Array.isArray(slug) ? slug : slug ? [slug] : []).filter(
Boolean,
);
if (!view) return { view: "overview", groupId: null };
if (!VIEWS.includes(view) || rest.length) return null;
// Only groups have sub-pages.
if (groupId !== undefined && view !== "groups") return null;
return { view: view as AdminView, groupId: groupId ?? null };
}
export function adminGroupPath(groupId: string): string {
return `/admin/groups/${encodeURIComponent(groupId)}`;
}
+1 -1
View File
@@ -63,7 +63,7 @@ WebHooker ships with a built-in config console at `/admin` for managing routes,
For local debugging only, set `DEBUG_MODE=true` to bypass GitHub OAuth and grant complete console access. Do not set this variable in a deployed environment.
The console is served as an SPA at `/admin`; its tabs are deep-linkable via the URL path (`/admin/groups`, `/admin/logs`, `/admin/audit`). URLs outside `/admin` that do not match an endpoint return a plain `404` instead of the console.
The console is served as an SPA at `/admin`; its tabs are deep-linkable via the URL path (`/admin/groups`, `/admin/logs`, `/admin/audit`), and each group's routes page has its own URL (`/admin/groups/{groupId}`). Pages are browser history entries: use the browser's (or device's) back button to return from a group to the group list. Unknown console paths return the console's 404 page. URLs outside `/admin` that do not match an endpoint return a plain `404` instead of the console.
Destructive actions — deleting routes, groups, filter conditions, fragments, targets or forge hosts, removing members, revoking invites, disabling a group's webhook — ask for confirmation in an in-app dialog (empty, never-filled rows are removed directly). The route and group editors ignore clicks on the backdrop so unsaved input is never lost; close them with Cancel, ✕ or <kbd>Esc</kbd>.
+1 -1
View File
@@ -62,7 +62,7 @@ WebHooker 在 `/admin` 提供内置配置控制台,可在浏览器中管理路
仅供本地调试:设置 `DEBUG_MODE=true` 可跳过 GitHub OAuth,并授予完整控制台权限。部署环境切勿设置此变量。
控制台以 SPA 形式在 `/admin` 提供;其标签页可通过 URL 路径直达(`/admin/groups`、`/admin/logs`、`/admin/audit`)。`/admin` 之外未匹配到端点的 URL 直接返回 `404`,而不会展示控制台。
控制台以 SPA 形式在 `/admin` 提供;其标签页可通过 URL 路径直达(`/admin/groups`、`/admin/logs`、`/admin/audit`),每个分组的路由页也有独立 URL(`/admin/groups/{groupId}`)。各页面都会记入浏览器历史:从分组返回分组列表请使用浏览器(或设备)自带的返回。未知的控制台路径显示控制台的 404 页面。`/admin` 之外未匹配到端点的 URL 直接返回 `404`,而不会展示控制台。
删除类操作——删除路由、分组、过滤条件、片段、目标或来源主机,移除成员,撤销邀请,停用分组 webhook——都会先弹出应用内确认框(从未填写过的空行直接删除)。路由与分组编辑弹窗点击遮罩不会关闭,避免丢失未保存的内容;请用「取消」、✕ 或 <kbd>Esc</kbd> 关闭。
+36
View File
@@ -0,0 +1,36 @@
import { describe, it, expect } from "bun:test";
import { adminGroupPath, parseAdminPath } from "../app/utils/admin-path";
describe("parseAdminPath", () => {
it("maps the console pages", () => {
expect(parseAdminPath(undefined)).toEqual({ view: "overview", groupId: null });
expect(parseAdminPath([])).toEqual({ view: "overview", groupId: null });
expect(parseAdminPath("logs")).toEqual({ view: "logs", groupId: null });
expect(parseAdminPath(["groups"])).toEqual({ view: "groups", groupId: null });
expect(parseAdminPath(["metrics"])).toEqual({ view: "metrics", groupId: null });
});
it("opens a group's routes under /admin/groups/{groupId}", () => {
expect(parseAdminPath(["groups", "inst-12345678"])).toEqual({
view: "groups",
groupId: "inst-12345678",
});
// A trailing slash adds an empty segment.
expect(parseAdminPath(["groups", ""])).toEqual({ view: "groups", groupId: null });
expect(parseAdminPath(["groups", "acme", ""])).toEqual({ view: "groups", groupId: "acme" });
});
it("rejects unknown pages and sub-pages", () => {
expect(parseAdminPath(["foo"])).toBeNull();
expect(parseAdminPath(["logs", "x"])).toBeNull();
expect(parseAdminPath(["groups", "acme", "routes"])).toBeNull();
expect(parseAdminPath(["constructor"])).toBeNull();
});
});
describe("adminGroupPath", () => {
it("encodes the group id", () => {
expect(adminGroupPath("acme")).toBe("/admin/groups/acme");
expect(adminGroupPath("a/b c")).toBe("/admin/groups/a%2Fb%20c");
});
});