@coffre/ui 0.3.0 → 0.4.1

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.
Files changed (180) hide show
  1. package/dist/chunks/audit-sentence-BhHmvQX_.js +660 -0
  2. package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
  3. package/dist/chunks/connected-apps-CUOyEZXR.js +146 -0
  4. package/dist/chunks/connected-apps-CUOyEZXR.js.map +1 -0
  5. package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
  6. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  7. package/dist/chunks/{directory-CSjWWUQ1.js → directory-CxxrnGUL.js} +177 -60
  8. package/dist/chunks/directory-CxxrnGUL.js.map +1 -0
  9. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  10. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  11. package/dist/chunks/grants-CXcmhujY.js +669 -0
  12. package/dist/chunks/grants-CXcmhujY.js.map +1 -0
  13. package/dist/chunks/offboarding-6eAduCsM.js +305 -0
  14. package/dist/chunks/offboarding-6eAduCsM.js.map +1 -0
  15. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  16. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  17. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  18. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  19. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  20. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  21. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-B9R2zPlp.js} +259 -251
  22. package/dist/chunks/principal-page-B9R2zPlp.js.map +1 -0
  23. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  24. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  25. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  26. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  27. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  28. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  29. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  30. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  31. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  32. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  33. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  34. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  35. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  36. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  37. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  38. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  39. package/dist/chunks/{use-change-c6CeLRin.js → use-change-CZdI2MJG.js} +75 -21
  40. package/dist/chunks/use-change-CZdI2MJG.js.map +1 -0
  41. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  42. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  43. package/dist/chunks/validation-D312_NLf.js +87 -0
  44. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  45. package/dist/index.d.ts +385 -31
  46. package/dist/index.js +188 -102
  47. package/dist/index.js.map +1 -1
  48. package/dist/pages/account.d.ts +2 -2
  49. package/dist/pages/account.js +174 -135
  50. package/dist/pages/account.js.map +1 -1
  51. package/dist/pages/approval.d.ts +9 -0
  52. package/dist/pages/approval.js +207 -0
  53. package/dist/pages/approval.js.map +1 -0
  54. package/dist/pages/audit.js +17 -542
  55. package/dist/pages/audit.js.map +1 -1
  56. package/dist/pages/device-login.js +2 -3
  57. package/dist/pages/device-login.js.map +1 -1
  58. package/dist/pages/environment.js +647 -257
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +18 -7
  61. package/dist/pages/login.js.map +1 -1
  62. package/dist/pages/oauth-authorize.d.ts +10 -0
  63. package/dist/pages/oauth-authorize.js +249 -0
  64. package/dist/pages/oauth-authorize.js.map +1 -0
  65. package/dist/pages/project-access.d.ts +6 -0
  66. package/dist/pages/project-access.js +370 -0
  67. package/dist/pages/project-access.js.map +1 -0
  68. package/dist/pages/project-environments.d.ts +4 -0
  69. package/dist/pages/project-environments.js +593 -0
  70. package/dist/pages/project-environments.js.map +1 -0
  71. package/dist/pages/project-settings.d.ts +4 -0
  72. package/dist/pages/project-settings.js +242 -0
  73. package/dist/pages/project-settings.js.map +1 -0
  74. package/dist/pages/project.d.ts +10 -2
  75. package/dist/pages/project.js +57 -934
  76. package/dist/pages/project.js.map +1 -1
  77. package/dist/pages/projects.js +53 -21
  78. package/dist/pages/projects.js.map +1 -1
  79. package/dist/pages/service-account.d.ts +10 -0
  80. package/dist/pages/{token.js → service-account.js} +112 -54
  81. package/dist/pages/service-account.js.map +1 -0
  82. package/dist/pages/service-accounts.d.ts +3 -0
  83. package/dist/pages/service-accounts.js +38 -0
  84. package/dist/pages/service-accounts.js.map +1 -0
  85. package/dist/pages/settings.d.ts +1 -0
  86. package/dist/pages/settings.js +104 -42
  87. package/dist/pages/settings.js.map +1 -1
  88. package/dist/pages/unregistered.js +2 -3
  89. package/dist/pages/unregistered.js.map +1 -1
  90. package/dist/pages/user.d.ts +6 -1
  91. package/dist/pages/user.js +18 -6
  92. package/dist/pages/user.js.map +1 -1
  93. package/dist/pages/users.js +6 -10
  94. package/dist/pages/users.js.map +1 -1
  95. package/package.json +3 -3
  96. package/src/components/actions-log.tsx +117 -0
  97. package/src/components/audit-sentence.tsx +55 -0
  98. package/src/components/command-palette.tsx +4 -4
  99. package/src/components/connected-apps.tsx +138 -0
  100. package/src/components/delete-place.tsx +180 -0
  101. package/src/components/directory.tsx +266 -110
  102. package/src/components/every-project.tsx +287 -0
  103. package/src/components/expiry-field.tsx +42 -0
  104. package/src/components/folders.tsx +219 -0
  105. package/src/components/grants.tsx +11 -4
  106. package/src/components/icons.tsx +2 -0
  107. package/src/components/missing.tsx +110 -0
  108. package/src/components/offboarding.tsx +62 -34
  109. package/src/components/page.tsx +4 -1
  110. package/src/components/principal-page.tsx +154 -108
  111. package/src/components/principal-picker.tsx +5 -5
  112. package/src/components/principal.tsx +4 -4
  113. package/src/components/references.tsx +323 -0
  114. package/src/components/service-tokens.tsx +112 -93
  115. package/src/components/shell.tsx +11 -32
  116. package/src/components/tabs.tsx +18 -0
  117. package/src/components/trusted-workloads.tsx +97 -79
  118. package/src/components/ui.tsx +8 -1
  119. package/src/index.ts +13 -3
  120. package/src/layout.tsx +2 -2
  121. package/src/lib/access-plan.ts +2 -2
  122. package/src/lib/audit-sentences.ts +161 -77
  123. package/src/lib/changes.ts +77 -5
  124. package/src/lib/coffre.ts +3 -2
  125. package/src/lib/one-time.ts +32 -0
  126. package/src/lib/project-access.ts +11 -23
  127. package/src/lib/project-page.ts +14 -0
  128. package/src/lib/queries.ts +126 -32
  129. package/src/lib/search.ts +25 -0
  130. package/src/lib/signin-errors.ts +45 -1
  131. package/src/lib/validation.ts +14 -0
  132. package/src/options.ts +187 -42
  133. package/src/pages/account.tsx +176 -133
  134. package/src/pages/approval.tsx +197 -0
  135. package/src/pages/audit.tsx +9 -61
  136. package/src/pages/environment.tsx +585 -286
  137. package/src/pages/login.tsx +8 -2
  138. package/src/pages/oauth-authorize.tsx +233 -0
  139. package/src/pages/project-access.tsx +219 -0
  140. package/src/pages/project-environments.tsx +582 -0
  141. package/src/pages/project-settings.tsx +259 -0
  142. package/src/pages/project.tsx +52 -879
  143. package/src/pages/projects.tsx +55 -18
  144. package/src/pages/service-account.tsx +50 -0
  145. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  146. package/src/pages/settings.tsx +62 -8
  147. package/src/pages/user.tsx +16 -4
  148. package/src/pages/users.tsx +2 -2
  149. package/src/parity.ts +160 -0
  150. package/src/register.ts +57 -10
  151. package/src/router.tsx +4 -0
  152. package/src/shared/models.ts +6 -2
  153. package/src/styles/globals.css +536 -31
  154. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  155. package/dist/chunks/grants-saMQagmG.js +0 -160
  156. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  157. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  158. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  159. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  160. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  161. package/dist/chunks/page-C5HcNqf2.js +0 -190
  162. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  163. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  164. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  165. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  166. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  167. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  168. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  169. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  170. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  171. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  172. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  173. package/dist/pages/token.d.ts +0 -3
  174. package/dist/pages/token.js.map +0 -1
  175. package/dist/pages/tokens.d.ts +0 -3
  176. package/dist/pages/tokens.js +0 -39
  177. package/dist/pages/tokens.js.map +0 -1
  178. package/dist/project-BqIy8gYR.d.ts +0 -5
  179. package/src/lib/instance.ts +0 -13
  180. package/src/pages/token.tsx +0 -34
@@ -1,206 +1,174 @@
1
- import { a as ErrorLine, c as Notice, i as EmptyState, l as Spinner, s as Modal } from "./ui-DixXLQvQ.js";
2
- import { A as Pencil, G as X, W as Users, l as Clock, p as Folder, v as Key } from "./icons-D-PfAfnH.js";
3
- import { d as Tile, i as PageHeader, n as ClosedDoor, s as memberRef, u as useCoffre } from "./page-C5HcNqf2.js";
4
- import { t as ItemFailure } from "./row-state-0PsrEzOL.js";
5
- import { c as managedProjects, t as affects, u as queries } from "./queries-CQ81o4so.js";
6
- import { t as useShell } from "./use-shell-jxd7Tzd-.js";
7
- import { D as projectAccessLabel, l as directoryList, n as useChangeStatus } from "./use-change-c6CeLRin.js";
8
- import { a as PrincipalActions, i as KIND, o as PrincipalAvatar, r as InstanceRole } from "./directory-CSjWWUQ1.js";
9
- import { t as useAction } from "./use-action-CWsg_YWU.js";
10
- import { n as GrantsTable, t as GrantRowView } from "./grants-saMQagmG.js";
11
- import { r as RemovedNotice, t as PrincipalReportCards } from "./offboarding-C6l30DZR.js";
1
+ import { t as useMounted } from "./mounted-jJmqqV_n.js";
2
+ import { a as ErrorLine, c as Notice, i as EmptyState, l as Spinner, s as Modal, u as Timestamp } from "./ui-DJje3gST.js";
3
+ import { A as Key, H as Pencil, J as ShieldCheck, N as Link$1, T as Folder, X as SlashCircle, d as Tile, f as Activity, h as Archive, i as PageHeader, l as uiResult, n as ClosedDoor, rt as Users, s as memberRef, u as useCoffre, x as Clock } from "./page-DvsgZ2Hd.js";
4
+ import { t as ItemFailure } from "./row-state-DOPUsjQK.js";
5
+ import { d as managedProjects, g as signInWays, p as queries, r as keys, t as affects } from "./queries-DVR_i3rA.js";
6
+ import { t as useShell } from "./use-shell-rNKfGjdj.js";
7
+ import { A as projectAccessLabel, d as disconnectMemberApp, l as directoryList, n as useChangeStatus } from "./use-change-CZdI2MJG.js";
8
+ import { t as PrincipalAvatar } from "./principal-BIN-xwZw.js";
9
+ import { i as PrincipalActions, n as InstanceRole, r as KIND } from "./directory-CxxrnGUL.js";
10
+ import { t as ConnectedAppsCard } from "./connected-apps-CUOyEZXR.js";
11
+ import { a as lines, i as describe, t as Sentence } from "./audit-sentence-BhHmvQX_.js";
12
+ import { a as useAction } from "./validation-D312_NLf.js";
13
+ import { a as EveryProjectGrants, d as accessPatch, f as dateFromExpiry, g as withLevel, h as withEnvironment, l as ExpiryField, m as planFromGrants, n as GrantsTable, p as environmentAccess, t as GrantRowView, u as accessChanges } from "./grants-CXcmhujY.js";
14
+ import { t as PageTabs } from "./tabs-BmwKfUeK.js";
15
+ import { r as RemovedNotice, t as PrincipalReportCards } from "./offboarding-6eAduCsM.js";
12
16
  import { useState } from "react";
13
- import { Link } from "@tanstack/react-router";
17
+ import { Link, Outlet } from "@tanstack/react-router";
14
18
  import { toast } from "sonner";
15
19
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
- import { useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
17
- //#region src/lib/access-plan.ts
18
- /** An environment's access in a plan; slugs like `constructor` are not inherited. */
19
- function environmentAccess(plan, slug) {
20
- return Object.hasOwn(plan.environments, slug) ? plan.environments[slug] : null;
21
- }
22
- /**
23
- * Read what a principal holds on a project back into the editor's terms.
24
- * `environments` are the ones the editor can set: live, and not archived.
25
- */
26
- function planFromGrants(grants, environments) {
27
- if (grants.length === 0) return {
28
- level: "none",
29
- expiresAt: null,
30
- environments: {}
31
- };
32
- const [only] = grants;
33
- if (grants.length === 1 && only.environmentSlug === null && (only.role === "owner" || only.role === "viewer" || only.role === "developer")) return {
34
- level: only.role,
35
- expiresAt: only.expiresAt,
36
- environments: {}
37
- };
38
- const perEnvironment = {};
39
- for (const grant of grants) {
40
- const slug = grant.environmentSlug;
41
- if (slug === null || !environments.includes(slug) || Object.hasOwn(perEnvironment, slug) || grant.role !== "viewer" && grant.role !== "developer") return {
42
- level: "custom",
43
- expiresAt: null,
44
- environments: {}
45
- };
46
- perEnvironment[slug] = {
47
- role: grant.role,
48
- expiresAt: grant.expiresAt
49
- };
50
- }
51
- return {
52
- level: "env",
53
- expiresAt: null,
54
- environments: perEnvironment
55
- };
56
- }
20
+ import { useInfiniteQuery, useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
21
+ import { ROLES } from "@coffre/core/access";
22
+ //#region src/components/actions-log.tsx
23
+ var PAGE_SIZE = 50;
57
24
  /**
58
- * Switch a plan's level. Going from read or write everywhere to per
59
- * environment starts every environment at that level and expiry, so the
60
- * switch alone keeps the same reach.
25
+ * Everything one member did, newest first, from the audit log: the same
26
+ * entries `coffre audit --actor` lists, said as the audit page says them.
27
+ * Older pages come on request.
61
28
  */
62
- function withLevel(plan, level, environments) {
63
- if (level === "env" && (plan.level === "viewer" || plan.level === "developer") && Object.keys(plan.environments).length === 0) {
64
- const access = {
65
- role: plan.level,
66
- expiresAt: plan.expiresAt
67
- };
68
- return {
69
- ...plan,
70
- level,
71
- environments: Object.fromEntries(environments.map((slug) => [slug, access]))
72
- };
73
- }
74
- return {
75
- ...plan,
76
- level
77
- };
78
- }
79
- /** Set one environment's access, or take it away with `null`. */
80
- function withEnvironment(plan, slug, access) {
81
- const environments = { ...plan.environments };
82
- if (access === null) delete environments[slug];
83
- else environments[slug] = access;
84
- return {
85
- ...plan,
86
- environments
87
- };
88
- }
89
- function grantsFor(plan) {
90
- switch (plan.level) {
91
- case "none":
92
- case "custom": return [];
93
- case "owner":
94
- case "viewer":
95
- case "developer": return [{
96
- role: plan.level,
97
- environmentSlug: null,
98
- expiresAt: plan.expiresAt
99
- }];
100
- case "env": return Object.entries(plan.environments).map(([environmentSlug, access]) => ({
101
- environmentSlug,
102
- ...access
103
- }));
104
- }
105
- }
106
- /** The server and the date field spell the same instant differently. */
107
- function sameExpiry(a, b) {
108
- return a === b || a !== null && b !== null && Date.parse(a) === Date.parse(b);
109
- }
110
- /**
111
- * The changes that take what is held to the plan: grants to create, grants
112
- * whose expiry moves, and grants to revoke, in that order. Asking for what is
113
- * already held yields nothing, so applying the same plan twice is a no-op.
114
- */
115
- function accessChanges(grants, plan) {
116
- if (plan.level === "custom") return [];
117
- const key = (grant) => `${grant.role}@${grant.environmentSlug ?? ""}`;
118
- const wanted = new Map(grantsFor(plan).map((grant) => [key(grant), grant]));
119
- const held = new Map(grants.map((grant) => [key(grant), grant]));
120
- const changes = [];
121
- for (const [id, grant] of wanted) if (!held.has(id)) changes.push({
122
- kind: "create",
123
- ...grant
29
+ function ActionsLog({ member }) {
30
+ const client = useCoffre();
31
+ const log = useInfiniteQuery({
32
+ queryKey: [
33
+ ...keys.audit,
34
+ "actor",
35
+ member
36
+ ],
37
+ staleTime: 0,
38
+ initialPageParam: void 0,
39
+ queryFn: ({ pageParam }) => uiResult(() => client.audit.list({
40
+ actor: member,
41
+ limit: PAGE_SIZE,
42
+ before: pageParam
43
+ })),
44
+ getNextPageParam: (page) => page.ok && page.entries.length === PAGE_SIZE ? page.entries.at(-1).seq : void 0
124
45
  });
125
- for (const [id, grant] of held) {
126
- const want = wanted.get(id);
127
- if (want !== void 0 && !sameExpiry(grant.expiresAt, want.expiresAt)) changes.push({
128
- kind: "expiry",
129
- grant,
130
- expiresAt: want.expiresAt
131
- });
132
- }
133
- for (const [id, grant] of held) if (!wanted.has(id)) changes.push({
134
- kind: "revoke",
135
- grant
46
+ if (log.isPending) return /* @__PURE__ */ jsxs("p", {
47
+ className: "hint",
48
+ children: [/* @__PURE__ */ jsx(Spinner, { size: 13 }), " Reading the log…"]
136
49
  });
137
- return changes;
138
- }
139
- /**
140
- * The changes as the API's access patch for one project: each place it
141
- * touches, and the role to hold there until when, or `null` for none.
142
- *
143
- * { "market": null, "market/dev": { "role": "developer", "until": "2026-12-31T23:59:59.000Z" } }
144
- *
145
- * A place holds one role, so where a level changes, the revoke of the old
146
- * role and the create of the new land on the same place, and the new role
147
- * wins: the server replaces one with the other, never passing through none.
148
- */
149
- function accessPatch(project, changes) {
150
- const place = (environmentSlug) => environmentSlug === null ? project : `${project}/${environmentSlug}`;
151
- const holding = (role, expiresAt) => expiresAt === null ? role : {
152
- role,
153
- until: expiresAt
154
- };
155
- const patch = {};
156
- for (const change of changes) if (change.kind === "revoke") patch[place(change.grant.environmentSlug)] = null;
157
- for (const change of changes) {
158
- if (change.kind === "expiry") patch[place(change.grant.environmentSlug)] = holding(change.grant.role, change.expiresAt);
159
- if (change.kind === "create") patch[place(change.environmentSlug)] = holding(change.role, change.expiresAt);
160
- }
161
- return patch;
162
- }
163
- /** A date field's value as the instant access ends: the close of that day, UTC. */
164
- function expiryFromDate(date) {
165
- return date === "" ? null : (/* @__PURE__ */ new Date(`${date}T23:59:59Z`)).toISOString();
166
- }
167
- /** A date field's value for an expiry. Expiries are shown as UTC dates everywhere. */
168
- function dateFromExpiry(expiresAt) {
169
- return expiresAt === null ? "" : expiresAt.slice(0, 10);
50
+ const failed = log.data?.pages.find((page) => !page.ok);
51
+ if (failed !== void 0 && !failed.ok) return /* @__PURE__ */ jsx(Notice, {
52
+ tone: "bad",
53
+ children: failed.error
54
+ });
55
+ const shown = lines((log.data?.pages ?? []).flatMap((page) => page.ok ? page.entries : []));
56
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("section", {
57
+ className: "card",
58
+ "aria-label": "Actions log",
59
+ children: shown.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
60
+ title: "Nothing done yet",
61
+ children: "Every read, write and change they make is listed here."
62
+ }) : /* @__PURE__ */ jsx("div", {
63
+ className: "dt-wrap",
64
+ children: /* @__PURE__ */ jsxs("table", {
65
+ className: "dt actions-log stacks stacks-inline",
66
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
67
+ /* @__PURE__ */ jsx("th", {
68
+ className: "col-shrink",
69
+ children: /* @__PURE__ */ jsxs("span", {
70
+ className: "th",
71
+ children: [/* @__PURE__ */ jsx(Clock, { size: 14 }), "When"]
72
+ })
73
+ }),
74
+ /* @__PURE__ */ jsx("th", { children: /* @__PURE__ */ jsxs("span", {
75
+ className: "th",
76
+ children: [/* @__PURE__ */ jsx(Activity, { size: 14 }), "Action"]
77
+ }) }),
78
+ /* @__PURE__ */ jsx("th", {
79
+ className: "col-shrink",
80
+ children: /* @__PURE__ */ jsxs("span", {
81
+ className: "th",
82
+ children: [/* @__PURE__ */ jsx(ShieldCheck, { size: 14 }), "Outcome"]
83
+ })
84
+ })
85
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: shown.map((batch) => {
86
+ const lead = batch[0];
87
+ const sentence = describe(batch);
88
+ return /* @__PURE__ */ jsxs("tr", {
89
+ className: sentence.refused ? "is-denied" : void 0,
90
+ children: [
91
+ /* @__PURE__ */ jsx("td", {
92
+ className: "nowrap cell-muted",
93
+ title: lead.occurredAt,
94
+ children: /* @__PURE__ */ jsx(Timestamp, {
95
+ iso: lead.occurredAt,
96
+ display: "relative"
97
+ })
98
+ }),
99
+ /* @__PURE__ */ jsx("td", {
100
+ className: "cell-sentence",
101
+ children: /* @__PURE__ */ jsx("span", {
102
+ className: "sentence",
103
+ children: /* @__PURE__ */ jsx(Sentence, { parts: sentence.parts })
104
+ })
105
+ }),
106
+ /* @__PURE__ */ jsx("td", {
107
+ className: "nowrap",
108
+ "data-label": "Outcome",
109
+ children: sentence.refused ? /* @__PURE__ */ jsxs("span", {
110
+ className: "decided decided-refused",
111
+ children: [/* @__PURE__ */ jsx(SlashCircle, { size: 13 }), "Refused"]
112
+ }) : /* @__PURE__ */ jsx("span", {
113
+ className: "cell-muted",
114
+ children: "Allowed"
115
+ })
116
+ })
117
+ ]
118
+ }, lead.seq);
119
+ }) })]
120
+ })
121
+ })
122
+ }), log.hasNextPage && /* @__PURE__ */ jsx("div", {
123
+ className: "table-actions",
124
+ children: /* @__PURE__ */ jsxs("button", {
125
+ type: "button",
126
+ className: "btn",
127
+ disabled: log.isFetchingNextPage,
128
+ onClick: () => void log.fetchNextPage(),
129
+ children: [log.isFetchingNextPage && /* @__PURE__ */ jsx(Spinner, {}), "Show older"]
130
+ })
131
+ })] });
170
132
  }
171
133
  //#endregion
172
134
  //#region src/components/principal-page.tsx
135
+ /** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */
136
+ function useReport(principalType, principalId) {
137
+ const { capabilities } = useShell();
138
+ return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.canManageGrants)).data;
139
+ }
173
140
  /**
174
- * Everything one user's or token's page shows, from what `loadPrincipal`
175
- * read: who it is to the instance and what it has seen (owners only), and its
176
- * grants on every project where you manage access.
141
+ * Its grants on every project where you manage access, which `loadAccess`
142
+ * read: there is no call for one member's, so each project's are filtered.
177
143
  */
178
- function usePrincipalPage(principalType, principalId) {
144
+ function useProjectAccess(principalType, principalId) {
179
145
  const client = useCoffre();
180
- const { projects, capabilities } = useShell();
181
- const managed = managedProjects(projects);
182
- const { data: report } = useSuspenseQuery(queries.report(client, memberRef(principalType, principalId), capabilities.canManageGrants));
146
+ const managed = managedProjects(useShell().projects);
183
147
  const grants = useSuspenseQueries({ queries: managed.map((project) => queries.grants(client, project.slug)) });
184
- return {
185
- report,
186
- access: managed.map((project, index) => {
187
- const result = grants[index].data;
188
- return {
189
- project,
190
- grants: result.ok ? result.grants.filter((grant) => grant.principalType === principalType && grant.principalId === principalId) : [],
191
- grantsError: result.ok ? null : result.error
192
- };
193
- })
194
- };
148
+ return managed.map((project, index) => {
149
+ const result = grants[index].data;
150
+ return {
151
+ project,
152
+ grants: result.ok ? result.grants.filter((grant) => grant.principalType === principalType && grant.principalId === principalId && grant.scope !== "every-project") : [],
153
+ grantsError: result.ok ? null : result.error
154
+ };
155
+ });
195
156
  }
196
- function PrincipalPage({ principalType, principalId }) {
197
- const { instanceRole } = useShell();
198
- const { report, access } = usePrincipalPage(principalType, principalId);
157
+ /**
158
+ * A user's or service account's page: who it is, its menu, and its tabs,
159
+ * each a page of its own under this one. Access is a user's first tab; a
160
+ * service account's is how it signs in, while it shows one. A tab the
161
+ * deployment left out is not offered.
162
+ */
163
+ function PrincipalLayout({ principalType, principalId }) {
164
+ const shell = useShell();
165
+ const mounted = useMounted();
166
+ const { capabilities } = shell;
167
+ const report = useReport(principalType, principalId);
199
168
  const { status, dismiss } = useChangeStatus(directoryList.queryKey);
200
169
  const change = status(memberRef(principalType, principalId));
201
170
  const kind = KIND[principalType];
202
171
  const people = principalType === "user";
203
- const list = people ? "/users" : "/tokens";
204
172
  const found = report?.ok === true ? report.report : null;
205
173
  const removed = found?.status === "removed";
206
174
  const entry = found !== null && !removed ? {
@@ -210,26 +178,55 @@ function PrincipalPage({ principalType, principalId }) {
210
178
  isRootAdmin: found.isRootAdmin,
211
179
  tampered: found.status === "tampered"
212
180
  } : void 0;
213
- if (report?.ok === true && found === null || report === null && access.length === 0) return /* @__PURE__ */ jsx(ClosedDoor, {
181
+ if (report?.ok === true && found === null || report === null && managedProjects(shell.projects).length === 0) return /* @__PURE__ */ jsx(ClosedDoor, {
214
182
  icon: people ? /* @__PURE__ */ jsx(Users, { size: 18 }) : /* @__PURE__ */ jsx(Key, { size: 18 }),
215
183
  label: /* @__PURE__ */ jsx("span", {
216
184
  className: "mono",
217
- children: principalId
185
+ children: people ? principalId : `service:${principalId}`
218
186
  }),
219
- title: people ? "No such user for you" : "No such token for you",
187
+ title: people ? "No such user for you" : "No such service account for you",
220
188
  actions: /* @__PURE__ */ jsxs(Link, {
221
189
  className: "btn",
222
- to: list,
223
- children: ["All ", people ? "users" : "tokens"]
190
+ to: people ? "/users" : "/service-accounts",
191
+ children: ["All ", people ? "users" : "service accounts"]
224
192
  }),
225
193
  children: report === null ? `A ${kind}'s page lists its access to the projects where you manage access, and you manage none.` : `No ${kind} by that name has ever been registered here.`
226
194
  });
227
- const rows = access.flatMap(({ project, grants }) => grants.map((grant) => ({
228
- project,
229
- grant
230
- })));
231
- const errors = access.filter((entry) => entry.grantsError !== null);
232
- const editable = removed ? [] : access.filter(({ project, grantsError }) => project.archivedAt === null && grantsError === null);
195
+ const access = /* @__PURE__ */ jsxs(Fragment$1, { children: [removed ? /* @__PURE__ */ jsx(Archive, { size: 15 }) : /* @__PURE__ */ jsx(Folder, { size: 15 }), removed ? "Offboarding" : "Access"] });
196
+ const activity = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Activity, { size: 15 }), "Activity"] });
197
+ const tabs = people ? [/* @__PURE__ */ jsx(Link, {
198
+ to: "/users/$user",
199
+ params: { user: principalId },
200
+ activeOptions: {
201
+ exact: true,
202
+ includeSearch: false
203
+ },
204
+ children: access
205
+ }, "access"), capabilities.canReadAudit && mounted("/users/$user/activity") && /* @__PURE__ */ jsx(Link, {
206
+ to: "/users/$user/activity",
207
+ params: { user: principalId },
208
+ children: activity
209
+ }, "activity")] : [
210
+ signInWays(shell, report) !== null && /* @__PURE__ */ jsxs(Link, {
211
+ to: "/service-accounts/$account",
212
+ params: { account: principalId },
213
+ activeOptions: {
214
+ exact: true,
215
+ includeSearch: false
216
+ },
217
+ children: [/* @__PURE__ */ jsx(Link$1, { size: 15 }), "Sign-in"]
218
+ }, "sign-in"),
219
+ mounted("/service-accounts/$account/access") && /* @__PURE__ */ jsx(Link, {
220
+ to: "/service-accounts/$account/access",
221
+ params: { account: principalId },
222
+ children: access
223
+ }, "access"),
224
+ capabilities.canReadAudit && mounted("/service-accounts/$account/activity") && /* @__PURE__ */ jsx(Link, {
225
+ to: "/service-accounts/$account/activity",
226
+ params: { account: principalId },
227
+ children: activity
228
+ }, "activity")
229
+ ];
233
230
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
234
231
  /* @__PURE__ */ jsx(PageHeader, {
235
232
  lead: /* @__PURE__ */ jsx(PrincipalAvatar, {
@@ -237,19 +234,16 @@ function PrincipalPage({ principalType, principalId }) {
237
234
  id: principalId,
238
235
  size: "lg"
239
236
  }),
240
- title: principalId,
237
+ title: principalType === "service" ? `service:${principalId}` : principalId,
238
+ description: principalType === "service" ? "A service account: an identity for CI and other automation." : void 0,
241
239
  meta: removed ? /* @__PURE__ */ jsx("span", {
242
240
  className: "tag tag-red",
243
241
  children: "Removed"
244
242
  }) : entry?.principalType === "user" && /* @__PURE__ */ jsx(InstanceRole, { principal: entry }),
245
- actions: (editable.length > 0 || entry !== void 0) && /* @__PURE__ */ jsxs(Fragment$1, { children: [editable.length > 0 && /* @__PURE__ */ jsx(EditAccess, {
246
- principalType,
247
- principalId,
248
- access: editable
249
- }), entry !== void 0 && /* @__PURE__ */ jsx(PrincipalActions, {
243
+ actions: entry !== void 0 && /* @__PURE__ */ jsx(PrincipalActions, {
250
244
  principal: entry,
251
245
  trigger: "btn btn-icon"
252
- })] })
246
+ })
253
247
  }),
254
248
  change.state === "failed" && /* @__PURE__ */ jsx("div", {
255
249
  className: "report-notice",
@@ -265,12 +259,35 @@ function PrincipalPage({ principalType, principalId }) {
265
259
  children: report.error
266
260
  })
267
261
  }),
262
+ /* @__PURE__ */ jsx(PageTabs, {
263
+ label: people ? "User sections" : "Service account sections",
264
+ children: tabs
265
+ }),
266
+ /* @__PURE__ */ jsx(Outlet, {})
267
+ ] });
268
+ }
269
+ /**
270
+ * A user's or service account's Access tab: its grants on every project
271
+ * where you manage access, and on every project; once it is removed, what
272
+ * its offboarding did instead.
273
+ */
274
+ function PrincipalAccess({ principalType, principalId }) {
275
+ const { instanceRole, features } = useShell();
276
+ const report = useReport(principalType, principalId);
277
+ const access = useProjectAccess(principalType, principalId);
278
+ const kind = KIND[principalType];
279
+ const people = principalType === "user";
280
+ const found = report?.ok === true ? report.report : null;
281
+ const removed = found?.status === "removed";
282
+ const rows = access.flatMap(({ project, grants }) => grants.map((grant) => ({
283
+ project,
284
+ grant
285
+ })));
286
+ const errors = access.filter((entry) => entry.grantsError !== null);
287
+ const editable = removed ? [] : access.filter(({ project, grantsError }) => project.archivedAt === null && grantsError === null);
288
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
268
289
  removed && found !== null && /* @__PURE__ */ jsx(RemovedNotice, { report: found }),
269
290
  !removed && /* @__PURE__ */ jsxs(Fragment$1, { children: [
270
- /* @__PURE__ */ jsx("h2", {
271
- className: "section-title",
272
- children: "Project access"
273
- }),
274
291
  errors.map(({ project, grantsError }) => /* @__PURE__ */ jsx("div", {
275
292
  style: { marginBottom: "0.75rem" },
276
293
  children: /* @__PURE__ */ jsxs(Notice, {
@@ -307,28 +324,52 @@ function PrincipalPage({ principalType, principalId }) {
307
324
  /* @__PURE__ */ jsx(Tile, { name: project.slug }),
308
325
  /* @__PURE__ */ jsx(Link, {
309
326
  className: "cell-link",
310
- to: "/projects/$project",
327
+ to: people ? "/projects/$project/users" : "/projects/$project/service-accounts",
311
328
  params: { project: project.slug },
312
- search: { tab: people ? "users" : "tokens" },
313
329
  children: project.name
314
330
  }),
315
331
  project.archivedAt !== null && /* @__PURE__ */ jsx("span", {
316
332
  className: "tag tag-red",
317
- children: "archived"
333
+ children: "Archived"
318
334
  })
319
335
  ]
320
336
  })
321
337
  }, grant.id))
322
338
  })
323
339
  }),
340
+ editable.length > 0 && /* @__PURE__ */ jsx("div", {
341
+ className: "table-actions",
342
+ children: /* @__PURE__ */ jsx(EditAccess, {
343
+ principalType,
344
+ principalId,
345
+ access: editable
346
+ })
347
+ }),
324
348
  instanceRole !== "root-admin" && /* @__PURE__ */ jsx("p", {
325
349
  className: "hint section-foot",
326
350
  children: "Only projects where you manage access are listed."
351
+ }),
352
+ /* @__PURE__ */ jsx(EveryProjectGrants, {
353
+ principalType,
354
+ principalId
355
+ }),
356
+ features.mcp && people && found !== null && /* @__PURE__ */ jsx(MemberApps, {
357
+ principalId,
358
+ apps: found.apps
327
359
  })
328
360
  ] }),
329
361
  found !== null && /* @__PURE__ */ jsx(PrincipalReportCards, { report: found })
330
362
  ] });
331
363
  }
364
+ /** A person's connected apps, for an owner, who may disconnect any of them. */
365
+ function MemberApps({ principalId, apps }) {
366
+ return /* @__PURE__ */ jsx(ConnectedAppsCard, {
367
+ apps,
368
+ change: disconnectMemberApp(useCoffre(), memberRef("user", principalId)),
369
+ description: "AI assistants and other MCP clients they connected. Each acts as them, never beyond their access. Disconnecting one stops it at its next request; removing them disconnects every one.",
370
+ empty: "They have connected none. An app connects only after they approve it on coffre's page."
371
+ });
372
+ }
332
373
  /**
333
374
  * One principal's access to every project you manage, edited in one place.
334
375
  *
@@ -437,15 +478,15 @@ function EditAccess({ principalType, principalId, access }) {
437
478
  }),
438
479
  /* @__PURE__ */ jsx("option", {
439
480
  value: "owner",
440
- children: "Owner"
481
+ children: ROLES.owner.name
441
482
  }),
442
- /* @__PURE__ */ jsx("option", {
483
+ /* @__PURE__ */ jsxs("option", {
443
484
  value: "viewer",
444
- children: "Read: all"
485
+ children: [ROLES.viewer.name, ": all"]
445
486
  }),
446
- /* @__PURE__ */ jsx("option", {
487
+ /* @__PURE__ */ jsxs("option", {
447
488
  value: "developer",
448
- children: "Write: all"
489
+ children: [ROLES.developer.name, ": all"]
449
490
  }),
450
491
  environments.length > 0 && /* @__PURE__ */ jsx("option", {
451
492
  value: "env",
@@ -492,11 +533,11 @@ function EditAccess({ principalType, principalId, access }) {
492
533
  }),
493
534
  /* @__PURE__ */ jsx("option", {
494
535
  value: "viewer",
495
- children: "Read"
536
+ children: ROLES.viewer.name
496
537
  }),
497
538
  /* @__PURE__ */ jsx("option", {
498
539
  value: "developer",
499
- children: "Write"
540
+ children: ROLES.developer.name
500
541
  })
501
542
  ]
502
543
  }),
@@ -540,39 +581,6 @@ function EditAccess({ principalType, principalId, access }) {
540
581
  })
541
582
  })] });
542
583
  }
543
- /**
544
- * When one grant ends, as a date: access lasts through that day, UTC. Blank
545
- * reads "Never" where the browser lets the empty field be restyled.
546
- */
547
- function ExpiryField({ label, expiresAt, onChange }) {
548
- const date = dateFromExpiry(expiresAt);
549
- return /* @__PURE__ */ jsxs("span", {
550
- className: `expiry${date === "" ? " is-never" : ""}`,
551
- children: [
552
- /* @__PURE__ */ jsx("input", {
553
- className: "input select-sm",
554
- type: "date",
555
- "aria-label": label,
556
- min: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
557
- value: date,
558
- onChange: (event) => onChange(expiryFromDate(event.target.value))
559
- }),
560
- /* @__PURE__ */ jsx("span", {
561
- className: "expiry-never",
562
- "aria-hidden": "true",
563
- children: "Never"
564
- }),
565
- /* @__PURE__ */ jsx("button", {
566
- className: "btn btn-quiet btn-sm btn-icon",
567
- type: "button",
568
- "aria-label": `${label}: never`,
569
- title: "Never expires",
570
- onClick: () => onChange(null),
571
- children: /* @__PURE__ */ jsx(X, { size: 12 })
572
- })
573
- ]
574
- });
575
- }
576
584
  function AccessChangeTag({ change }) {
577
585
  const until = (expiresAt) => expiresAt === null ? "" : ` until ${dateFromExpiry(expiresAt)}`;
578
586
  switch (change.kind) {
@@ -623,6 +631,6 @@ function AccessChangeTag({ change }) {
623
631
  }
624
632
  }
625
633
  //#endregion
626
- export { PrincipalPage as t };
634
+ export { PrincipalLayout as n, ActionsLog as r, PrincipalAccess as t };
627
635
 
628
- //# sourceMappingURL=principal-page-D_91OA0l.js.map
636
+ //# sourceMappingURL=principal-page-B9R2zPlp.js.map