@app-vitals/agent-admin 1.113.1 → 1.114.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.114.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@anthropic-ai/sdk": "0.137.0",
|
|
47
|
-
"@app-vitals/agent-lib": "1.
|
|
47
|
+
"@app-vitals/agent-lib": "1.114.0",
|
|
48
48
|
"@hono/zod-openapi": "^1.0.0",
|
|
49
49
|
"@prisma/adapter-pg": "^7.10.0",
|
|
50
50
|
"@prisma/client": "^7.10.0",
|
|
@@ -51,25 +51,37 @@ function emailForm(
|
|
|
51
51
|
</form>`;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* One "Edit" popover per member row (owner viewers only): a no-JS
|
|
56
|
+
* `<details>/<summary>` disclosure mirroring the "Sync Manifest" pattern. It
|
|
57
|
+
* holds the role change (owners demote, members promote) and the remove form.
|
|
58
|
+
*/
|
|
59
|
+
function renderMemberEditMenu(m: AccountMember): string {
|
|
60
|
+
const roleForm =
|
|
61
|
+
m.role === "owner"
|
|
62
|
+
? emailForm("members/demote", m.email, "Make member")
|
|
63
|
+
: emailForm("members/promote", m.email, "Make owner");
|
|
64
|
+
const removeForm = emailForm(
|
|
65
|
+
"members/remove",
|
|
66
|
+
m.email,
|
|
67
|
+
"Remove",
|
|
68
|
+
true,
|
|
69
|
+
REMOVE_MEMBER_CONFIRM,
|
|
70
|
+
);
|
|
71
|
+
return `<details style="position:relative;display:inline-block">
|
|
72
|
+
<summary class="btn btn-secondary" style="cursor:pointer;font-size:12px;list-style:none">Edit</summary>
|
|
73
|
+
<div style="position:absolute;right:0;margin-top:6px;background:var(--vos-surface);border:1px solid var(--vos-border);border-radius:6px;padding:12px;box-shadow:0 4px 12px rgba(0,0,0,0.08);z-index:10;min-width:160px;display:flex;flex-direction:column;gap:8px;align-items:flex-start">
|
|
74
|
+
${roleForm}
|
|
75
|
+
${removeForm}
|
|
76
|
+
</div>
|
|
77
|
+
</details>`;
|
|
78
|
+
}
|
|
79
|
+
|
|
54
80
|
function renderMemberRow(m: AccountMember, isOwner: boolean): string {
|
|
55
|
-
const actions = isOwner
|
|
56
|
-
? [
|
|
57
|
-
m.role === "owner"
|
|
58
|
-
? emailForm("members/demote", m.email, "Demote")
|
|
59
|
-
: emailForm("members/promote", m.email, "Make owner"),
|
|
60
|
-
emailForm(
|
|
61
|
-
"members/remove",
|
|
62
|
-
m.email,
|
|
63
|
-
"Remove",
|
|
64
|
-
true,
|
|
65
|
-
REMOVE_MEMBER_CONFIRM,
|
|
66
|
-
),
|
|
67
|
-
].join(" ")
|
|
68
|
-
: "";
|
|
69
81
|
return `<tr>
|
|
70
82
|
<td>${escapeHtml(m.email)}</td>
|
|
71
83
|
<td><span class="badge ${m.role === "owner" ? "badge-purple" : "badge-gray"}">${escapeHtml(m.role)}</span></td>
|
|
72
|
-
${isOwner ? `<td style="text-align:right">${
|
|
84
|
+
${isOwner ? `<td style="text-align:right">${renderMemberEditMenu(m)}</td>` : ""}
|
|
73
85
|
</tr>`;
|
|
74
86
|
}
|
|
75
87
|
|
|
@@ -127,7 +139,7 @@ export function renderAccountPage(opts: AccountPageOpts): string {
|
|
|
127
139
|
</div>
|
|
128
140
|
<div class="card">
|
|
129
141
|
<div class="card-title">Members</div>
|
|
130
|
-
<div class="data-table-wrapper">
|
|
142
|
+
<div class="data-table-wrapper"${isOwner ? ' style="overflow:visible"' : ""}>
|
|
131
143
|
<table class="data-table">
|
|
132
144
|
<thead><tr><th>Email</th><th>Role</th>${actionTh}</tr></thead>
|
|
133
145
|
<tbody>${memberRows}</tbody>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { describe, expect, test } from "bun:test";
|
|
7
7
|
import {
|
|
8
|
+
REMOVE_MEMBER_CONFIRM,
|
|
8
9
|
renderAccountPage,
|
|
9
10
|
renderZeroQuotaNotice,
|
|
10
11
|
} from "./admin-ui-account-pages.ts";
|
|
@@ -72,13 +73,74 @@ describe("renderAccountPage", () => {
|
|
|
72
73
|
expect(html).toContain('action="/admin/account/rename"');
|
|
73
74
|
});
|
|
74
75
|
|
|
75
|
-
test("
|
|
76
|
-
|
|
76
|
+
test("owner sees exactly one Edit control per member row", () => {
|
|
77
|
+
const html = render(true);
|
|
78
|
+
expect(html.match(/<summary[^>]*>Edit<\/summary>/g)?.length).toBe(
|
|
79
|
+
members.length,
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("member rows have no top-level Demote/Make owner/Remove buttons", () => {
|
|
84
|
+
const outsidePopovers = render(true).replace(
|
|
85
|
+
/<details[\s\S]*?<\/details>/g,
|
|
86
|
+
"",
|
|
87
|
+
);
|
|
88
|
+
expect(outsidePopovers).not.toContain("members/promote");
|
|
89
|
+
expect(outsidePopovers).not.toContain("members/demote");
|
|
90
|
+
expect(outsidePopovers).not.toContain("members/remove");
|
|
91
|
+
expect(outsidePopovers).not.toContain(">Demote<");
|
|
92
|
+
expect(outsidePopovers).not.toContain(">Make owner<");
|
|
93
|
+
expect(outsidePopovers).not.toContain(">Remove<");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("member popover offers Make owner and Remove, not Make member", () => {
|
|
97
|
+
const html = render(true);
|
|
98
|
+
const rowStart = html.indexOf("m@x.com</td>");
|
|
99
|
+
const row = html.slice(rowStart, html.indexOf("</tr>", rowStart));
|
|
100
|
+
expect(row).toContain("<details");
|
|
101
|
+
expect(row).toContain('action="/admin/account/members/promote"');
|
|
102
|
+
expect(row).toContain(">Make owner</button>");
|
|
103
|
+
expect(row).not.toContain("members/demote");
|
|
104
|
+
expect(row).not.toContain(">Make member</button>");
|
|
105
|
+
expect(row).toContain('action="/admin/account/members/remove"');
|
|
106
|
+
expect(row).toContain(">Remove</button>");
|
|
107
|
+
expect(row).toContain("btn-danger");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("owner popover offers Make member and Remove, not Make owner", () => {
|
|
111
|
+
const html = render(true);
|
|
112
|
+
const rowStart = html.indexOf("o@x.com</td>");
|
|
113
|
+
const row = html.slice(rowStart, html.indexOf("</tr>", rowStart));
|
|
114
|
+
expect(row).toContain("<details");
|
|
115
|
+
expect(row).toContain('action="/admin/account/members/demote"');
|
|
116
|
+
expect(row).toContain(">Make member</button>");
|
|
117
|
+
expect(row).not.toContain("members/promote");
|
|
118
|
+
expect(row).not.toContain(">Make owner</button>");
|
|
119
|
+
expect(row).toContain('action="/admin/account/members/remove"');
|
|
120
|
+
expect(row).toContain(">Remove</button>");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("owner members table wrapper does not clip the Edit popover", () => {
|
|
124
|
+
const html = render(true);
|
|
125
|
+
expect(html).toContain(
|
|
126
|
+
'<div class="data-table-wrapper" style="overflow:visible">',
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("remove form in the Edit popover confirms REMOVE_MEMBER_CONFIRM", () => {
|
|
131
|
+
const html = render(true);
|
|
132
|
+
expect(html).toContain(
|
|
133
|
+
`onsubmit="return confirm('${REMOVE_MEMBER_CONFIRM}')"`,
|
|
134
|
+
);
|
|
135
|
+
expect(html).toContain("notification settings are removed");
|
|
77
136
|
});
|
|
78
137
|
|
|
79
|
-
test("member sees read-only page", () => {
|
|
138
|
+
test("member sees read-only page with no Edit control or actions column", () => {
|
|
80
139
|
const html = render(false);
|
|
81
140
|
expect(html).not.toContain('action="/admin/account/');
|
|
141
|
+
expect(html).not.toContain(">Edit</summary>");
|
|
142
|
+
expect(html).not.toContain(">Edit</button>");
|
|
143
|
+
expect(html).not.toContain("<th></th>");
|
|
82
144
|
expect(html).toContain("m@x.com");
|
|
83
145
|
});
|
|
84
146
|
|
|
@@ -232,6 +232,33 @@ describe("/admin/account", () => {
|
|
|
232
232
|
).toBe(400);
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
+
it("owner page renders one Edit popover per member posting to the role and remove routes", async () => {
|
|
236
|
+
const { app } = setup();
|
|
237
|
+
const body = await (
|
|
238
|
+
await app.request("/admin/account", {
|
|
239
|
+
headers: { "x-test-user-email": "owner@x.com" },
|
|
240
|
+
})
|
|
241
|
+
).text();
|
|
242
|
+
expect(body.match(/<summary[^>]*>Edit<\/summary>/g)?.length).toBe(2);
|
|
243
|
+
expect(body).toContain('action="/admin/account/members/demote"');
|
|
244
|
+
expect(body).toContain('action="/admin/account/members/promote"');
|
|
245
|
+
expect(body).toContain('action="/admin/account/members/remove"');
|
|
246
|
+
expect(body).toContain(">Make member</button>");
|
|
247
|
+
expect(body).toContain(">Make owner</button>");
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("non-owner admin view has no Edit control", async () => {
|
|
251
|
+
const { app } = setup();
|
|
252
|
+
const res = await app.request("/admin/account", {
|
|
253
|
+
headers: { "x-test-user-email": "member@x.com", "x-test-admin": "1" },
|
|
254
|
+
});
|
|
255
|
+
expect(res.status).toBe(200);
|
|
256
|
+
const body = await res.text();
|
|
257
|
+
expect(body).toContain("member@x.com");
|
|
258
|
+
expect(body).not.toContain(">Edit</summary>");
|
|
259
|
+
expect(body).not.toContain(">Edit</button>");
|
|
260
|
+
});
|
|
261
|
+
|
|
235
262
|
it("member gets 404 on every mutation (ACM-7.2)", async () => {
|
|
236
263
|
const { app } = setup();
|
|
237
264
|
for (const [path, fields] of [
|