@coffre/ui 0.2.0 → 0.4.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.
Files changed (177) 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/delete-place-CRX7ntE8.js +206 -0
  4. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  5. package/dist/chunks/{directory-CSjWWUQ1.js → directory-zr3ek7Mc.js} +175 -60
  6. package/dist/chunks/directory-zr3ek7Mc.js.map +1 -0
  7. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  8. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  9. package/dist/chunks/grants-Cw1FyGID.js +669 -0
  10. package/dist/chunks/grants-Cw1FyGID.js.map +1 -0
  11. package/dist/chunks/offboarding-CE6d7um1.js +305 -0
  12. package/dist/chunks/offboarding-CE6d7um1.js.map +1 -0
  13. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  14. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  15. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  16. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  17. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  18. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  19. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-DhjO76GH.js} +245 -251
  20. package/dist/chunks/principal-page-DhjO76GH.js.map +1 -0
  21. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  22. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  23. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  24. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  25. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  26. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  27. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  28. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  29. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  30. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  31. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  32. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  33. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  34. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  35. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  36. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  37. package/dist/chunks/{use-change-c6CeLRin.js → use-change-DUiGO19U.js} +52 -21
  38. package/dist/chunks/use-change-DUiGO19U.js.map +1 -0
  39. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  40. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  41. package/dist/chunks/validation-D312_NLf.js +87 -0
  42. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  43. package/dist/index.d.ts +361 -27
  44. package/dist/index.js +188 -98
  45. package/dist/index.js.map +1 -1
  46. package/dist/pages/account.d.ts +2 -2
  47. package/dist/pages/account.js +297 -135
  48. package/dist/pages/account.js.map +1 -1
  49. package/dist/pages/approval.d.ts +9 -0
  50. package/dist/pages/approval.js +207 -0
  51. package/dist/pages/approval.js.map +1 -0
  52. package/dist/pages/audit.js +17 -542
  53. package/dist/pages/audit.js.map +1 -1
  54. package/dist/pages/device-login.js +2 -3
  55. package/dist/pages/device-login.js.map +1 -1
  56. package/dist/pages/environment.js +647 -257
  57. package/dist/pages/environment.js.map +1 -1
  58. package/dist/pages/login.js +18 -7
  59. package/dist/pages/login.js.map +1 -1
  60. package/dist/pages/oauth-authorize.d.ts +10 -0
  61. package/dist/pages/oauth-authorize.js +249 -0
  62. package/dist/pages/oauth-authorize.js.map +1 -0
  63. package/dist/pages/project-access.d.ts +6 -0
  64. package/dist/pages/project-access.js +370 -0
  65. package/dist/pages/project-access.js.map +1 -0
  66. package/dist/pages/project-environments.d.ts +4 -0
  67. package/dist/pages/project-environments.js +593 -0
  68. package/dist/pages/project-environments.js.map +1 -0
  69. package/dist/pages/project-settings.d.ts +4 -0
  70. package/dist/pages/project-settings.js +242 -0
  71. package/dist/pages/project-settings.js.map +1 -0
  72. package/dist/pages/project.d.ts +10 -2
  73. package/dist/pages/project.js +57 -934
  74. package/dist/pages/project.js.map +1 -1
  75. package/dist/pages/projects.js +53 -21
  76. package/dist/pages/projects.js.map +1 -1
  77. package/dist/pages/service-account.d.ts +10 -0
  78. package/dist/pages/{token.js → service-account.js} +115 -56
  79. package/dist/pages/service-account.js.map +1 -0
  80. package/dist/pages/service-accounts.d.ts +3 -0
  81. package/dist/pages/service-accounts.js +38 -0
  82. package/dist/pages/service-accounts.js.map +1 -0
  83. package/dist/pages/settings.d.ts +1 -0
  84. package/dist/pages/settings.js +104 -42
  85. package/dist/pages/settings.js.map +1 -1
  86. package/dist/pages/unregistered.js +2 -3
  87. package/dist/pages/unregistered.js.map +1 -1
  88. package/dist/pages/user.d.ts +6 -1
  89. package/dist/pages/user.js +18 -6
  90. package/dist/pages/user.js.map +1 -1
  91. package/dist/pages/users.js +6 -10
  92. package/dist/pages/users.js.map +1 -1
  93. package/package.json +3 -3
  94. package/src/components/actions-log.tsx +117 -0
  95. package/src/components/audit-sentence.tsx +55 -0
  96. package/src/components/command-palette.tsx +4 -4
  97. package/src/components/delete-place.tsx +180 -0
  98. package/src/components/directory.tsx +259 -110
  99. package/src/components/every-project.tsx +287 -0
  100. package/src/components/expiry-field.tsx +42 -0
  101. package/src/components/folders.tsx +219 -0
  102. package/src/components/grants.tsx +11 -4
  103. package/src/components/icons.tsx +2 -0
  104. package/src/components/missing.tsx +110 -0
  105. package/src/components/offboarding.tsx +61 -33
  106. package/src/components/page.tsx +4 -1
  107. package/src/components/principal-page.tsx +136 -106
  108. package/src/components/principal-picker.tsx +5 -5
  109. package/src/components/principal.tsx +4 -4
  110. package/src/components/references.tsx +323 -0
  111. package/src/components/service-tokens.tsx +115 -95
  112. package/src/components/shell.tsx +11 -32
  113. package/src/components/tabs.tsx +18 -0
  114. package/src/components/trusted-workloads.tsx +97 -79
  115. package/src/components/ui.tsx +8 -1
  116. package/src/index.ts +13 -2
  117. package/src/layout.tsx +2 -2
  118. package/src/lib/access-plan.ts +2 -2
  119. package/src/lib/audit-sentences.ts +161 -77
  120. package/src/lib/changes.ts +56 -5
  121. package/src/lib/coffre.ts +3 -2
  122. package/src/lib/one-time.ts +32 -0
  123. package/src/lib/project-access.ts +11 -23
  124. package/src/lib/project-page.ts +14 -0
  125. package/src/lib/queries.ts +126 -32
  126. package/src/lib/search.ts +25 -0
  127. package/src/lib/signin-errors.ts +45 -1
  128. package/src/lib/validation.ts +14 -0
  129. package/src/options.ts +187 -35
  130. package/src/pages/account.tsx +274 -129
  131. package/src/pages/approval.tsx +197 -0
  132. package/src/pages/audit.tsx +9 -61
  133. package/src/pages/environment.tsx +585 -286
  134. package/src/pages/login.tsx +8 -2
  135. package/src/pages/oauth-authorize.tsx +233 -0
  136. package/src/pages/project-access.tsx +219 -0
  137. package/src/pages/project-environments.tsx +582 -0
  138. package/src/pages/project-settings.tsx +259 -0
  139. package/src/pages/project.tsx +52 -879
  140. package/src/pages/projects.tsx +55 -18
  141. package/src/pages/service-account.tsx +50 -0
  142. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  143. package/src/pages/settings.tsx +62 -8
  144. package/src/pages/user.tsx +16 -4
  145. package/src/pages/users.tsx +2 -2
  146. package/src/parity.ts +160 -0
  147. package/src/register.ts +58 -9
  148. package/src/router.tsx +4 -0
  149. package/src/shared/models.ts +6 -2
  150. package/src/styles/globals.css +536 -31
  151. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  152. package/dist/chunks/grants-saMQagmG.js +0 -160
  153. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  154. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  155. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  156. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  157. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  158. package/dist/chunks/page-C5HcNqf2.js +0 -190
  159. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  160. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  161. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  162. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  163. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  164. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  165. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  166. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  167. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  168. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  169. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  170. package/dist/pages/token.d.ts +0 -3
  171. package/dist/pages/token.js.map +0 -1
  172. package/dist/pages/tokens.d.ts +0 -3
  173. package/dist/pages/tokens.js +0 -39
  174. package/dist/pages/tokens.js.map +0 -1
  175. package/dist/project-BqIy8gYR.d.ts +0 -5
  176. package/src/lib/instance.ts +0 -13
  177. package/src/pages/token.tsx +0 -34
@@ -1,221 +1,31 @@
1
- import { t as hasEnvironmentDetails } from "../chunks/project-environments-lEzFHUt4.js";
2
- import { a as ErrorLine, c as Notice, i as EmptyState, l as Spinner, n as ConfirmDialog, o as MenuPopup, s as Modal } from "../chunks/ui-DixXLQvQ.js";
3
- import { A as Pencil, F as Settings, H as User, N as RotateBack, O as MoreHorizontal, P as Search, W as Users, a as Check, i as Archive, j as Plus, p as Folder, v as Key, y as Layers } from "../chunks/icons-D-PfAfnH.js";
4
- import { i as PageHeader, n as ClosedDoor, t as Card, u as useCoffre } from "../chunks/page-C5HcNqf2.js";
5
- import { a as rowClass, i as RowPending, t as ItemFailure } from "../chunks/row-state-0PsrEzOL.js";
6
- import { l as projectOf, r as keys, t as affects, u as queries } from "../chunks/queries-CQ81o4so.js";
7
- import { t as useShell } from "../chunks/use-shell-jxd7Tzd-.js";
8
- import { D as projectAccessLabel, E as parseProjectAccess, O as projectAccessOptions, d as environmentId, f as grantAccess, i as archiveEnvironment, n as useChangeStatus, p as grantId, s as createEnvironment, t as useChange, v as renameEnvironment } from "../chunks/use-change-c6CeLRin.js";
9
- import { i as KIND, o as PrincipalAvatar, s as PrincipalLink } from "../chunks/directory-CSjWWUQ1.js";
1
+ import { t as useMounted } from "../chunks/mounted-jJmqqV_n.js";
2
+ import { c as Notice } from "../chunks/ui-DJje3gST.js";
3
+ import { A as Key, T as Folder, i as PageHeader, j as Layers, n as ClosedDoor, q as Settings, rt as Users, u as useCoffre } from "../chunks/page-DvsgZ2Hd.js";
4
+ import { f as projectOf, p as queries } from "../chunks/queries-DVR_i3rA.js";
10
5
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
11
- import { t as useAction } from "../chunks/use-action-CWsg_YWU.js";
12
- import { n as slugProblem } from "../chunks/validation-BQtqPe2V.js";
13
- import { i as useRefusedGrants, n as GrantsTable, r as RefusedGrants, t as GrantRowView } from "../chunks/grants-saMQagmG.js";
14
- import { useEffect, useId, useState } from "react";
15
- import { Link, useRouter } from "@tanstack/react-router";
16
- import { toast } from "sonner";
17
- import { Menu } from "@base-ui/react/menu";
18
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
- import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
20
- //#region src/components/principal-picker.tsx
21
- /**
22
- * Who a grant is for: picked from the registered users or tokens, each shown
23
- * with what it already holds on this project, or typed when the list is not
24
- * yours to read.
25
- *
26
- * Only instance owners may list the directory. Asking on anyone else's behalf
27
- * would write a refusal to the audit log in their name, so they get a text
28
- * field and the server's answer instead. The list is asked for when the
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.
31
- */
32
- function PrincipalPicker({ principalType, canList, grants, value, onChange }) {
33
- const coffre = useCoffre();
34
- const directory = useQuery(queries.directory(coffre, canList)).data ?? null;
35
- const [query, setQuery] = useState("");
36
- const name = useId();
37
- const kind = KIND[principalType];
38
- const label = principalType === "user" ? "User" : "Token";
39
- if (!canList || directory?.ok === false) return /* @__PURE__ */ jsxs("label", {
40
- className: "field",
41
- children: [
42
- /* @__PURE__ */ jsx("span", {
43
- className: "label",
44
- children: principalType === "user" ? "Email" : "Service token common name"
45
- }),
46
- /* @__PURE__ */ jsx("input", {
47
- className: "input input-mono",
48
- autoFocus: true,
49
- spellCheck: false,
50
- autoComplete: "off",
51
- placeholder: principalType === "user" ? "someone@acme.example" : "ci-deploy",
52
- value,
53
- onChange: (event) => onChange(event.target.value)
54
- }),
55
- /* @__PURE__ */ jsxs("span", {
56
- className: "hint",
57
- children: [
58
- "The ",
59
- kind,
60
- " must already be registered under ",
61
- principalType === "user" ? "Users" : "Tokens",
62
- "."
63
- ]
64
- })
65
- ]
66
- });
67
- const registered = directory?.principals.filter((principal) => principal.principalType === principalType) ?? [];
68
- const needle = query.trim().toLowerCase();
69
- const matches = registered.filter((principal) => principal.principalId.toLowerCase().includes(needle));
70
- return /* @__PURE__ */ jsxs("fieldset", {
71
- className: "field picker",
72
- children: [
73
- /* @__PURE__ */ jsx("legend", {
74
- className: "label",
75
- children: label
76
- }),
77
- /* @__PURE__ */ jsxs("label", {
78
- className: "input-group",
79
- children: [
80
- /* @__PURE__ */ jsxs("span", {
81
- className: "visually-hidden",
82
- children: [
83
- "Filter ",
84
- kind,
85
- "s by name"
86
- ]
87
- }),
88
- /* @__PURE__ */ jsx(Search, {
89
- size: 14,
90
- className: "input-icon"
91
- }),
92
- /* @__PURE__ */ jsx("input", {
93
- className: "input",
94
- type: "search",
95
- autoFocus: true,
96
- spellCheck: false,
97
- autoComplete: "off",
98
- placeholder: principalType === "user" ? "Filter by email…" : "Filter by name…",
99
- value: query,
100
- onChange: (event) => setQuery(event.target.value),
101
- onKeyDown: (event) => {
102
- if (event.key === "Enter" && matches.length === 1) {
103
- event.preventDefault();
104
- onChange(matches[0].principalId);
105
- }
106
- }
107
- })
108
- ]
109
- }),
110
- /* @__PURE__ */ jsx("div", {
111
- className: "picker-list",
112
- children: directory === null ? /* @__PURE__ */ jsxs("p", {
113
- className: "picker-empty",
114
- children: [
115
- /* @__PURE__ */ jsx(Spinner, { size: 13 }),
116
- "Loading ",
117
- kind,
118
- "s…"
119
- ]
120
- }) : registered.length === 0 ? /* @__PURE__ */ jsxs("p", {
121
- className: "picker-empty",
122
- children: [
123
- "No ",
124
- kind,
125
- "s are registered yet.",
126
- " ",
127
- /* @__PURE__ */ jsx(Link, {
128
- to: principalType === "user" ? "/users" : "/tokens",
129
- children: "Add one"
130
- }),
131
- " first."
132
- ]
133
- }) : matches.length === 0 ? /* @__PURE__ */ jsxs("p", {
134
- className: "picker-empty",
135
- children: [
136
- "No registered ",
137
- kind,
138
- " matches “",
139
- query.trim(),
140
- "”."
141
- ]
142
- }) : matches.map((principal) => {
143
- const held = grants.filter((grant) => grant.principalType === principalType && grant.principalId === principal.principalId).map(projectAccessLabel);
144
- const chosen = principal.principalId === value;
145
- return /* @__PURE__ */ jsxs("label", {
146
- className: `picker-option${chosen ? " is-chosen" : ""}`,
147
- children: [
148
- /* @__PURE__ */ jsx("input", {
149
- type: "radio",
150
- className: "visually-hidden",
151
- name,
152
- value: principal.principalId,
153
- checked: chosen,
154
- onChange: () => onChange(principal.principalId)
155
- }),
156
- /* @__PURE__ */ jsx(PrincipalAvatar, {
157
- type: principalType,
158
- id: principal.principalId
159
- }),
160
- /* @__PURE__ */ jsx("span", {
161
- className: "picker-name",
162
- children: principal.principalId
163
- }),
164
- held.length > 0 && /* @__PURE__ */ jsxs("span", {
165
- className: "picker-held",
166
- children: [/* @__PURE__ */ jsx("span", {
167
- className: "visually-hidden",
168
- children: "holds"
169
- }), held.map((access) => /* @__PURE__ */ jsx("span", {
170
- className: "tag",
171
- children: access
172
- }, access))]
173
- }),
174
- /* @__PURE__ */ jsx(Check, {
175
- size: 14,
176
- className: "picker-check"
177
- })
178
- ]
179
- }, principal.principalId);
180
- })
181
- })
182
- ]
183
- });
184
- }
185
- //#endregion
6
+ import { t as PageTabs } from "../chunks/tabs-BmwKfUeK.js";
7
+ import { Link, Outlet } from "@tanstack/react-router";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { useSuspenseQuery } from "@tanstack/react-query";
186
10
  //#region src/pages/project.tsx
187
11
  var Route = pageRoute();
188
- var TABS = [
189
- {
190
- key: "environments",
191
- label: "Environments",
192
- icon: /* @__PURE__ */ jsx(Layers, { size: 15 })
193
- },
194
- {
195
- key: "users",
196
- label: "Users",
197
- icon: /* @__PURE__ */ jsx(Users, { size: 15 })
198
- },
199
- {
200
- key: "tokens",
201
- label: "Tokens",
202
- icon: /* @__PURE__ */ jsx(Key, { size: 15 })
203
- },
204
- {
205
- key: "settings",
206
- label: "Settings",
207
- icon: /* @__PURE__ */ jsx(Settings, { size: 15 })
208
- }
209
- ];
210
- function ProjectPage() {
211
- const { project: projectSlug } = Route.useParams();
12
+ /**
13
+ * A project's page: its header, and its tabs, each a page of its own under
14
+ * this one. Each tab is gated on its own permission, not on one blanket
15
+ * "admin": an access manager can administer grants without being able to
16
+ * rename the project, and the other way round. A tab the deployment left
17
+ * out is not offered.
18
+ */
19
+ function ProjectLayout() {
20
+ const { project: slug } = Route.useParams();
21
+ const mounted = useMounted();
212
22
  const { data: projects } = useSuspenseQuery(queries.projects(useCoffre()));
213
- const result = projectOf(projects, projectSlug);
23
+ const result = projectOf(projects, slug);
214
24
  if (!result.ok) return /* @__PURE__ */ jsx(ClosedDoor, {
215
25
  icon: /* @__PURE__ */ jsx(Folder, { size: 18 }),
216
26
  label: /* @__PURE__ */ jsx("span", {
217
27
  className: "mono",
218
- children: projectSlug
28
+ children: slug
219
29
  }),
220
30
  title: "No project here for you",
221
31
  actions: /* @__PURE__ */ jsx(Link, {
@@ -225,744 +35,57 @@ function ProjectPage() {
225
35
  }),
226
36
  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."
227
37
  });
228
- return result.managesAccess ? /* @__PURE__ */ jsx(ManagedProject, { project: result.project }) : /* @__PURE__ */ jsx(ProjectView, {
229
- project: result.project,
230
- grants: [],
231
- grantsError: null
232
- });
233
- }
234
- /** A project whose access you manage, with its grants. */
235
- function ManagedProject({ project }) {
236
- const { data: result } = useSuspenseQuery(queries.grants(useCoffre(), project.slug));
237
- return result.ok ? /* @__PURE__ */ jsx(ProjectView, {
238
- project,
239
- grants: result.grants,
240
- grantsError: null
241
- }) : /* @__PURE__ */ jsx(ProjectView, {
242
- project,
243
- grants: [],
244
- grantsError: result.error
245
- });
246
- }
247
- function ProjectView({ project, grants, grantsError }) {
248
- const search = Route.useSearch();
249
- const canManageProject = project.permissions.includes("project.manage");
250
- const canManageEnvironments = project.permissions.includes("environment.manage");
251
- const canManageGrants = project.permissions.includes("grant.manage");
252
- const allowed = TABS.filter(({ key }) => key === "environments" || (key === "users" || key === "tokens") && canManageGrants || key === "settings" && canManageProject);
253
- const tab = allowed.find(({ key }) => key === search.tab)?.key ?? "environments";
254
- const principalType = tab === "users" ? "user" : "service";
255
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
38
+ const { project: found, managesAccess } = result;
39
+ const params = { project: found.slug };
40
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
256
41
  /* @__PURE__ */ jsx(PageHeader, {
257
- tile: project.slug,
258
- title: project.name,
42
+ tile: found.slug,
43
+ title: found.name,
259
44
  aside: /* @__PURE__ */ jsx("span", {
260
45
  className: "page-title-slug",
261
- children: project.slug
262
- }),
263
- actions: tab === "environments" ? canManageEnvironments && /* @__PURE__ */ jsx(NewEnvironment, { project: project.slug }) : (tab === "users" || tab === "tokens") && grantsError === null && /* @__PURE__ */ jsx(NewGrant, {
264
- principalType,
265
- project: project.slug,
266
- environments: project.environments,
267
- grants
46
+ children: found.slug
268
47
  })
269
48
  }),
270
- project.archivedAt !== null && /* @__PURE__ */ jsx("div", {
49
+ found.archivedAt !== null && /* @__PURE__ */ jsx("div", {
271
50
  style: { marginBottom: "1.25rem" },
272
51
  children: /* @__PURE__ */ jsxs(Notice, {
273
52
  tone: "bad",
274
53
  children: [/* @__PURE__ */ jsx("strong", { children: "This project is archived." }), " Its environments serve no reads, to people or to machines, until it is restored."]
275
54
  })
276
55
  }),
277
- allowed.length > 1 && /* @__PURE__ */ jsx("nav", {
278
- className: "tabs",
279
- "aria-label": "Project sections",
280
- children: allowed.map(({ key, label, icon }) => /* @__PURE__ */ jsxs(Link, {
281
- to: "/projects/$project",
282
- params: { project: project.slug },
283
- search: { tab: key === "environments" ? void 0 : key },
284
- activeOptions: {
285
- exact: true,
286
- explicitUndefined: true
287
- },
288
- "aria-current": key === tab ? "page" : void 0,
289
- children: [icon, label]
290
- }, key))
291
- }),
292
- tab === "environments" && /* @__PURE__ */ jsx(EnvironmentsPanel, {
293
- project,
294
- canManage: canManageEnvironments
295
- }),
296
- (tab === "users" || tab === "tokens") && (grantsError !== null ? /* @__PURE__ */ jsx(Notice, {
297
- tone: "bad",
298
- children: grantsError
299
- }) : /* @__PURE__ */ jsx(AccessPanel, {
300
- principalType,
301
- project: project.slug,
302
- grants: grants.filter((grant) => grant.principalType === principalType)
303
- })),
304
- tab === "settings" && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(GeneralSettings, { project }), /* @__PURE__ */ jsx(DangerZone, { project })] })
305
- ] });
306
- }
307
- function EnvironmentsPanel({ project, canManage }) {
308
- const archived = project.environments.filter(hasEnvironmentDetails).filter((environment) => environment.details.archivedAt !== null);
309
- const current = project.environments.filter((environment) => environment.details === null || environment.details.archivedAt === null);
310
- const { failedAdds, dismiss } = useChangeStatus(keys.projects);
311
- const refused = failedAdds(project.environments.map((environment) => environmentId(project.slug, environment.slug))).filter(({ ids }) => ids.every((id) => id.startsWith(`${project.slug}/`)));
312
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [current.length === 0 && refused.length === 0 ? /* @__PURE__ */ jsx("div", {
313
- className: "card",
314
- children: /* @__PURE__ */ jsx(EmptyState, {
315
- title: "No environments yet",
316
- children: canManage ? "Add the first with Add environment." : "Creating environments needs environment.manage on this project."
317
- })
318
- }) : /* @__PURE__ */ jsxs("ul", {
319
- className: "env-grid",
320
- "aria-label": "Environments",
321
- children: [current.map((environment) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(EnvironmentCard, {
322
- project: project.slug,
323
- environment,
324
- isAdmin: canManage
325
- }) }, `${project.slug}:${environment.slug}`)), refused.map(({ mutationId, vars, status }) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", {
326
- className: "env-card is-muted is-failed",
327
- children: [/* @__PURE__ */ jsxs("div", {
328
- className: "env-card-text",
329
- children: [/* @__PURE__ */ jsx("span", {
330
- className: "env-card-name",
331
- children: vars.name
332
- }), /* @__PURE__ */ jsx("span", {
333
- className: "env-card-meta",
334
- children: /* @__PURE__ */ jsx("span", {
335
- className: "mono",
336
- children: vars.slug
337
- })
338
- })]
339
- }), /* @__PURE__ */ jsx(ItemFailure, {
340
- status,
341
- onDismiss: () => dismiss(mutationId),
342
- children: "Not added."
343
- })]
344
- }) }, mutationId))]
345
- }), archived.length > 0 && /* @__PURE__ */ jsxs("section", {
346
- "aria-labelledby": "archived-environments",
347
- children: [/* @__PURE__ */ jsx("h2", {
348
- className: "section-title",
349
- id: "archived-environments",
350
- children: "Archived"
351
- }), /* @__PURE__ */ jsx("ul", {
352
- className: "env-grid",
353
- children: archived.map((environment) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(EnvironmentCard, {
354
- project: project.slug,
355
- environment,
356
- isAdmin: canManage
357
- }) }, environment.slug))
358
- })]
359
- })] });
360
- }
361
- /**
362
- * One environment. The whole card opens it when you can; its menu sits above
363
- * that link.
364
- */
365
- function EnvironmentCard({ project, environment, isAdmin }) {
366
- const [renaming, setRenaming] = useState(false);
367
- const [confirming, setConfirming] = useState(false);
368
- const [slug, setSlug] = useState(environment.slug);
369
- const [name, setName] = useState(environment.name);
370
- const coffre = useCoffre();
371
- const rename = useChange(renameEnvironment(coffre, project));
372
- const archive = useChange(archiveEnvironment(coffre, project));
373
- const { status, dismiss } = useChangeStatus(keys.projects);
374
- const state = status(environmentId(project, environment.slug));
375
- const pending = state.state === "pending";
376
- const details = environment.details;
377
- const isArchived = details !== null && details.archivedAt !== null;
378
- const secretCount = details?.secretCount ?? null;
379
- const opens = details !== null && !isArchived && environment.accessible && !pending;
380
- const manageable = isAdmin && details !== null;
381
- const slugError = slug === "" ? null : slugProblem(slug);
382
- return /* @__PURE__ */ jsxs("div", {
383
- className: `env-card${opens ? " is-link" : " is-muted"} ${rowClass(state)}`,
384
- children: [
385
- /* @__PURE__ */ jsxs("div", {
386
- className: "env-card-text",
387
- children: [opens ? /* @__PURE__ */ jsx(Link, {
388
- className: "env-card-name stretch",
389
- to: "/projects/$project/$environment",
390
- params: {
391
- project,
392
- environment: environment.slug
393
- },
394
- children: environment.name
395
- }) : /* @__PURE__ */ jsx("span", {
396
- className: "env-card-name",
397
- children: environment.name
398
- }), /* @__PURE__ */ jsxs("span", {
399
- className: "env-card-meta",
400
- children: [/* @__PURE__ */ jsx("span", {
401
- className: "mono",
402
- children: environment.slug
403
- }), isArchived ? /* @__PURE__ */ jsx("span", {
404
- className: "tag tag-red",
405
- children: "archived"
406
- }) : !environment.accessible && !pending ? /* @__PURE__ */ jsx("span", {
407
- className: "tag tag-outline",
408
- children: "no secret access"
409
- }) : secretCount !== null && /* @__PURE__ */ jsxs("span", { children: [
410
- secretCount,
411
- " secret",
412
- secretCount === 1 ? "" : "s"
413
- ] })]
414
- })]
415
- }),
416
- pending && /* @__PURE__ */ jsx(RowPending, { status: state }),
417
- manageable && !pending && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
418
- className: "act act-quiet env-card-menu",
419
- "aria-label": `Actions for ${environment.slug}`,
420
- children: /* @__PURE__ */ jsx(MoreHorizontal, { size: 16 })
421
- }), /* @__PURE__ */ jsxs(MenuPopup, {
422
- align: "end",
423
- children: [
424
- /* @__PURE__ */ jsxs(Menu.Item, {
425
- className: "menu-item",
426
- onClick: () => {
427
- setSlug(environment.slug);
428
- setName(environment.name);
429
- setRenaming(true);
430
- },
431
- children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Rename"]
432
- }),
433
- /* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }),
434
- /* @__PURE__ */ jsxs(Menu.Item, {
435
- className: `menu-item${isArchived ? "" : " menu-item-danger"}`,
436
- onClick: () => setConfirming(true),
437
- children: [isArchived ? /* @__PURE__ */ jsx(RotateBack, { size: 14 }) : /* @__PURE__ */ jsx(Archive, { size: 14 }), isArchived ? "Restore" : "Archive…"]
438
- })
439
- ]
440
- })] }),
441
- manageable && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Modal, {
442
- open: renaming,
443
- onOpenChange: setRenaming,
444
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
445
- "Rename",
446
- " ",
447
- /* @__PURE__ */ jsxs("span", {
448
- className: "mono",
449
- children: [
450
- project,
451
- "/",
452
- environment.slug
453
- ]
454
- })
455
- ] }),
456
- children: /* @__PURE__ */ jsxs("form", {
457
- className: "form",
458
- onSubmit: (event) => {
459
- event.preventDefault();
460
- rename({
461
- from: environment.slug,
462
- slug,
463
- name: name.trim()
464
- });
465
- setRenaming(false);
466
- },
467
- children: [
468
- /* @__PURE__ */ jsxs("label", {
469
- className: "field",
470
- children: [
471
- /* @__PURE__ */ jsx("span", {
472
- className: "label",
473
- children: "Slug"
474
- }),
475
- /* @__PURE__ */ jsx("input", {
476
- className: "input input-mono",
477
- autoFocus: true,
478
- spellCheck: false,
479
- value: slug,
480
- "aria-invalid": slugError !== null,
481
- onChange: (event) => setSlug(event.target.value)
482
- }),
483
- /* @__PURE__ */ jsx("span", {
484
- className: `hint${slugError !== null ? " edit-note-error" : ""}`,
485
- children: slugError ?? `Anything running coffre run ${project}/${environment.slug} will need the new path.`
486
- })
487
- ]
488
- }),
489
- /* @__PURE__ */ jsxs("label", {
490
- className: "field",
491
- children: [/* @__PURE__ */ jsx("span", {
492
- className: "label",
493
- children: "Display name"
494
- }), /* @__PURE__ */ jsx("input", {
495
- className: "input",
496
- value: name,
497
- onChange: (event) => setName(event.target.value)
498
- })]
499
- }),
500
- /* @__PURE__ */ jsxs("div", {
501
- className: "dialog-actions",
502
- children: [/* @__PURE__ */ jsx("button", {
503
- className: "btn",
504
- type: "button",
505
- onClick: () => setRenaming(false),
506
- children: "Cancel"
507
- }), /* @__PURE__ */ jsx("button", {
508
- className: "btn btn-primary",
509
- type: "submit",
510
- disabled: slug === "" || slugError !== null || name.trim() === "",
511
- children: "Save"
512
- })]
513
- })
514
- ]
515
- })
516
- }), /* @__PURE__ */ jsx(ConfirmDialog, {
517
- open: confirming,
518
- onOpenChange: setConfirming,
519
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
520
- isArchived ? "Restore" : "Archive",
521
- " ",
522
- /* @__PURE__ */ jsxs("span", {
523
- className: "mono",
524
- children: [
525
- project,
526
- "/",
527
- environment.slug
528
- ]
529
- }),
530
- "?"
531
- ] }),
532
- body: secretCount === null ? /* @__PURE__ */ jsx(Fragment$1, { children: "This changes whether the environment serves secrets to principals who have access. Values and history remain stored." }) : isArchived ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
533
- "The environment starts serving its ",
534
- secretCount,
535
- " secret",
536
- secretCount === 1 ? "" : "s",
537
- " again, to everyone who holds a grant on it."
538
- ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
539
- "Its ",
540
- secretCount,
541
- " secret",
542
- secretCount === 1 ? "" : "s",
543
- " stop being served, so anything running ",
544
- /* @__PURE__ */ jsx("code", { children: "coffre run" }),
545
- " against",
546
- " ",
547
- /* @__PURE__ */ jsxs("span", {
548
- className: "mono",
549
- children: [
550
- project,
551
- "/",
552
- environment.slug
553
- ]
554
- }),
555
- " ",
556
- "loses them at its next start. Values and history survive, and restoring is one click."
557
- ] }),
558
- confirmLabel: isArchived ? "Restore environment" : "Archive environment",
559
- destructive: !isArchived,
560
- onConfirm: () => archive({
561
- slug: environment.slug,
562
- archived: !isArchived
563
- })
564
- })] }),
565
- /* @__PURE__ */ jsx(ItemFailure, {
566
- status: state,
567
- onDismiss: () => state.state === "failed" && dismiss(state.mutationId)
568
- })
569
- ]
570
- });
571
- }
572
- function NewEnvironment({ project }) {
573
- const [open, setOpen] = useState(false);
574
- const [slug, setSlug] = useState("");
575
- const [name, setName] = useState("");
576
- const create = useChange(createEnvironment(useCoffre(), project));
577
- const slugError = slug === "" ? null : slugProblem(slug);
578
- function close() {
579
- setOpen(false);
580
- }
581
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("button", {
582
- className: "btn btn-primary",
583
- onClick: () => setOpen(true),
584
- children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "Add environment"]
585
- }), /* @__PURE__ */ jsx(Modal, {
586
- open,
587
- onOpenChange: (next) => next ? setOpen(true) : close(),
588
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: ["New environment in ", /* @__PURE__ */ jsx("span", {
589
- className: "mono",
590
- children: project
591
- })] }),
592
- children: /* @__PURE__ */ jsxs("form", {
593
- className: "form",
594
- onSubmit: (event) => {
595
- event.preventDefault();
596
- create({
597
- slug,
598
- name: name.trim()
599
- });
600
- setSlug("");
601
- setName("");
602
- close();
603
- },
604
- children: [
605
- /* @__PURE__ */ jsxs("label", {
606
- className: "field",
607
- children: [
608
- /* @__PURE__ */ jsx("span", {
609
- className: "label",
610
- children: "Slug"
611
- }),
612
- /* @__PURE__ */ jsx("input", {
613
- className: "input input-mono",
614
- autoFocus: true,
615
- spellCheck: false,
616
- autoComplete: "off",
617
- placeholder: "staging",
618
- value: slug,
619
- "aria-invalid": slugError !== null,
620
- onChange: (event) => setSlug(event.target.value)
621
- }),
622
- /* @__PURE__ */ jsx("span", {
623
- className: `hint${slugError !== null ? " edit-note-error" : ""}`,
624
- children: slugError ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [
625
- "The CLI will address it as",
626
- " ",
627
- /* @__PURE__ */ jsxs("span", {
628
- className: "mono",
629
- children: [
630
- project,
631
- "/",
632
- slug === "" ? "staging" : slug
633
- ]
634
- }),
635
- "."
636
- ] })
637
- })
638
- ]
639
- }),
640
- /* @__PURE__ */ jsxs("label", {
641
- className: "field",
642
- children: [/* @__PURE__ */ jsx("span", {
643
- className: "label",
644
- children: "Display name"
645
- }), /* @__PURE__ */ jsx("input", {
646
- className: "input",
647
- placeholder: "Staging",
648
- value: name,
649
- onChange: (event) => setName(event.target.value)
650
- })]
651
- }),
652
- /* @__PURE__ */ jsxs("div", {
653
- className: "dialog-actions",
654
- children: [/* @__PURE__ */ jsx("button", {
655
- className: "btn",
656
- type: "button",
657
- onClick: close,
658
- children: "Cancel"
659
- }), /* @__PURE__ */ jsx("button", {
660
- className: "btn btn-primary",
661
- type: "submit",
662
- disabled: slug === "" || slugError !== null || name.trim() === "",
663
- children: "Add environment"
664
- })]
665
- })
666
- ]
667
- })
668
- })] });
669
- }
670
- function AccessPanel({ principalType, project, grants }) {
671
- const people = principalType === "user";
672
- const refused = useRefusedGrants(project, grants, principalType);
673
- return /* @__PURE__ */ jsx("section", {
674
- className: "card",
675
- "aria-label": people ? "Users with access" : "Tokens with access",
676
- children: grants.length === 0 && refused.length === 0 ? /* @__PURE__ */ jsxs(EmptyState, {
677
- title: people ? "No user has access" : "No token has access",
678
- children: [
679
- "Add ",
680
- people ? "a user" : "a token",
681
- " with permissions on the whole project or on one environment."
682
- ]
683
- }) : /* @__PURE__ */ jsxs(GrantsTable, {
684
- lead: /* @__PURE__ */ jsxs("span", {
685
- className: "th",
686
- children: [people ? /* @__PURE__ */ jsx(User, { size: 14 }) : /* @__PURE__ */ jsx(Key, { size: 14 }), people ? "Email" : "Name"]
687
- }),
688
- children: [grants.map((grant, index) => /* @__PURE__ */ jsx(GrantRowView, {
689
- number: index + 1,
690
- project,
691
- grant,
692
- leadLabel: people ? "Email" : "Name",
693
- lead: /* @__PURE__ */ jsx(PrincipalLink, {
694
- type: grant.principalType,
695
- id: grant.principalId
696
- })
697
- }, grantId(grant))), /* @__PURE__ */ jsx(RefusedGrants, { refused })]
698
- })
699
- });
700
- }
701
- function NewGrant({ principalType, project, environments, grants }) {
702
- const { capabilities } = useShell();
703
- const [open, setOpen] = useState(false);
704
- const [principalId, setPrincipalId] = useState("");
705
- const [permission, setPermission] = useState("viewer:");
706
- const [expiresAt, setExpiresAt] = useState("");
707
- const grant = useChange(grantAccess(useCoffre(), project));
708
- const permissionOptions = projectAccessOptions(environments);
709
- const kind = principalType === "user" ? "user" : "token";
710
- function close() {
711
- setOpen(false);
712
- }
713
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("button", {
714
- className: "btn btn-primary",
715
- onClick: () => setOpen(true),
716
- children: [
717
- /* @__PURE__ */ jsx(Plus, { size: 14 }),
718
- "Add ",
719
- kind
720
- ]
721
- }), /* @__PURE__ */ jsx(Modal, {
722
- open,
723
- onOpenChange: (next) => next ? setOpen(true) : close(),
724
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
725
- "Give a ",
726
- kind,
727
- " access to ",
728
- /* @__PURE__ */ jsx("span", {
729
- className: "mono",
730
- children: project
731
- })
732
- ] }),
733
- wide: true,
734
- description: "Owners manage the whole project and its access. Read and write can cover every environment, or one.",
735
- children: /* @__PURE__ */ jsxs("form", {
736
- className: "form",
737
- onSubmit: (event) => {
738
- event.preventDefault();
739
- const access = parseProjectAccess(permission);
740
- grant({
741
- principalType,
742
- principalId: principalId.trim(),
743
- role: access.role,
744
- roleName: permissionOptions.find((option) => option.value === permission)?.label ?? access.role,
745
- environmentSlug: access.environmentSlug,
746
- expiresAt: expiresAt === "" ? null : (/* @__PURE__ */ new Date(`${expiresAt}T23:59:59Z`)).toISOString()
747
- });
748
- setPrincipalId("");
749
- setExpiresAt("");
750
- setPermission("viewer:");
751
- close();
752
- },
56
+ /* @__PURE__ */ jsx(PageTabs, {
57
+ label: "Project sections",
753
58
  children: [
754
- /* @__PURE__ */ jsx(PrincipalPicker, {
755
- principalType,
756
- canList: capabilities.canManageGrants,
757
- grants,
758
- value: principalId,
759
- onChange: setPrincipalId
760
- }),
761
- /* @__PURE__ */ jsxs("div", {
762
- className: "form-row",
763
- children: [/* @__PURE__ */ jsxs("label", {
764
- className: "field",
765
- style: { flexGrow: 2 },
766
- children: [/* @__PURE__ */ jsx("span", {
767
- className: "label",
768
- children: "Permissions"
769
- }), /* @__PURE__ */ jsx("select", {
770
- className: "select",
771
- value: permission,
772
- onChange: (event) => setPermission(event.target.value),
773
- children: permissionOptions.map((option) => /* @__PURE__ */ jsx("option", {
774
- value: option.value,
775
- children: option.label
776
- }, option.value))
777
- })]
778
- }), /* @__PURE__ */ jsxs("label", {
779
- className: "field",
780
- children: [/* @__PURE__ */ jsxs("span", {
781
- className: "label",
782
- children: ["Expires ", /* @__PURE__ */ jsx("span", {
783
- className: "hint",
784
- children: "(optional)"
785
- })]
786
- }), /* @__PURE__ */ jsx("input", {
787
- className: "input",
788
- type: "date",
789
- value: expiresAt,
790
- onChange: (event) => setExpiresAt(event.target.value)
791
- })]
792
- })]
793
- }),
794
- /* @__PURE__ */ jsxs("div", {
795
- className: "dialog-actions",
796
- children: [/* @__PURE__ */ jsx("button", {
797
- className: "btn",
798
- type: "button",
799
- onClick: close,
800
- children: "Cancel"
801
- }), /* @__PURE__ */ jsx("button", {
802
- className: "btn btn-primary",
803
- type: "submit",
804
- disabled: principalId.trim() === "",
805
- children: "Grant access"
806
- })]
807
- })
59
+ /* @__PURE__ */ jsxs(Link, {
60
+ to: "/projects/$project",
61
+ params,
62
+ activeOptions: {
63
+ exact: true,
64
+ includeSearch: false
65
+ },
66
+ children: [/* @__PURE__ */ jsx(Layers, { size: 15 }), "Environments"]
67
+ }, "environments"),
68
+ managesAccess && mounted("/projects/$project/users") && /* @__PURE__ */ jsxs(Link, {
69
+ to: "/projects/$project/users",
70
+ params,
71
+ children: [/* @__PURE__ */ jsx(Users, { size: 15 }), "Users"]
72
+ }, "users"),
73
+ managesAccess && mounted("/projects/$project/service-accounts") && /* @__PURE__ */ jsxs(Link, {
74
+ to: "/projects/$project/service-accounts",
75
+ params,
76
+ children: [/* @__PURE__ */ jsx(Key, { size: 15 }), "Service accounts"]
77
+ }, "service-accounts"),
78
+ found.permissions.includes("project.manage") && mounted("/projects/$project/settings") && /* @__PURE__ */ jsxs(Link, {
79
+ to: "/projects/$project/settings",
80
+ params,
81
+ children: [/* @__PURE__ */ jsx(Settings, { size: 15 }), "Settings"]
82
+ }, "settings")
808
83
  ]
809
- })
810
- })] });
811
- }
812
- /**
813
- * The project's name and slug, as a form on the page.
814
- *
815
- * Renaming changes paths other people and scripts use, so it is laid out in
816
- * plain sight with what it does and does not affect, rather than tucked
817
- * behind a menu.
818
- */
819
- function GeneralSettings({ project }) {
820
- const router = useRouter();
821
- const [slug, setSlug] = useState(project.slug);
822
- const [name, setName] = useState(project.name);
823
- const coffre = useCoffre();
824
- const { pending, error, run } = useAction();
825
- const slugError = slug === "" ? null : slugProblem(slug);
826
- const dirty = slug !== project.slug || name.trim() !== project.name;
827
- useEffect(() => {
828
- setSlug(project.slug);
829
- setName(project.name);
830
- }, [project.slug, project.name]);
831
- return /* @__PURE__ */ jsxs("section", {
832
- className: "card",
833
- "aria-labelledby": "general-settings",
834
- children: [/* @__PURE__ */ jsx("div", {
835
- className: "card-head",
836
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h2", {
837
- className: "card-title",
838
- id: "general-settings",
839
- children: "General"
840
- }) })
841
- }), /* @__PURE__ */ jsxs("form", {
842
- onSubmit: (event) => {
843
- event.preventDefault();
844
- run(() => coffre.projects.update(project.slug, {
845
- slug,
846
- name
847
- }), {
848
- affects: affects.places(),
849
- onSuccess: async () => {
850
- toast.success("Project renamed");
851
- if (slug !== project.slug) await router.navigate({
852
- to: "/projects/$project",
853
- params: { project: slug },
854
- search: { tab: "settings" }
855
- });
856
- }
857
- });
858
- },
859
- children: [/* @__PURE__ */ jsxs("div", {
860
- className: "card-body form-row",
861
- children: [/* @__PURE__ */ jsxs("label", {
862
- className: "field",
863
- children: [
864
- /* @__PURE__ */ jsx("span", {
865
- className: "label",
866
- children: "Slug"
867
- }),
868
- /* @__PURE__ */ jsx("input", {
869
- className: "input input-mono",
870
- spellCheck: false,
871
- value: slug,
872
- "aria-invalid": slugError !== null,
873
- onChange: (event) => setSlug(event.target.value)
874
- }),
875
- /* @__PURE__ */ jsx("span", {
876
- className: `hint${slugError !== null ? " edit-note-error" : ""}`,
877
- children: slugError ?? "Scripts that name the old slug will need the new one."
878
- })
879
- ]
880
- }), /* @__PURE__ */ jsxs("label", {
881
- className: "field",
882
- children: [/* @__PURE__ */ jsx("span", {
883
- className: "label",
884
- children: "Display name"
885
- }), /* @__PURE__ */ jsx("input", {
886
- className: "input",
887
- value: name,
888
- onChange: (event) => setName(event.target.value)
889
- })]
890
- })]
891
- }), /* @__PURE__ */ jsxs("div", {
892
- className: "card-foot",
893
- children: [error !== null && /* @__PURE__ */ jsx("span", {
894
- className: "hint",
895
- children: /* @__PURE__ */ jsx(ErrorLine, { error })
896
- }), /* @__PURE__ */ jsxs("button", {
897
- className: "btn btn-primary",
898
- type: "submit",
899
- disabled: !dirty || pending || slug === "" || slugError !== null || name.trim() === "",
900
- children: [pending && /* @__PURE__ */ jsx(Spinner, {}), "Save"]
901
- })]
902
- })]
903
- })]
904
- });
905
- }
906
- function DangerZone({ project }) {
907
- const [confirming, setConfirming] = useState(false);
908
- const coffre = useCoffre();
909
- const { pending, error, run } = useAction();
910
- const isArchived = project.archivedAt !== null;
911
- return /* @__PURE__ */ jsxs(Card, {
912
- labelledBy: "danger-zone",
913
- title: "Danger zone",
914
- tone: "danger",
915
- children: [/* @__PURE__ */ jsxs("div", {
916
- className: "card-row",
917
- children: [/* @__PURE__ */ jsxs("div", { children: [
918
- /* @__PURE__ */ jsx("p", {
919
- className: "card-row-title",
920
- children: isArchived ? "Restore project" : "Archive project"
921
- }),
922
- /* @__PURE__ */ jsx("p", {
923
- className: "card-row-desc",
924
- children: isArchived ? "The project reappears in listings and its environments serve reads again, for everyone who holds a grant on it." : "Every environment stops serving reads, including to machine callers already running. Nothing is deleted, and you can restore it here at any time."
925
- }),
926
- error !== null && /* @__PURE__ */ jsx("div", {
927
- style: { marginTop: "0.5rem" },
928
- children: /* @__PURE__ */ jsx(ErrorLine, { error })
929
- })
930
- ] }), /* @__PURE__ */ jsxs("button", {
931
- className: `btn ${isArchived ? "" : "btn-danger-outline"}`,
932
- onClick: () => setConfirming(true),
933
- disabled: pending,
934
- children: [pending ? /* @__PURE__ */ jsx(Spinner, {}) : isArchived ? /* @__PURE__ */ jsx(RotateBack, { size: 14 }) : /* @__PURE__ */ jsx(Archive, { size: 14 }), isArchived ? "Restore project" : "Archive project…"]
935
- })]
936
- }), /* @__PURE__ */ jsx(ConfirmDialog, {
937
- open: confirming,
938
- onOpenChange: setConfirming,
939
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
940
- isArchived ? "Restore" : "Archive",
941
- " ",
942
- /* @__PURE__ */ jsx("span", {
943
- className: "mono",
944
- children: project.slug
945
- }),
946
- "?"
947
- ] }),
948
- body: isArchived ? /* @__PURE__ */ jsx(Fragment$1, { children: "The project reappears in listings and its environments start serving reads again, for everyone who holds a grant on it." }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
949
- "Every environment in ",
950
- /* @__PURE__ */ jsx("span", {
951
- className: "mono",
952
- children: project.slug
953
- }),
954
- " stops serving reads, including to machine callers already running. Nothing is deleted: values, versions and the audit trail over them stay intact, and you can restore it here at any time."
955
- ] }),
956
- confirmLabel: isArchived ? "Restore project" : "Archive project",
957
- destructive: !isArchived,
958
- onConfirm: () => run(() => coffre.projects.update(project.slug, { archived: !isArchived }), {
959
- affects: affects.places(),
960
- onSuccess: () => toast.success(isArchived ? `${project.slug} restored` : `${project.slug} archived`)
961
- })
962
- })]
963
- });
84
+ }),
85
+ /* @__PURE__ */ jsx(Outlet, {})
86
+ ] });
964
87
  }
965
88
  //#endregion
966
- export { ProjectPage };
89
+ export { ProjectLayout };
967
90
 
968
91
  //# sourceMappingURL=project.js.map