@coffre/ui 0.1.10 → 0.1.11

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 (167) hide show
  1. package/dist/client/_coffre/assets/account-BJAdDvZf.js +2 -0
  2. package/dist/client/_coffre/assets/account-D0jLpk5c.js +1 -0
  3. package/dist/client/_coffre/assets/affordances-Bq2-oUB5.js +1 -0
  4. package/dist/client/_coffre/assets/audit-C-pcBgKe.js +2 -0
  5. package/dist/client/_coffre/assets/audit-CHGlDeBB.js +1 -0
  6. package/dist/client/_coffre/assets/{auth.device-BP5FY0K1.js → auth.device-BndOUjse.js} +1 -1
  7. package/dist/client/_coffre/assets/auth.device-CWHNQn9W.js +2 -0
  8. package/dist/client/_coffre/assets/directory-nDExpkAz.js +1 -0
  9. package/dist/client/_coffre/assets/dist-QVHMLatb.js +1 -0
  10. package/dist/client/_coffre/assets/globals-CKBoTlyH.css +1 -0
  11. package/dist/client/_coffre/assets/grants-CjoOnxzz.js +1 -0
  12. package/dist/client/_coffre/assets/icons-BQ27Ds9u.js +1 -0
  13. package/dist/client/_coffre/assets/index-CUGytaO3.js +12 -0
  14. package/dist/client/_coffre/assets/link-DP8SVWon.js +1 -0
  15. package/dist/client/_coffre/assets/login-CeaxDMcr.js +2 -0
  16. package/dist/client/_coffre/assets/login-DrMgvqZn.js +1 -0
  17. package/dist/client/_coffre/assets/offboarding-CNr_1tnl.js +1 -0
  18. package/dist/client/_coffre/assets/page-CGmvjSy4.js +1 -0
  19. package/dist/client/_coffre/assets/preload-helper-ClBkJ19f.js +1 -0
  20. package/dist/client/_coffre/assets/principal-page-DNLb_q_e.js +1 -0
  21. package/dist/client/_coffre/assets/projects._project._environment-CHzbboGp.js +3 -0
  22. package/dist/client/_coffre/assets/projects._project._environment-DDxu_HHD.js +2 -0
  23. package/dist/client/_coffre/assets/projects._project.index-CIAsjvg6.js +2 -0
  24. package/dist/client/_coffre/assets/projects._project.index-DZ9l6d-1.js +1 -0
  25. package/dist/client/_coffre/assets/projects.index-4eUXreE_.js +1 -0
  26. package/dist/client/_coffre/assets/row-state-ByET1OKX.js +1 -0
  27. package/dist/client/_coffre/assets/settings-D2zp1Ssu.js +1 -0
  28. package/dist/client/_coffre/assets/suspense-C7KwSnTG.js +1 -0
  29. package/dist/client/_coffre/assets/tokens._token-DWmbqzNk.js +2 -0
  30. package/dist/client/_coffre/assets/tokens._token-Dui_4KfS.js +1 -0
  31. package/dist/client/_coffre/assets/tokens.index-CSi5Wxwf.js +1 -0
  32. package/dist/client/_coffre/assets/ui-BdipqGpP.js +46 -0
  33. package/dist/client/_coffre/assets/unregistered-CA7B4C1m.js +1 -0
  34. package/dist/client/_coffre/assets/use-action-DRm9yVhV.js +1 -0
  35. package/dist/client/_coffre/assets/use-change-BRRMJocl.js +1 -0
  36. package/dist/client/_coffre/assets/use-shell-BMGlJ25Q.js +1 -0
  37. package/dist/client/_coffre/assets/useQuery-D__2KBOs.js +1 -0
  38. package/dist/client/_coffre/assets/useSuspenseQuery-CSXyDALB.js +1 -0
  39. package/dist/client/_coffre/assets/users._user-BkNrX7Qf.js +1 -0
  40. package/dist/client/_coffre/assets/users._user-jbSvtdOg.js +2 -0
  41. package/dist/client/_coffre/assets/users.index-CKnQ1G76.js +1 -0
  42. package/dist/server/.vite/manifest.json +343 -246
  43. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-Dx-c3XVk.js +162 -0
  44. package/dist/server/_coffre/assets/{account-CUQYGCYh.js → account-BocTPU1J.js} +150 -117
  45. package/dist/server/_coffre/assets/{account-DMlUoBxQ.js → account-CL8hOGhO.js} +10 -24
  46. package/dist/server/_coffre/assets/{affordances-BNaXjMOb.js → affordances-CKANXDTG.js} +2 -22
  47. package/dist/server/_coffre/assets/{async-local-storage-C0cwgkEr.js → async-local-storage-C10uQtMM.js} +3 -2
  48. package/dist/server/_coffre/assets/{audit-CCdSLmvK.js → audit-Bcka4vA6.js} +46 -16
  49. package/dist/server/_coffre/assets/audit-CSRQYIhu.js +31 -0
  50. package/dist/server/_coffre/assets/{auth.device-C05u5ROO.js → auth.device-CMcUISZY.js} +7 -5
  51. package/dist/server/_coffre/assets/{auth.device-BoFM1jcf.js → auth.device-DqO0T-rU.js} +5 -5
  52. package/dist/server/_coffre/assets/{directory-GsnYkse0.js → directory-CyYx6Jx1.js} +87 -112
  53. package/dist/server/_coffre/assets/{use-action-DwEmf58L.js → dist-CnnV3t2g.js} +3 -48
  54. package/dist/server/_coffre/assets/globals-CKBoTlyH.css +1 -0
  55. package/dist/server/_coffre/assets/grants-CRijabX0.js +158 -0
  56. package/dist/server/_coffre/assets/{page-BdnhpwvH.js → icons-Dy-5ccDF.js} +3 -196
  57. package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +480 -0
  58. package/dist/server/_coffre/assets/link-42ZWdjzZ.js +422 -0
  59. package/dist/server/_coffre/assets/{login-DUtCQju5.js → login-BI9tzJEy.js} +7 -5
  60. package/dist/server/_coffre/assets/{login-B2njIq_o.js → login-C-v88YwP.js} +2 -2
  61. package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +56 -0
  62. package/dist/server/_coffre/assets/{offboarding-8yMa7ViM.js → offboarding-1H0LavTd.js} +6 -4
  63. package/dist/server/_coffre/assets/page-D_mO0-sn.js +3592 -0
  64. package/dist/server/_coffre/assets/{principal-page-B8zPcS2b.js → principal-page-DQDoXute.js} +51 -42
  65. package/dist/server/_coffre/assets/{projects._project._environment-BZ5Z80V8.js → projects._project._environment-C-yVwC92.js} +168 -248
  66. package/dist/server/_coffre/assets/{projects._project._environment-DdIOc7wx.js → projects._project._environment-D_5R40of.js} +4 -11
  67. package/dist/server/_coffre/assets/{projects._project.index-CuEAUwGn.js → projects._project.index-A2BImFIT.js} +134 -96
  68. package/dist/server/_coffre/assets/{projects._project.index-DvbcU1kh.js → projects._project.index-BPPKxKrt.js} +5 -4
  69. package/dist/server/_coffre/assets/{projects.index-5HI0wOuG.js → projects.index-543IsPzY.js} +57 -55
  70. package/dist/server/_coffre/assets/{react-dom-qCTiwGGR.js → react-dom-bBoJXlK2.js} +417 -51
  71. package/dist/server/_coffre/assets/{router-CQDoql8s.js → router-CM3vK8QO.js} +376 -92
  72. package/dist/server/_coffre/assets/row-state-XBtDoIA4.js +117 -0
  73. package/dist/server/_coffre/assets/{settings-BVz78wjP.js → settings-BLVU74ym.js} +8 -6
  74. package/dist/server/_coffre/assets/suspense-CzYTwxOj.js +602 -0
  75. package/dist/server/_coffre/assets/tokens._token-B-hBgwBW.js +10 -0
  76. package/dist/server/_coffre/assets/{tokens._token-CWs3Mtki.js → tokens._token-aubAUonP.js} +97 -79
  77. package/dist/server/_coffre/assets/{tokens.index-Ck0LN7aC.js → tokens.index-4D3jwp5v.js} +9 -6
  78. package/dist/server/_coffre/assets/{ui-D_slKpSF.js → ui-BI3Bf72q.js} +7 -836
  79. package/dist/server/_coffre/assets/{unregistered-Z17da4Rc.js → unregistered-CagDxMyw.js} +5 -3
  80. package/dist/server/_coffre/assets/use-action-tzBZvjjQ.js +47 -0
  81. package/dist/server/_coffre/assets/use-change-Dggqxy5y.js +1212 -0
  82. package/dist/server/_coffre/assets/use-shell-CwStDfzX.js +462 -0
  83. package/dist/server/_coffre/assets/useQuery-C6_dBjem.js +8 -0
  84. package/dist/server/_coffre/assets/{useStore-DWGPqzXR.js → useRouter-CaUSUNsw.js} +1 -420
  85. package/dist/server/_coffre/assets/useSuspenseQuery-BuapQt_P.js +117 -0
  86. package/dist/server/_coffre/assets/{users._user-CMwj-VI9.js → users._user-137WNyxn.js} +4 -5
  87. package/dist/server/_coffre/assets/users._user-C252Iilj.js +10 -0
  88. package/dist/server/_coffre/assets/{users.index-fWHv6A30.js → users.index-DQHsfnal.js} +9 -6
  89. package/dist/server/index.js +6 -5
  90. package/package.json +5 -3
  91. package/src/components/directory.tsx +75 -104
  92. package/src/components/grants.tsx +60 -112
  93. package/src/components/principal-page.tsx +54 -67
  94. package/src/components/principal-picker.tsx +7 -16
  95. package/src/components/row-state.tsx +95 -0
  96. package/src/components/service-tokens.tsx +75 -64
  97. package/src/components/shell.tsx +1 -1
  98. package/src/components/syncs.tsx +42 -26
  99. package/src/lib/announce.ts +36 -0
  100. package/src/lib/changes.ts +498 -0
  101. package/src/lib/optimistic.ts +233 -0
  102. package/src/lib/queries.ts +393 -0
  103. package/src/lib/use-action.ts +20 -15
  104. package/src/lib/use-change.ts +42 -0
  105. package/src/lib/use-shell.ts +17 -0
  106. package/src/router.tsx +17 -9
  107. package/src/routes/__root.tsx +8 -38
  108. package/src/routes/account.tsx +163 -154
  109. package/src/routes/audit.tsx +51 -72
  110. package/src/routes/auth.device.tsx +4 -2
  111. package/src/routes/login.tsx +3 -2
  112. package/src/routes/projects.$project.$environment.tsx +226 -231
  113. package/src/routes/projects.$project.index.tsx +136 -118
  114. package/src/routes/projects.index.tsx +117 -145
  115. package/src/routes/settings.tsx +7 -7
  116. package/src/routes/tokens.$token.tsx +14 -17
  117. package/src/routes/tokens.index.tsx +8 -4
  118. package/src/routes/unregistered.tsx +3 -2
  119. package/src/routes/users.$user.tsx +4 -4
  120. package/src/routes/users.index.tsx +8 -4
  121. package/src/styles/globals.css +78 -1
  122. package/dist/client/_coffre/assets/account-B48wuSF8.js +0 -1
  123. package/dist/client/_coffre/assets/account-BkNyIDT7.js +0 -2
  124. package/dist/client/_coffre/assets/affordances-CmoY-8Xf.js +0 -1
  125. package/dist/client/_coffre/assets/audit-BvwKYb-5.js +0 -2
  126. package/dist/client/_coffre/assets/audit-D02H-zxS.js +0 -1
  127. package/dist/client/_coffre/assets/auth.device-DYOONgFF.js +0 -2
  128. package/dist/client/_coffre/assets/coffre-BBp7cKVa.js +0 -1
  129. package/dist/client/_coffre/assets/directory-Bu0EIxqI.js +0 -1
  130. package/dist/client/_coffre/assets/globals-Bh2x1gBM.css +0 -1
  131. package/dist/client/_coffre/assets/grants-DavcwofW.js +0 -1
  132. package/dist/client/_coffre/assets/index-CDPlq5rM.js +0 -12
  133. package/dist/client/_coffre/assets/login-C-wTm_t1.js +0 -2
  134. package/dist/client/_coffre/assets/login-CLLv1om9.js +0 -1
  135. package/dist/client/_coffre/assets/offboarding-DWsE2FSa.js +0 -1
  136. package/dist/client/_coffre/assets/page-DbSS7pYH.js +0 -1
  137. package/dist/client/_coffre/assets/preload-helper-DduCCcmc.js +0 -46
  138. package/dist/client/_coffre/assets/principal-page-Bp_iwuSd.js +0 -1
  139. package/dist/client/_coffre/assets/projects._project._environment-BMeX_B8l.js +0 -2
  140. package/dist/client/_coffre/assets/projects._project._environment-CT0A-hIU.js +0 -3
  141. package/dist/client/_coffre/assets/projects._project.index-C_xYOGLT.js +0 -2
  142. package/dist/client/_coffre/assets/projects._project.index-Chcf-cUd.js +0 -1
  143. package/dist/client/_coffre/assets/projects.index-CfOtb1X5.js +0 -2
  144. package/dist/client/_coffre/assets/projects.index-DSjOhLDh.js +0 -1
  145. package/dist/client/_coffre/assets/settings-BC9cUJNK.js +0 -1
  146. package/dist/client/_coffre/assets/settings-Bkj_E21y.js +0 -2
  147. package/dist/client/_coffre/assets/tokens._token-BA0KqvaW.js +0 -1
  148. package/dist/client/_coffre/assets/tokens._token-Dh9jLOkm.js +0 -2
  149. package/dist/client/_coffre/assets/tokens.index-BgAMWkHT.js +0 -2
  150. package/dist/client/_coffre/assets/tokens.index-CHueIAv1.js +0 -1
  151. package/dist/client/_coffre/assets/unregistered-D5go1AfR.js +0 -1
  152. package/dist/client/_coffre/assets/use-action-l__xZDYY.js +0 -1
  153. package/dist/client/_coffre/assets/users._user-Dwqa0gv5.js +0 -1
  154. package/dist/client/_coffre/assets/users._user-xJAb3T6Y.js +0 -2
  155. package/dist/client/_coffre/assets/users.index-BJoF-L37.js +0 -2
  156. package/dist/client/_coffre/assets/users.index-YUjtbTGy.js +0 -1
  157. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-BKg2AlPu.js +0 -133
  158. package/dist/server/_coffre/assets/audit-CThXn2v7.js +0 -74
  159. package/dist/server/_coffre/assets/coffre-C2ANsTAz.js +0 -281
  160. package/dist/server/_coffre/assets/globals-Bh2x1gBM.css +0 -1
  161. package/dist/server/_coffre/assets/grants-B6k4Fu9z.js +0 -243
  162. package/dist/server/_coffre/assets/projects.index-uiomWX_l.js +0 -54
  163. package/dist/server/_coffre/assets/settings-4oRyDizv.js +0 -18
  164. package/dist/server/_coffre/assets/tokens._token-CF_deAwq.js +0 -18
  165. package/dist/server/_coffre/assets/tokens.index-DF_07KEe.js +0 -10
  166. package/dist/server/_coffre/assets/users._user-DUzwkSKT.js +0 -10
  167. package/dist/server/_coffre/assets/users.index-BbuweTwH.js +0 -10
@@ -1,13 +1,20 @@
1
- import { C as require_react, E as __toESM, i as useRouter, o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
2
- import { E as Link, a as ErrorLine, c as Spinner, h as dropdown_menu_exports, i as EmptyState, n as ConfirmDialog, o as Modal, s as Notice } from "./ui-D_slKpSF.js";
3
- import { B as Search, C as Key, F as Pencil, L as Plus, M as MoreHorizontal, Q as Users, V as Settings, X as User, i as PageHeader, l as Archive, n as ClosedDoor, t as Card, tt as useLoaderData, u as Check, v as Folder, w as Layers, z as RotateBack } from "./page-BdnhpwvH.js";
4
- import { s as useCoffre, t as Refusal } from "./coffre-C2ANsTAz.js";
5
- import { r as toast, t as useAction } from "./use-action-DwEmf58L.js";
1
+ import { i as require_react, r as require_jsx_runtime, s as __toESM, t as useRouter } from "./useRouter-CaUSUNsw.js";
2
+ import { t as Link } from "./link-42ZWdjzZ.js";
3
+ import { C as useCoffre, c as keys, h as queries, i as PageHeader, m as projectOf, n as ClosedDoor, o as affects, t as Card } from "./page-D_mO0-sn.js";
4
+ import { D as projectAccessOptions, E as projectAccessLabel, T as parseProjectAccess, _ as renameEnvironment, d as environmentId, f as grantAccess, i as archiveEnvironment, n as useChangeStatus, p as grantId, s as createEnvironment, t as useChange } from "./use-change-Dggqxy5y.js";
5
+ import { t as useShell } from "./use-shell-CwStDfzX.js";
6
+ import { t as useSuspenseQuery } from "./useSuspenseQuery-BuapQt_P.js";
7
+ import { t as useQuery } from "./useQuery-C6_dBjem.js";
8
+ import { n as toast } from "./dist-CnnV3t2g.js";
9
+ import { a as ErrorLine, c as Spinner, h as dropdown_menu_exports, i as EmptyState, n as ConfirmDialog, o as Modal, s as Notice } from "./ui-BI3Bf72q.js";
6
10
  import { t as hasEnvironmentDetails } from "./project-environments-lEzFHUt4.js";
7
- import { c as PrincipalLink, i as KIND, o as loadDirectory, s as PrincipalAvatar } from "./directory-GsnYkse0.js";
8
- import { a as parseProjectAccess, n as GrantsTable, o as projectAccessLabel, r as ensureGrant, s as projectAccessOptions, t as GrantRowView } from "./grants-B6k4Fu9z.js";
9
- import { t as Route } from "./projects._project.index-DvbcU1kh.js";
11
+ import { A as Pencil, D as MoreHorizontal, F as Search, G as User, I as Settings, M as Plus, P as RotateBack, a as Check, i as Archive, p as Folder, q as Users, v as Key, y as Layers } from "./icons-Dy-5ccDF.js";
12
+ import { a as rowClass, i as RowPending, t as ItemFailure } from "./row-state-XBtDoIA4.js";
13
+ import { t as Route } from "./projects._project.index-BPPKxKrt.js";
14
+ import { i as KIND, o as PrincipalAvatar, s as PrincipalLink } from "./directory-CyYx6Jx1.js";
15
+ import { t as useAction } from "./use-action-tzBZvjjQ.js";
10
16
  import { n as slugProblem } from "./validation-BQtqPe2V.js";
17
+ import { i as useRefusedGrants, n as GrantsTable, r as RefusedGrants, t as GrantRowView } from "./grants-CRijabX0.js";
11
18
  //#region src/components/principal-picker.tsx
12
19
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
13
20
  var import_jsx_runtime = require_jsx_runtime();
@@ -19,25 +26,16 @@ var import_jsx_runtime = require_jsx_runtime();
19
26
  * Only instance owners may list the directory. Asking on anyone else's behalf
20
27
  * would write a refusal to the audit log in their name, so they get a text
21
28
  * field and the server's answer instead. The list is asked for when the
22
- * dialog opens rather than with the page, since most visits never open it.
29
+ * dialog opens rather than with the page, since most visits never open it,
30
+ * and shared with the Users and Tokens pages through the cache.
23
31
  */
24
32
  function PrincipalPicker({ principalType, canList, grants, value, onChange }) {
25
33
  const coffre = useCoffre();
26
- const [directory, setDirectory] = (0, import_react.useState)(null);
34
+ const directory = useQuery(queries.directory(coffre, canList)).data ?? null;
27
35
  const [query, setQuery] = (0, import_react.useState)("");
28
36
  const name = (0, import_react.useId)();
29
37
  const kind = KIND[principalType];
30
38
  const label = principalType === "user" ? "User" : "Token";
31
- (0, import_react.useEffect)(() => {
32
- if (!canList) return;
33
- let live = true;
34
- loadDirectory(coffre, true).then((result) => {
35
- if (live) setDirectory(result);
36
- });
37
- return () => {
38
- live = false;
39
- };
40
- }, [canList, coffre]);
41
39
  if (!canList || directory?.ok === false) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
42
40
  className: "field",
43
41
  children: [
@@ -209,9 +207,9 @@ var TABS = [
209
207
  }
210
208
  ];
211
209
  function ProjectPage() {
212
- const result = Route.useLoaderData();
213
210
  const { project: projectSlug } = Route.useParams();
214
- const search = Route.useSearch();
211
+ const { data: projects } = useSuspenseQuery(queries.projects(useCoffre()));
212
+ const result = projectOf(projects, projectSlug);
215
213
  if (!result.ok) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClosedDoor, {
216
214
  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Folder, { size: 18 }),
217
215
  label: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
@@ -226,7 +224,27 @@ function ProjectPage() {
226
224
  }),
227
225
  children: result.error ?? "There is no such project, or you hold no grant on it. The two look the same on purpose: an answer that told them apart would let anyone list project names."
228
226
  });
229
- const { project, grants, grantsError } = result;
227
+ return result.managesAccess ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ManagedProject, { project: result.project }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProjectView, {
228
+ project: result.project,
229
+ grants: [],
230
+ grantsError: null
231
+ });
232
+ }
233
+ /** A project whose access you manage, with its grants. */
234
+ function ManagedProject({ project }) {
235
+ const { data: result } = useSuspenseQuery(queries.grants(useCoffre(), project.slug));
236
+ return result.ok ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProjectView, {
237
+ project,
238
+ grants: result.grants,
239
+ grantsError: null
240
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProjectView, {
241
+ project,
242
+ grants: [],
243
+ grantsError: result.error
244
+ });
245
+ }
246
+ function ProjectView({ project, grants, grantsError }) {
247
+ const search = Route.useSearch();
230
248
  const canManageProject = project.permissions.includes("project.manage");
231
249
  const canManageEnvironments = project.permissions.includes("environment.manage");
232
250
  const canManageGrants = project.permissions.includes("grant.manage");
@@ -288,20 +306,41 @@ function ProjectPage() {
288
306
  function EnvironmentsPanel({ project, canManage }) {
289
307
  const archived = project.environments.filter(hasEnvironmentDetails).filter((environment) => environment.details.archivedAt !== null);
290
308
  const current = project.environments.filter((environment) => environment.details === null || environment.details.archivedAt === null);
291
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [current.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
309
+ const { failedAdds, dismiss } = useChangeStatus(keys.projects);
310
+ const refused = failedAdds(project.environments.map((environment) => environmentId(project.slug, environment.slug))).filter(({ ids }) => ids.every((id) => id.startsWith(`${project.slug}/`)));
311
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [current.length === 0 && refused.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
292
312
  className: "card",
293
313
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, {
294
314
  title: "No environments yet",
295
315
  children: canManage ? "Add the first with Add environment." : "Creating environments needs environment.manage on this project."
296
316
  })
297
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
317
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", {
298
318
  className: "env-grid",
299
319
  "aria-label": "Environments",
300
- children: current.map((environment) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EnvironmentCard, {
320
+ children: [current.map((environment) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EnvironmentCard, {
301
321
  project: project.slug,
302
322
  environment,
303
323
  isAdmin: canManage
304
- }) }, `${project.slug}:${environment.slug}`))
324
+ }) }, `${project.slug}:${environment.slug}`)), refused.map(({ mutationId, vars, status }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
325
+ className: "env-card is-muted is-failed",
326
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
327
+ className: "env-card-text",
328
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
329
+ className: "env-card-name",
330
+ children: vars.name
331
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
332
+ className: "env-card-meta",
333
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
334
+ className: "mono",
335
+ children: vars.slug
336
+ })
337
+ })]
338
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFailure, {
339
+ status,
340
+ onDismiss: () => dismiss(mutationId),
341
+ children: "Not added."
342
+ })]
343
+ }) }, mutationId))]
305
344
  }), archived.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
306
345
  "aria-labelledby": "archived-environments",
307
346
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
@@ -328,18 +367,19 @@ function EnvironmentCard({ project, environment, isAdmin }) {
328
367
  const [slug, setSlug] = (0, import_react.useState)(environment.slug);
329
368
  const [name, setName] = (0, import_react.useState)(environment.name);
330
369
  const coffre = useCoffre();
331
- const { pending, error, setError, run } = useAction();
370
+ const rename = useChange(renameEnvironment(coffre, project));
371
+ const archive = useChange(archiveEnvironment(coffre, project));
372
+ const { status, dismiss } = useChangeStatus(keys.projects);
373
+ const state = status(environmentId(project, environment.slug));
374
+ const pending = state.state === "pending";
332
375
  const details = environment.details;
333
376
  const isArchived = details !== null && details.archivedAt !== null;
334
377
  const secretCount = details?.secretCount ?? null;
335
- const opens = details !== null && !isArchived && environment.accessible;
378
+ const opens = details !== null && !isArchived && environment.accessible && !pending;
336
379
  const manageable = isAdmin && details !== null;
337
380
  const slugError = slug === "" ? null : slugProblem(slug);
338
- (0, import_react.useEffect)(() => {
339
- if (error !== null && !renaming) toast.error(error);
340
- }, [error, renaming]);
341
381
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
342
- className: `env-card${opens ? " is-link" : " is-muted"}`,
382
+ className: `env-card${opens ? " is-link" : " is-muted"} ${rowClass(state)}`,
343
383
  children: [
344
384
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
345
385
  className: "env-card-text",
@@ -362,7 +402,7 @@ function EnvironmentCard({ project, environment, isAdmin }) {
362
402
  }), isArchived ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
363
403
  className: "tag tag-red",
364
404
  children: "archived"
365
- }) : !environment.accessible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
405
+ }) : !environment.accessible && !pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
366
406
  className: "tag tag-outline",
367
407
  children: "no secret access"
368
408
  }) : secretCount !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
@@ -372,13 +412,13 @@ function EnvironmentCard({ project, environment, isAdmin }) {
372
412
  ] })]
373
413
  })]
374
414
  }),
375
- manageable && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Root, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(dropdown_menu_exports.Trigger, {
415
+ pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowPending, { status: state }),
416
+ manageable && !pending && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Root, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(dropdown_menu_exports.Trigger, {
376
417
  asChild: true,
377
418
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
378
419
  className: "act act-quiet env-card-menu",
379
420
  "aria-label": `Actions for ${environment.slug}`,
380
- disabled: pending,
381
- children: pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreHorizontal, { size: 16 })
421
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreHorizontal, { size: 16 })
382
422
  })
383
423
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(dropdown_menu_exports.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Content, {
384
424
  className: "menu",
@@ -404,10 +444,7 @@ function EnvironmentCard({ project, environment, isAdmin }) {
404
444
  }) })] }),
405
445
  manageable && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Modal, {
406
446
  open: renaming,
407
- onOpenChange: (open) => {
408
- setRenaming(open);
409
- if (!open) setError(null);
410
- },
447
+ onOpenChange: setRenaming,
411
448
  title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
412
449
  "Rename",
413
450
  " ",
@@ -424,13 +461,12 @@ function EnvironmentCard({ project, environment, isAdmin }) {
424
461
  className: "form",
425
462
  onSubmit: (event) => {
426
463
  event.preventDefault();
427
- run(() => coffre.environments.update(`${project}/${environment.slug}`, {
464
+ rename({
465
+ from: environment.slug,
428
466
  slug,
429
- name
430
- }), () => {
431
- setRenaming(false);
432
- toast.success("Environment renamed");
467
+ name: name.trim()
433
468
  });
469
+ setRenaming(false);
434
470
  },
435
471
  children: [
436
472
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
@@ -465,7 +501,6 @@ function EnvironmentCard({ project, environment, isAdmin }) {
465
501
  onChange: (event) => setName(event.target.value)
466
502
  })]
467
503
  }),
468
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
469
504
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
470
505
  className: "dialog-actions",
471
506
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
@@ -473,11 +508,11 @@ function EnvironmentCard({ project, environment, isAdmin }) {
473
508
  type: "button",
474
509
  onClick: () => setRenaming(false),
475
510
  children: "Cancel"
476
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
511
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
477
512
  className: "btn btn-primary",
478
513
  type: "submit",
479
- disabled: pending || slug === "" || slugError !== null || name.trim() === "",
480
- children: [pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Save"]
514
+ disabled: slug === "" || slugError !== null || name.trim() === "",
515
+ children: "Save"
481
516
  })]
482
517
  })
483
518
  ]
@@ -526,8 +561,15 @@ function EnvironmentCard({ project, environment, isAdmin }) {
526
561
  ] }),
527
562
  confirmLabel: isArchived ? "Restore environment" : "Archive environment",
528
563
  destructive: !isArchived,
529
- onConfirm: () => run(() => coffre.environments.update(`${project}/${environment.slug}`, { archived: !isArchived }), () => toast.success(isArchived ? `${environment.slug} restored` : `${environment.slug} archived`))
530
- })] })
564
+ onConfirm: () => archive({
565
+ slug: environment.slug,
566
+ archived: !isArchived
567
+ })
568
+ })] }),
569
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFailure, {
570
+ status: state,
571
+ onDismiss: () => state.state === "failed" && dismiss(state.mutationId)
572
+ })
531
573
  ]
532
574
  });
533
575
  }
@@ -535,12 +577,10 @@ function NewEnvironment({ project }) {
535
577
  const [open, setOpen] = (0, import_react.useState)(false);
536
578
  const [slug, setSlug] = (0, import_react.useState)("");
537
579
  const [name, setName] = (0, import_react.useState)("");
538
- const coffre = useCoffre();
539
- const { pending, error, setError, run } = useAction();
580
+ const create = useChange(createEnvironment(useCoffre(), project));
540
581
  const slugError = slug === "" ? null : slugProblem(slug);
541
582
  function close() {
542
583
  setOpen(false);
543
- setError(null);
544
584
  }
545
585
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
546
586
  className: "btn btn-primary",
@@ -557,15 +597,13 @@ function NewEnvironment({ project }) {
557
597
  className: "form",
558
598
  onSubmit: (event) => {
559
599
  event.preventDefault();
560
- run(async () => {
561
- const { created } = await coffre.environments.create(`${project}/${slug}`, { name });
562
- if (!created) throw new Refusal(`An environment named "${slug}" already exists.`);
563
- }, () => {
564
- toast.success(`Environment ${slug} added`);
565
- setSlug("");
566
- setName("");
567
- close();
600
+ create({
601
+ slug,
602
+ name: name.trim()
568
603
  });
604
+ setSlug("");
605
+ setName("");
606
+ close();
569
607
  },
570
608
  children: [
571
609
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
@@ -615,7 +653,6 @@ function NewEnvironment({ project }) {
615
653
  onChange: (event) => setName(event.target.value)
616
654
  })]
617
655
  }),
618
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
619
656
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
620
657
  className: "dialog-actions",
621
658
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
@@ -623,11 +660,11 @@ function NewEnvironment({ project }) {
623
660
  type: "button",
624
661
  onClick: close,
625
662
  children: "Cancel"
626
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
663
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
627
664
  className: "btn btn-primary",
628
665
  type: "submit",
629
- disabled: pending || slug === "" || slugError !== null || name.trim() === "",
630
- children: [pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Add environment"]
666
+ disabled: slug === "" || slugError !== null || name.trim() === "",
667
+ children: "Add environment"
631
668
  })]
632
669
  })
633
670
  ]
@@ -636,22 +673,23 @@ function NewEnvironment({ project }) {
636
673
  }
637
674
  function AccessPanel({ principalType, project, grants }) {
638
675
  const people = principalType === "user";
676
+ const refused = useRefusedGrants(project, grants, principalType);
639
677
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", {
640
678
  className: "card",
641
679
  "aria-label": people ? "Users with access" : "Tokens with access",
642
- children: grants.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyState, {
680
+ children: grants.length === 0 && refused.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyState, {
643
681
  title: people ? "No user has access" : "No token has access",
644
682
  children: [
645
683
  "Add ",
646
684
  people ? "a user" : "a token",
647
685
  " with permissions on the whole project or on one environment."
648
686
  ]
649
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GrantsTable, {
687
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(GrantsTable, {
650
688
  lead: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
651
689
  className: "th",
652
690
  children: [people ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(User, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Key, { size: 14 }), people ? "Email" : "Name"]
653
691
  }),
654
- children: grants.map((grant, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GrantRowView, {
692
+ children: [grants.map((grant, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GrantRowView, {
655
693
  number: index + 1,
656
694
  project,
657
695
  grant,
@@ -660,23 +698,21 @@ function AccessPanel({ principalType, project, grants }) {
660
698
  type: grant.principalType,
661
699
  id: grant.principalId
662
700
  })
663
- }, grant.id))
701
+ }, grantId(grant))), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RefusedGrants, { refused })]
664
702
  })
665
703
  });
666
704
  }
667
705
  function NewGrant({ principalType, project, environments, grants }) {
668
- const { capabilities } = useLoaderData({ from: "__root__" });
706
+ const { capabilities } = useShell();
669
707
  const [open, setOpen] = (0, import_react.useState)(false);
670
708
  const [principalId, setPrincipalId] = (0, import_react.useState)("");
671
709
  const [permission, setPermission] = (0, import_react.useState)("viewer:");
672
710
  const [expiresAt, setExpiresAt] = (0, import_react.useState)("");
673
- const coffre = useCoffre();
674
- const { pending, error, setError, run } = useAction();
711
+ const grant = useChange(grantAccess(useCoffre(), project));
675
712
  const permissionOptions = projectAccessOptions(environments);
676
713
  const kind = principalType === "user" ? "user" : "token";
677
714
  function close() {
678
715
  setOpen(false);
679
- setError(null);
680
716
  }
681
717
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
682
718
  className: "btn btn-primary",
@@ -705,21 +741,18 @@ function NewGrant({ principalType, project, environments, grants }) {
705
741
  onSubmit: (event) => {
706
742
  event.preventDefault();
707
743
  const access = parseProjectAccess(permission);
708
- run(() => ensureGrant(coffre, {
709
- project,
744
+ grant({
710
745
  principalType,
711
746
  principalId: principalId.trim(),
712
747
  role: access.role,
748
+ roleName: permissionOptions.find((option) => option.value === permission)?.label ?? access.role,
713
749
  environmentSlug: access.environmentSlug,
714
750
  expiresAt: expiresAt === "" ? null : (/* @__PURE__ */ new Date(`${expiresAt}T23:59:59Z`)).toISOString()
715
- }), ({ existed }) => {
716
- const label = permissionOptions.find((option) => option.value === permission)?.label ?? "access";
717
- toast.success(existed ? `${principalId} already has ${label}` : `${principalId} granted ${label.toLowerCase()}`);
718
- setPrincipalId("");
719
- setExpiresAt("");
720
- setPermission("viewer:");
721
- close();
722
751
  });
752
+ setPrincipalId("");
753
+ setExpiresAt("");
754
+ setPermission("viewer:");
755
+ close();
723
756
  },
724
757
  children: [
725
758
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalPicker, {
@@ -762,7 +795,6 @@ function NewGrant({ principalType, project, environments, grants }) {
762
795
  })]
763
796
  })]
764
797
  }),
765
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
766
798
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
767
799
  className: "dialog-actions",
768
800
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
@@ -770,11 +802,11 @@ function NewGrant({ principalType, project, environments, grants }) {
770
802
  type: "button",
771
803
  onClick: close,
772
804
  children: "Cancel"
773
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
805
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
774
806
  className: "btn btn-primary",
775
807
  type: "submit",
776
- disabled: pending || principalId.trim() === "",
777
- children: [pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Grant access"]
808
+ disabled: principalId.trim() === "",
809
+ children: "Grant access"
778
810
  })]
779
811
  })
780
812
  ]
@@ -816,13 +848,16 @@ function GeneralSettings({ project }) {
816
848
  run(() => coffre.projects.update(project.slug, {
817
849
  slug,
818
850
  name
819
- }), async () => {
820
- toast.success("Project renamed");
821
- if (slug !== project.slug) await router.navigate({
822
- to: "/projects/$project",
823
- params: { project: slug },
824
- search: { tab: "settings" }
825
- });
851
+ }), {
852
+ affects: affects.places(),
853
+ onSuccess: async () => {
854
+ toast.success("Project renamed");
855
+ if (slug !== project.slug) await router.navigate({
856
+ to: "/projects/$project",
857
+ params: { project: slug },
858
+ search: { tab: "settings" }
859
+ });
860
+ }
826
861
  });
827
862
  },
828
863
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
@@ -924,7 +959,10 @@ function DangerZone({ project }) {
924
959
  ] }),
925
960
  confirmLabel: isArchived ? "Restore project" : "Archive project",
926
961
  destructive: !isArchived,
927
- onConfirm: () => run(() => coffre.projects.update(project.slug, { archived: !isArchived }), () => toast.success(isArchived ? `${project.slug} restored` : `${project.slug} archived`))
962
+ onConfirm: () => run(() => coffre.projects.update(project.slug, { archived: !isArchived }), {
963
+ affects: affects.places(),
964
+ onSuccess: () => toast.success(isArchived ? `${project.slug} restored` : `${project.slug} archived`)
965
+ })
928
966
  })]
929
967
  });
930
968
  }
@@ -1,12 +1,13 @@
1
- import { C as lazyRouteComponent, w as createFileRoute } from "./ui-D_slKpSF.js";
2
- import { i as loadProject } from "./grants-B6k4Fu9z.js";
1
+ import { n as createFileRoute, t as lazyRouteComponent } from "./lazyRouteComponent-CqBNCGuZ.js";
2
+ import { d as loadProject } from "./page-D_mO0-sn.js";
3
3
  //#region src/routes/projects.$project.index.tsx
4
- var $$splitComponentImporter = () => import("./projects._project.index-CuEAUwGn.js");
4
+ var $$splitComponentImporter = () => import("./projects._project.index-A2BImFIT.js");
5
5
  var Route = createFileRoute("/projects/$project/")({
6
6
  validateSearch: (search) => ({ tab: search.tab === "users" || search.tab === "tokens" || search.tab === "settings" ? search.tab : void 0 }),
7
- loader: ({ context: { client }, params }) => loadProject(client, params.project),
7
+ loader: ({ context: { client, queryClient }, params }) => loadProject(queryClient, client, params.project),
8
8
  component: lazyRouteComponent($$splitComponentImporter, "component")
9
9
  });
10
+ /** A project whose access you manage, with its grants. */
10
11
  /**
11
12
  * One environment. The whole card opens it when you can; its menu sits above
12
13
  * that link.