@app-vitals/agent-admin 1.49.0 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,9 @@
3
3
  * Admin UI — Agents Page E2E Tests (ADM-3.2)
4
4
  *
5
5
  * Tests the agent detail page at GET /admin/agents/:id, covering:
6
+ * Sections (SGL-1.2): general = /:id, automation, configuration, access,
7
+ * extensions = /:id/<section>. Each check loads the section owning the element.
8
+ *
6
9
  * 1. Unauthenticated GET /admin/agents → redirects to /admin/login
7
10
  * 2. Authenticated → page title contains agent name
8
11
  * 3. Authenticated → h1 contains agent name
@@ -26,7 +29,7 @@
26
29
  import { type ChildProcess, spawn } from "node:child_process";
27
30
  import { dirname, resolve } from "node:path";
28
31
  import { fileURLToPath } from "node:url";
29
- import { type BrowserContext, type Page, expect, test } from "@playwright/test";
32
+ import { type BrowserContext, expect, type Page, test } from "@playwright/test";
30
33
  import { sign } from "hono/jwt";
31
34
 
32
35
  // ─── Constants ────────────────────────────────────────────────────────────────
@@ -109,6 +112,7 @@ async function mintSession(
109
112
  async function loadAgentDetailPage(
110
113
  page: Page,
111
114
  context: BrowserContext,
115
+ section: "" | "automation" | "configuration" | "access" | "extensions" = "",
112
116
  ): Promise<void> {
113
117
  const token = await mintSession();
114
118
  await context.addCookies([
@@ -121,7 +125,9 @@ async function loadAgentDetailPage(
121
125
  sameSite: "Lax",
122
126
  },
123
127
  ]);
124
- await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}`);
128
+ await page.goto(
129
+ `${BASE_URL}/admin/agents/${AGENT_ID}${section ? `/${section}` : ""}`,
130
+ );
125
131
  }
126
132
 
127
133
  // ─── 1. Unauthenticated redirect ──────────────────────────────────────────────
@@ -158,7 +164,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
158
164
  page,
159
165
  context,
160
166
  }) => {
161
- await loadAgentDetailPage(page, context);
167
+ await loadAgentDetailPage(page, context, "configuration");
162
168
  await expect(page.locator("body")).toContainText("SLACK_BOT_TOKEN");
163
169
  });
164
170
 
@@ -166,7 +172,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
166
172
  page,
167
173
  context,
168
174
  }) => {
169
- await loadAgentDetailPage(page, context);
175
+ await loadAgentDetailPage(page, context, "configuration");
170
176
  const body = await page.locator("body").textContent();
171
177
  expect(body).toContain("••••••••");
172
178
  expect(body).not.toContain("xoxb-secret-value");
@@ -176,12 +182,12 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
176
182
  page,
177
183
  context,
178
184
  }) => {
179
- await loadAgentDetailPage(page, context);
185
+ await loadAgentDetailPage(page, context, "automation");
180
186
  await expect(page.locator("body")).toContainText("0 9 * * 1");
181
187
  });
182
188
 
183
189
  test("cron job prompt is visible", async ({ page, context }) => {
184
- await loadAgentDetailPage(page, context);
190
+ await loadAgentDetailPage(page, context, "automation");
185
191
  await expect(page.locator("body")).toContainText("Send the weekly standup");
186
192
  });
187
193
 
@@ -189,7 +195,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
189
195
  page,
190
196
  context,
191
197
  }) => {
192
- await loadAgentDetailPage(page, context);
198
+ await loadAgentDetailPage(page, context, "access");
193
199
  await expect(page.locator("body")).toContainText("Production token");
194
200
  });
195
201
 
@@ -197,7 +203,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
197
203
  page,
198
204
  context,
199
205
  }) => {
200
- await loadAgentDetailPage(page, context);
206
+ await loadAgentDetailPage(page, context, "configuration");
201
207
  const envForm = page.locator('form[action*="/envs"]').first();
202
208
  await expect(envForm).toBeAttached();
203
209
  });
@@ -206,7 +212,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
206
212
  page,
207
213
  context,
208
214
  }) => {
209
- await loadAgentDetailPage(page, context);
215
+ await loadAgentDetailPage(page, context, "automation");
210
216
  const cronForm = page.locator('form[action*="/crons"]').first();
211
217
  await expect(cronForm).toBeAttached();
212
218
  });
@@ -215,7 +221,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
215
221
  page,
216
222
  context,
217
223
  }) => {
218
- await loadAgentDetailPage(page, context);
224
+ await loadAgentDetailPage(page, context, "access");
219
225
  const tokenForm = page.locator('form[action*="/tokens"]').first();
220
226
  await expect(tokenForm).toBeAttached();
221
227
  });
@@ -251,17 +257,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
251
257
  context,
252
258
  }) => {
253
259
  await page.setViewportSize({ width: 375, height: 812 });
254
- await loadAgentDetailPage(page, context);
255
-
256
- // Env Vars now lives inside a collapsed accordion group (AGA-1.1) —
257
- // expand it before asserting on the visibility of anything inside.
258
- await page
259
- .locator("#env-vars")
260
- .locator("xpath=ancestor::details[contains(@class, 'group')]")
261
- .first()
262
- .evaluate((details) => {
263
- (details as HTMLDetailsElement).open = true;
264
- });
260
+ await loadAgentDetailPage(page, context, "configuration");
265
261
 
266
262
  const deleteBtn = page
267
263
  .locator("#env-vars .data-table .btn", { hasText: "Delete" })
@@ -276,6 +272,50 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
276
272
  });
277
273
  });
278
274
 
275
+ // ─── Section sidebar navigation (SGL-1.2) ────────────────────────────────────
276
+
277
+ test.describe("agent section sidebar", () => {
278
+ test("lists all five sections and marks General current on /:id", async ({
279
+ page,
280
+ context,
281
+ }) => {
282
+ await loadAgentDetailPage(page, context);
283
+ const nav = page.locator("nav.settings-sidebar");
284
+ for (const label of [
285
+ "General",
286
+ "Automation",
287
+ "Configuration",
288
+ "Access",
289
+ "Extensions",
290
+ ]) {
291
+ await expect(nav.getByRole("link", { name: label })).toBeVisible();
292
+ }
293
+ await expect(nav.locator('a[aria-current="page"]')).toHaveText("General");
294
+ });
295
+
296
+ test("clicking a sidebar link navigates to that section", async ({
297
+ page,
298
+ context,
299
+ }) => {
300
+ await loadAgentDetailPage(page, context);
301
+ const nav = page.locator("nav.settings-sidebar");
302
+
303
+ await nav.getByRole("link", { name: "Automation" }).click();
304
+ await expect(page).toHaveURL(
305
+ `${BASE_URL}/admin/agents/${AGENT_ID}/automation`,
306
+ );
307
+ await expect(page.locator("body")).toContainText("0 9 * * 1");
308
+
309
+ await nav.getByRole("link", { name: "Extensions" }).click();
310
+ await expect(page).toHaveURL(
311
+ `${BASE_URL}/admin/agents/${AGENT_ID}/extensions`,
312
+ );
313
+ await expect(nav.locator('a[aria-current="page"]')).toHaveText(
314
+ "Extensions",
315
+ );
316
+ });
317
+ });
318
+
279
319
  // ─── New-specialty picker (ATS-4.1) ──────────────────────────────────────────
280
320
 
281
321
  async function loadNewAgentPage(
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * admin/e2e/marketplaces-section.e2e.ts
3
- * Admin UI — Marketplaces section on the agent page (PMK-1.5)
3
+ * Admin UI — Marketplaces section on the agent Extensions section (/admin/agents/:id/extensions) (PMK-1.5)
4
4
  *
5
5
  * Covers: remote rows listed, add and remove of a remote row, and baked rows
6
6
  * (reported by the runtime) rendered read-only with no controls.
@@ -12,7 +12,7 @@
12
12
  import { type ChildProcess, spawn } from "node:child_process";
13
13
  import { dirname, resolve } from "node:path";
14
14
  import { fileURLToPath } from "node:url";
15
- import { type BrowserContext, type Page, expect, test } from "@playwright/test";
15
+ import { type BrowserContext, expect, type Page, test } from "@playwright/test";
16
16
  import { sign } from "hono/jwt";
17
17
 
18
18
  const PORT = 3496;
@@ -87,24 +87,7 @@ async function loadAgentPage(page: Page, context: BrowserContext) {
87
87
  sameSite: "Lax",
88
88
  },
89
89
  ]);
90
- await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}`);
91
- await openGroup(page);
92
- }
93
-
94
- // The section lives in the "Plugins & Tools" accordion group, collapsed on
95
- // every page load (including the redirect after each add/remove).
96
- async function openGroup(page: Page) {
97
- // Set `open` rather than clicking the summary, so a still-old (already
98
- // open) page can't be toggled shut; the table locator retries across the
99
- // navigation.
100
- await expect(async () => {
101
- await page
102
- .locator("details", { has: page.locator("#marketplaces-table") })
103
- .evaluate((el) => {
104
- (el as HTMLDetailsElement).open = true;
105
- });
106
- await expect(table(page)).toBeVisible({ timeout: 1000 });
107
- }).toPass();
90
+ await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
108
91
  }
109
92
 
110
93
  test("lists the remote row with source and ref, and the baked row", async ({
@@ -135,16 +118,14 @@ test("adds a remote row and then removes it", async ({ page, context }) => {
135
118
  await form.locator('input[name="source"]').fill("owner/added");
136
119
  await form.locator('input[name="ref"]').fill("main");
137
120
  await form.getByRole("button", { name: "Add marketplace" }).click();
138
- await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
139
- await openGroup(page);
121
+ await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
140
122
 
141
123
  const added = table(page).locator("tbody tr", { hasText: "added-remote" });
142
124
  await expect(added).toContainText("owner/added");
143
125
  await expect(added).toContainText("main");
144
126
 
145
127
  await added.getByRole("button", { name: "Remove" }).click();
146
- await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
147
- await openGroup(page);
128
+ await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
148
129
  await expect(
149
130
  table(page).locator("tbody tr", { hasText: "added-remote" }),
150
131
  ).toHaveCount(0);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * admin/e2e/plugins-section.e2e.ts
3
- * Admin UI — Plugins card add/remove on the agent page (PUI-1.2)
3
+ * Admin UI — Plugins card add/remove on the agent Extensions section (/admin/agents/:id/extensions) (PUI-1.2)
4
4
  *
5
5
  * Covers: seeded row listed, add by spec (explicit and bare), malformed spec
6
6
  * error, and remove.
@@ -12,7 +12,7 @@
12
12
  import { type ChildProcess, spawn } from "node:child_process";
13
13
  import { dirname, resolve } from "node:path";
14
14
  import { fileURLToPath } from "node:url";
15
- import { type BrowserContext, type Page, expect, test } from "@playwright/test";
15
+ import { type BrowserContext, expect, type Page, test } from "@playwright/test";
16
16
  import { sign } from "hono/jwt";
17
17
 
18
18
  const PORT = 3497;
@@ -87,24 +87,7 @@ async function loadAgentPage(page: Page, context: BrowserContext) {
87
87
  sameSite: "Lax",
88
88
  },
89
89
  ]);
90
- await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}`);
91
- await openGroup(page);
92
- }
93
-
94
- // The section lives in the "Plugins & Tools" accordion group, collapsed on
95
- // every page load (including the redirect after each add/remove).
96
- async function openGroup(page: Page) {
97
- // Set `open` rather than clicking the summary, so a still-old (already
98
- // open) page can't be toggled shut; the table locator retries across the
99
- // navigation.
100
- await expect(async () => {
101
- await page
102
- .locator("details", { has: page.locator("#plugins-table") })
103
- .evaluate((el) => {
104
- (el as HTMLDetailsElement).open = true;
105
- });
106
- await expect(table(page)).toBeVisible({ timeout: 1000 });
107
- }).toPass();
90
+ await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
108
91
  }
109
92
 
110
93
  test("lists the seeded plugin", async ({ page, context }) => {
@@ -119,8 +102,7 @@ test("adds a plugin by spec and then removes it", async ({ page, context }) => {
119
102
  const form = page.locator("#add-plugin-form");
120
103
  await form.locator('input[name="spec"]').fill("added@seeded-remote");
121
104
  await form.getByRole("button", { name: "Add plugin" }).click();
122
- await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
123
- await openGroup(page);
105
+ await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
124
106
 
125
107
  const added = table(page).locator("tbody tr", {
126
108
  hasText: "added@seeded-remote",
@@ -128,8 +110,7 @@ test("adds a plugin by spec and then removes it", async ({ page, context }) => {
128
110
  await expect(added).toHaveCount(1);
129
111
 
130
112
  await added.getByRole("button", { name: "Remove" }).click();
131
- await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
132
- await openGroup(page);
113
+ await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
133
114
  await expect(
134
115
  table(page).locator("tbody tr", { hasText: "added@seeded-remote" }),
135
116
  ).toHaveCount(0);
@@ -146,8 +127,7 @@ test("a bare name defaults to the shipwright marketplace", async ({
146
127
  const form = page.locator("#add-plugin-form");
147
128
  await form.locator('input[name="spec"]').fill("barename");
148
129
  await form.getByRole("button", { name: "Add plugin" }).click();
149
- await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
150
- await openGroup(page);
130
+ await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
151
131
  await expect(
152
132
  table(page).locator("tbody tr", { hasText: "barename@shipwright" }),
153
133
  ).toHaveCount(1);
@@ -163,6 +143,5 @@ test("a malformed spec redirects with an error and adds nothing", async ({
163
143
  await form.locator('input[name="spec"]').fill("a@b@c");
164
144
  await form.getByRole("button", { name: "Add plugin" }).click();
165
145
  await page.waitForURL(/\?error=/);
166
- await openGroup(page);
167
146
  await expect(table(page).locator("tbody tr")).toHaveCount(before);
168
147
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.49.0",
3
+ "version": "1.51.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@anthropic-ai/sdk": "0.135.0",
45
- "@app-vitals/agent-lib": "1.49.0",
45
+ "@app-vitals/agent-lib": "1.51.0",
46
46
  "@hono/zod-openapi": "^1.0.0",
47
47
  "@prisma/adapter-pg": "^7.10.0",
48
48
  "@prisma/client": "^7.10.0",
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * admin/src/admin-ui-account-nav.ts
3
- * Per-request "show the Account nav entry" flag (SSP-3.2). renderAdminToolbar()
3
+ * Per-request "show the Settings nav entry" flag. renderAdminToolbar()
4
4
  * is called from dozens of page renderers; rather than thread a parameter
5
5
  * through all of them, an admin-ui middleware wraps each /admin/* request in
6
6
  * runWithAccountNav() and the toolbar reads the flag back. Outside any
@@ -10,26 +10,15 @@
10
10
  import { AsyncLocalStorage } from "node:async_hooks";
11
11
 
12
12
  interface NavFlags {
13
- showAccount: boolean;
14
- /** GHE-1.4: the admin-only "Settings" entry. */
13
+ /** The "Settings" entry (admins and account members). */
15
14
  showSettings: boolean;
16
15
  }
17
16
 
18
17
  const storage = new AsyncLocalStorage<NavFlags>();
19
18
 
20
- export function runWithAccountNav<T>(showAccount: boolean, fn: () => T): T {
21
- const showSettings = storage.getStore()?.showSettings === true;
22
- return storage.run({ showAccount, showSettings }, fn);
23
- }
24
-
25
- export function shouldShowAccountNav(): boolean {
26
- return storage.getStore()?.showAccount === true;
27
- }
28
-
29
19
  /** Wrap a request so the toolbar shows (or hides) the admin Settings entry. */
30
20
  export function runWithSettingsNav<T>(showSettings: boolean, fn: () => T): T {
31
- const showAccount = storage.getStore()?.showAccount === true;
32
- return storage.run({ showAccount, showSettings }, fn);
21
+ return storage.run({ showSettings }, fn);
33
22
  }
34
23
 
35
24
  export function shouldShowSettingsNav(): boolean {
@@ -1,31 +1,22 @@
1
1
  /**
2
2
  * admin/src/admin-ui-account-nav.unit.test.ts
3
- * Flag plumbing for the toolbar Account / Settings entries.
3
+ * Flag plumbing for the toolbar Settings entry.
4
4
  */
5
5
 
6
6
  import { describe, expect, test } from "bun:test";
7
7
  import {
8
- runWithAccountNav,
9
8
  runWithSettingsNav,
10
- shouldShowAccountNav,
11
9
  shouldShowSettingsNav,
12
10
  } from "./admin-ui-account-nav.ts";
13
11
 
14
- describe("account-nav flags", () => {
15
- test("both hidden outside any context", () => {
16
- expect(shouldShowAccountNav()).toBe(false);
12
+ describe("settings-nav flag", () => {
13
+ test("hidden outside any context", () => {
17
14
  expect(shouldShowSettingsNav()).toBe(false);
18
15
  });
19
- test("settings flag survives a nested account wrapper, and vice versa", () => {
16
+ test("reflects the wrapper value, including nested", () => {
20
17
  runWithSettingsNav(true, () => {
21
- runWithAccountNav(false, () => {
22
- expect(shouldShowSettingsNav()).toBe(true);
23
- expect(shouldShowAccountNav()).toBe(false);
24
- });
25
- });
26
- runWithAccountNav(true, () => {
18
+ expect(shouldShowSettingsNav()).toBe(true);
27
19
  runWithSettingsNav(false, () => {
28
- expect(shouldShowAccountNav()).toBe(true);
29
20
  expect(shouldShowSettingsNav()).toBe(false);
30
21
  });
31
22
  });
@@ -8,7 +8,12 @@ import type { AccountInvite } from "./account-invites.ts";
8
8
  import type { AccountMember } from "./account-members.ts";
9
9
  import type { Account } from "./accounts.ts";
10
10
  import { renderAdminPage } from "./admin-ui-layout.ts";
11
- import { escapeHtml, renderAdminToolbar } from "./admin-ui-styles.ts";
11
+ import {
12
+ buildSettingsNav,
13
+ renderSettingsLayout,
14
+ type SettingsNav,
15
+ } from "./admin-ui-settings-layout.ts";
16
+ import { escapeHtml } from "./admin-ui-styles.ts";
12
17
 
13
18
  export const ACCOUNT_PATH = "/admin/account";
14
19
 
@@ -21,6 +26,10 @@ interface AccountPageOpts {
21
26
  /** True when the viewer is an owner; members get a read-only page. */
22
27
  isOwner: boolean;
23
28
  error?: string;
29
+ /** Settings sidebar nav; defaults to the base Account/Accounts nav. */
30
+ nav?: SettingsNav;
31
+ /** Platform admin viewing (shows adminOnly nav items). */
32
+ isAdmin?: boolean;
24
33
  }
25
34
 
26
35
  function emailForm(
@@ -88,13 +97,15 @@ export function renderAccountPage(opts: AccountPageOpts): string {
88
97
  : "";
89
98
 
90
99
  return renderAdminPage({
91
- title: "Account — Shipwright Admin",
92
- body: `${renderAdminToolbar(opts.userEmail, ACCOUNT_PATH)}
93
- <div class="vos-page">
94
- <div class="page-header">
95
- <h1 class="page-title">${escapeHtml(account.name)}</h1>
96
- </div>
97
- ${errorHtml}
100
+ title: "Account — Settings — Shipwright Admin",
101
+ body: renderSettingsLayout({
102
+ userName: opts.userEmail,
103
+ title: account.name,
104
+ nav: opts.nav ?? buildSettingsNav({ accounts: true }),
105
+ active: ACCOUNT_PATH,
106
+ toolbarPath: "/admin/settings",
107
+ isAdmin: opts.isAdmin ?? false,
108
+ body: `${errorHtml}
98
109
  <div class="card">
99
110
  <div class="card-title">Account</div>
100
111
  <p>Agents: <strong>${opts.agentCount} / ${account.maxAgents}</strong></p>
@@ -118,8 +129,8 @@ export function renderAccountPage(opts: AccountPageOpts): string {
118
129
  </table>
119
130
  </div>
120
131
  ${inviteForm}
121
- </div>
122
- </div>`,
132
+ </div>`,
133
+ }),
123
134
  });
124
135
  }
125
136
 
@@ -9,7 +9,6 @@ import {
9
9
  renderZeroQuotaNotice,
10
10
  } from "./admin-ui-account-pages.ts";
11
11
  import { renderAdminToolbar } from "./admin-ui-styles.ts";
12
- import { runWithAccountNav } from "./admin-ui-account-nav.ts";
13
12
 
14
13
  const d = new Date("2026-01-01T00:00:00Z");
15
14
  const account = {
@@ -92,21 +91,22 @@ describe("renderZeroQuotaNotice", () => {
92
91
  });
93
92
 
94
93
  describe("renderAdminToolbar account nav", () => {
95
- test("no Account entry outside the account-nav context", () => {
94
+ test("no top-level Account entry (Settings covers it, SGL-2.3)", () => {
96
95
  expect(renderAdminToolbar("u", "/admin/agents")).not.toContain(
97
- "/admin/account",
96
+ 'href="/admin/account"',
98
97
  );
99
98
  });
100
- test("Account entry inside the context", () => {
101
- const html = runWithAccountNav(true, () =>
102
- renderAdminToolbar("u", "/admin/agents"),
99
+ });
100
+
101
+ describe("renderAccountPage in the settings shell", () => {
102
+ test("renders inside the layout with Account active and Settings in the toolbar", () => {
103
+ const html = render(true);
104
+ expect(html).toContain("settings-sidebar");
105
+ expect(html).toContain(
106
+ '<a class="settings-nav-link" href="/admin/account" aria-current="page">Account</a>',
103
107
  );
104
- expect(html).toContain('href="/admin/account"');
105
108
  });
106
- test("no entry when context says false", () => {
107
- const html = runWithAccountNav(false, () =>
108
- renderAdminToolbar("u", "/admin/agents"),
109
- );
110
- expect(html).not.toContain("/admin/account");
109
+ test("Accounts nav item only for admins", () => {
110
+ expect(render(true)).not.toContain('href="/admin/accounts"');
111
111
  });
112
112
  });
@@ -178,6 +178,10 @@ describe("/admin/account", () => {
178
178
  const body = await res.text();
179
179
  expect(body).toContain("Acme");
180
180
  expect(body).toContain("1 / 2");
181
+ // SGL-2.3: rendered inside the settings shell; no top-level Account link.
182
+ expect(body).toContain("settings-sidebar");
183
+ expect(body).toContain('href="/admin/account" aria-current="page"');
184
+ expect(body).not.toContain('class="vos-nav-link" href="/admin/account"');
181
185
  });
182
186
 
183
187
  it("owner can invite, see it pending, and revoke it", async () => {
@@ -19,6 +19,7 @@ import { normalizeEmail } from "./account-email.ts";
19
19
  import type { Account, AccountService } from "./accounts.ts";
20
20
  import { ACCOUNT_PATH, renderAccountPage } from "./admin-ui-account-pages.ts";
21
21
  import type { AdminUIEnv } from "./admin-ui.ts";
22
+ import type { SettingsNav } from "./admin-ui-settings-layout.ts";
22
23
 
23
24
  export interface AccountRouteDeps {
24
25
  /** SHIPWRIGHT_SELF_SERVE_ENABLED === "enabled". */
@@ -30,6 +31,8 @@ export interface AccountRouteDeps {
30
31
  "listByAccount" | "getByEmail" | "remove" | "promote" | "demote"
31
32
  >;
32
33
  invites: Pick<AccountInviteService, "create" | "listPending" | "revoke">;
34
+ /** Settings sidebar nav (SGL-2.3). */
35
+ settingsNav?: SettingsNav;
33
36
  html: (content: string, opts?: { status?: number }) => Response;
34
37
  }
35
38
 
@@ -71,6 +74,8 @@ export function registerAccountRoutes(
71
74
  invites,
72
75
  isOwner,
73
76
  error,
77
+ isAdmin: c.var.isAdmin === true,
78
+ ...(deps.settingsNav ? { nav: deps.settingsNav } : {}),
74
79
  }),
75
80
  { status },
76
81
  );
@@ -8,7 +8,12 @@ import type { AccountInvite } from "./account-invites.ts";
8
8
  import type { AccountMember } from "./account-members.ts";
9
9
  import type { AccountWithCounts } from "./accounts.ts";
10
10
  import { renderAdminPage } from "./admin-ui-layout.ts";
11
- import { escapeHtml, renderAdminToolbar } from "./admin-ui-styles.ts";
11
+ import {
12
+ buildSettingsNav,
13
+ renderSettingsLayout,
14
+ type SettingsNav,
15
+ } from "./admin-ui-settings-layout.ts";
16
+ import { escapeHtml } from "./admin-ui-styles.ts";
12
17
 
13
18
  export const ADMIN_ACCOUNTS_PATH = "/admin/accounts";
14
19
 
@@ -36,6 +41,8 @@ interface AccountsListPageOpts {
36
41
  accounts: AccountWithCounts[];
37
42
  /** accountId -> owner emails. */
38
43
  owners: Map<string, string[]>;
44
+ /** Settings sidebar nav; defaults to the base Account/Accounts nav. */
45
+ nav?: SettingsNav;
39
46
  }
40
47
 
41
48
  export function renderAccountsListPage(opts: AccountsListPageOpts): string {
@@ -60,16 +67,20 @@ export function renderAccountsListPage(opts: AccountsListPageOpts): string {
60
67
 
61
68
  return renderAdminPage({
62
69
  title: "Accounts — Shipwright Admin",
63
- body: `${renderAdminToolbar(opts.userEmail, ADMIN_ACCOUNTS_PATH)}
64
- <div class="vos-page">
65
- <div class="page-header"><h1 class="page-title">Accounts</h1></div>
66
- <div class="card">
70
+ body: renderSettingsLayout({
71
+ userName: opts.userEmail,
72
+ title: "Accounts",
73
+ nav: opts.nav ?? buildSettingsNav({ accounts: true }),
74
+ active: ADMIN_ACCOUNTS_PATH,
75
+ toolbarPath: "/admin/settings",
76
+ isAdmin: true,
77
+ body: `<div class="card">
67
78
  <table class="data-table">
68
79
  <thead><tr><th>Name</th><th>Owner</th><th>Members</th><th>Agents</th><th>Status</th><th>Trial expires</th><th>Created</th><th></th></tr></thead>
69
80
  <tbody>${rows}</tbody>
70
81
  </table>
71
- </div>
72
- </div>`,
82
+ </div>`,
83
+ }),
73
84
  });
74
85
  }
75
86
 
@@ -80,6 +91,8 @@ interface AccountDetailPageOpts {
80
91
  members: AccountMember[];
81
92
  invites: AccountInvite[];
82
93
  error?: string;
94
+ /** Settings sidebar nav; defaults to the base Account/Accounts nav. */
95
+ nav?: SettingsNav;
83
96
  }
84
97
 
85
98
  function postForm(
@@ -110,8 +123,12 @@ export function renderAccountDetailPage(opts: AccountDetailPageOpts): string {
110
123
 
111
124
  const statusAction =
112
125
  account.status === "active"
113
- ? postForm(id, "suspend", {}, "Suspend", true)
114
- : postForm(id, "reactivate", {}, "Reactivate");
126
+ ? `<div class="settings-danger-zone">
127
+ <div class="settings-section-title">Danger zone</div>
128
+ <p class="help-text">Suspending locks down this account's crons until it is reactivated.</p>
129
+ ${postForm(id, "suspend", {}, "Suspend", true)}
130
+ </div>`
131
+ : `<div class="card">${postForm(id, "reactivate", {}, "Reactivate")}</div>`;
115
132
 
116
133
  const memberRows = opts.members
117
134
  .map(
@@ -150,12 +167,14 @@ export function renderAccountDetailPage(opts: AccountDetailPageOpts): string {
150
167
 
151
168
  return renderAdminPage({
152
169
  title: `${account.name} — Accounts — Shipwright Admin`,
153
- body: `${renderAdminToolbar(opts.userEmail, ADMIN_ACCOUNTS_PATH)}
154
- <div class="vos-page">
155
- <div class="page-header">
156
- <h1 class="page-title">${escapeHtml(account.name)} ${statusBadge(account.status)}</h1>
157
- ${statusAction}
158
- </div>
170
+ body: renderSettingsLayout({
171
+ userName: opts.userEmail,
172
+ title: account.name,
173
+ nav: opts.nav ?? buildSettingsNav({ accounts: true }),
174
+ active: ADMIN_ACCOUNTS_PATH,
175
+ toolbarPath: "/admin/settings",
176
+ isAdmin: true,
177
+ body: `<p>${statusBadge(account.status)}</p>
159
178
  <p><a href="${ADMIN_ACCOUNTS_PATH}">&larr; All accounts</a></p>
160
179
  ${errorHtml}
161
180
  <div class="card">
@@ -197,6 +216,7 @@ export function renderAccountDetailPage(opts: AccountDetailPageOpts): string {
197
216
  <tbody>${inviteRows}</tbody>
198
217
  </table>
199
218
  </div>
200
- </div>`,
219
+ ${statusAction}`,
220
+ }),
201
221
  });
202
222
  }