refactor(ui): unify account administration under Access

This commit is contained in:
sam committed 2026-10-16 02:57:13 +11:00
1 parent d3e2a67222
commit 7e3aafd534
11 files changed
+144 -136

No files matched your search

@@ -15,22 +15,14 @@ import { cn } from "@/lib/utils";
import NewOrgDialog from "./NewOrgDialog.vue";
import { useOrgStore } from "@/stores/org";
/**
* The Org area's shared frame: the org it is about, and the tab strip that
* moves between its sections. Each section is a route, so the strip is links
* and the address bar names the open section.
*
* The org name and id are a context bar rather than the page's heading: each
* section states its own, and /org/access is a moved page that still carries
* its own. An instance admin gets a switcher over every org in its place.
*/
const TABS = [
{ path: "/org", label: "Members" },
{ path: "/org/agents", label: "Agents" },
{ path: "/org/workspaces", label: "Workspaces" },
{ path: "/org/access", label: "Access", home: true },
{ path: "/org/tokens", label: "Tokens", home: true },
{ path: "/org/models", label: "Models", home: true, member: true },
{ path: "/access", label: "Accounts" },
{ path: "/access/policies", label: "Policies", home: true },
{ path: "/access/tokens", label: "Tokens", home: true },
{ path: "/access/authentication", label: "Authentication", home: true, admin: true },
{ path: "/access/agents", label: "Agents" },
{ path: "/access/workspaces", label: "Workspaces" },
{ path: "/access/models", label: "Models", home: true, member: true },
];
const route = useRoute();
@@ -38,17 +30,17 @@ const router = useRouter();
const orgStore = useOrgStore();
const { homeOrg, instanceAdmin, org, orgs } = storeToRefs(orgStore);
// Access and Tokens act on the caller's own org server-side, so they are
// Policies and tokens act on the caller's own org server-side, so they are
// hidden while an instance admin views another org rather than editing the
// wrong one.
const away = computed(() => !!org.value && org.value.id !== homeOrg.value);
// Models is an org's own; the system org configures models in Settings.
const tabs = computed(() =>
TABS.filter((tab) => !(away.value && tab.home) && !(tab.member && homeOrg.value === "org-sys")),
TABS.filter((tab) => !(tab.admin && !instanceAdmin.value) && !(away.value && tab.home) && !(tab.member && homeOrg.value === "org-sys")),
);
watch(away, (isAway) => {
watch([away, () => route.path], ([isAway]) => {
if (isAway && TABS.some((tab) => tab.home && route.path.startsWith(tab.path))) {
void router.replace("/org");
void router.replace("/access");
}
});
const error = ref("");
@@ -63,12 +55,13 @@ onMounted(async () => {
const currentPath = computed(() => route.path);
const current = (path: string) =>
path === "/org" ? currentPath.value === "/org" : currentPath.value.startsWith(path);
path === "/access" ? currentPath.value === "/access" : currentPath.value.startsWith(path);
</script>
<template>
<div>
<PageHeader :title="org?.name ?? 'Org'">
<PageHeader title="Access">
<span class="text-sm text-muted-foreground">{{ org?.name }}</span>
<template v-if="instanceAdmin">
<Select :model-value="org?.id" @update:model-value="(id) => orgStore.viewOrg(String(id))">
<SelectTrigger class="w-60" aria-label="Org">
@@ -82,7 +75,7 @@ const current = (path: string) =>
</template>
</PageHeader>
<nav aria-label="Org" class="mb-4 flex flex-wrap items-center gap-1 border-b border-border">
<nav aria-label="Access sections" class="mb-4 flex flex-wrap items-center gap-1 border-b border-border">
<RouterLink
v-for="tab in tabs"
:key="tab.path"