@coffre/ui 0.14.4 → 0.15.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 (115) hide show
  1. package/dist/chunks/{audit-sentence-JgJEwQEC.js → actions-log-DupYCEyV.js} +186 -21
  2. package/dist/chunks/actions-log-DupYCEyV.js.map +1 -0
  3. package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-CGUQlFMx.js} +5 -5
  4. package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-CGUQlFMx.js.map} +1 -1
  5. package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-CswZ-meh.js} +5 -5
  6. package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-CswZ-meh.js.map} +1 -1
  7. package/dist/chunks/{directory-BM8yoiJN.js → directory-DrswWQLT.js} +15 -15
  8. package/dist/chunks/directory-DrswWQLT.js.map +1 -0
  9. package/dist/chunks/environment-actions-8rL9Cw6X.js +576 -0
  10. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +1 -0
  11. package/dist/chunks/{folders-D3A1NGpt.js → folders-A6sbR_PG.js} +3 -3
  12. package/dist/chunks/{folders-D3A1NGpt.js.map → folders-A6sbR_PG.js.map} +1 -1
  13. package/dist/chunks/{grants-CjVmOgb2.js → grants-C0cb2oii.js} +8 -8
  14. package/dist/chunks/grants-C0cb2oii.js.map +1 -0
  15. package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-B3SEv1gq.js} +3 -3
  16. package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-B3SEv1gq.js.map} +1 -1
  17. package/dist/chunks/{offboarding-DbozhPym.js → offboarding-C1jbG_dk.js} +72 -67
  18. package/dist/chunks/offboarding-C1jbG_dk.js.map +1 -0
  19. package/dist/chunks/{page-JTORvh-N.js → page-CfhC9Hp1.js} +11 -6
  20. package/dist/chunks/page-CfhC9Hp1.js.map +1 -0
  21. package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-xC9wulhg.js} +5 -5
  22. package/dist/chunks/{personal-tokens-zWZOzLIC.js.map → personal-tokens-xC9wulhg.js.map} +1 -1
  23. package/dist/chunks/{principal-DFBswTBr.js → principal-CI17XK13.js} +2 -2
  24. package/dist/chunks/{principal-DFBswTBr.js.map → principal-CI17XK13.js.map} +1 -1
  25. package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-CdSeftGD.js} +17 -127
  26. package/dist/chunks/principal-page-CdSeftGD.js.map +1 -0
  27. package/dist/chunks/{project-page-BjwEoXfU.js → project-page-CHxjBE97.js} +3 -3
  28. package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-CHxjBE97.js.map} +1 -1
  29. package/dist/chunks/{queries-2jdgTwfZ.js → queries-D1JuimTu.js} +82 -26
  30. package/dist/chunks/queries-D1JuimTu.js.map +1 -0
  31. package/dist/chunks/{references-CRT2BsOS.js → references-D5llUGQL.js} +5 -5
  32. package/dist/chunks/{references-CRT2BsOS.js.map → references-D5llUGQL.js.map} +1 -1
  33. package/dist/chunks/{role-field-DswIpPqY.js → role-field-CoCv8wse.js} +5 -5
  34. package/dist/chunks/role-field-CoCv8wse.js.map +1 -0
  35. package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYH7kZHl.js} +3 -3
  36. package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYH7kZHl.js.map} +1 -1
  37. package/dist/chunks/{theme-Ck45wzWB.js → theme-rF44Wbmm.js} +3 -3
  38. package/dist/chunks/{theme-Ck45wzWB.js.map → theme-rF44Wbmm.js.map} +1 -1
  39. package/dist/chunks/{ui-D-blFWfx.js → ui-CGdORVzW.js} +2 -2
  40. package/dist/chunks/{ui-D-blFWfx.js.map → ui-CGdORVzW.js.map} +1 -1
  41. package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BxrHTBZw.js} +3 -3
  42. package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BxrHTBZw.js.map} +1 -1
  43. package/dist/chunks/{use-change-BC4xo02c.js → use-change-BorW2R6C.js} +4 -4
  44. package/dist/chunks/{use-change-BC4xo02c.js.map → use-change-BorW2R6C.js.map} +1 -1
  45. package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-BZnJ9Cq0.js} +56 -13
  46. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +1 -0
  47. package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-CPskgi1k.js} +3 -3
  48. package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-CPskgi1k.js.map} +1 -1
  49. package/dist/index.d.ts +46 -2
  50. package/dist/index.js +30 -11
  51. package/dist/index.js.map +1 -1
  52. package/dist/pages/account.js +11 -11
  53. package/dist/pages/account.js.map +1 -1
  54. package/dist/pages/approval.js +2 -2
  55. package/dist/pages/audit.js +55 -21
  56. package/dist/pages/audit.js.map +1 -1
  57. package/dist/pages/device-login.js +2 -2
  58. package/dist/pages/environment.js +228 -389
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +3 -3
  61. package/dist/pages/oauth-authorize.js +2 -2
  62. package/dist/pages/project-access.js +11 -11
  63. package/dist/pages/project-environments.js +28 -359
  64. package/dist/pages/project-environments.js.map +1 -1
  65. package/dist/pages/project-settings.js +8 -8
  66. package/dist/pages/project.js +3 -3
  67. package/dist/pages/projects.js +8 -8
  68. package/dist/pages/service-account.js +11 -10
  69. package/dist/pages/service-account.js.map +1 -1
  70. package/dist/pages/service-accounts.js +7 -6
  71. package/dist/pages/service-accounts.js.map +1 -1
  72. package/dist/pages/settings.d.ts +6 -1
  73. package/dist/pages/settings.js +284 -164
  74. package/dist/pages/settings.js.map +1 -1
  75. package/dist/pages/unregistered.js +2 -2
  76. package/dist/pages/user.js +7 -6
  77. package/dist/pages/user.js.map +1 -1
  78. package/dist/pages/users.js +7 -6
  79. package/dist/pages/users.js.map +1 -1
  80. package/package.json +3 -3
  81. package/src/components/actions-log.tsx +61 -8
  82. package/src/components/directory.tsx +5 -5
  83. package/src/components/environment-actions.tsx +508 -0
  84. package/src/components/grants.tsx +2 -2
  85. package/src/components/icons.tsx +2 -0
  86. package/src/components/offboarding.tsx +7 -0
  87. package/src/components/page.tsx +3 -2
  88. package/src/components/principal-page.tsx +1 -1
  89. package/src/components/protected.tsx +52 -39
  90. package/src/components/role-editor.tsx +99 -68
  91. package/src/components/role-field.tsx +1 -1
  92. package/src/lib/audit-sentences.ts +24 -19
  93. package/src/lib/queries.ts +85 -21
  94. package/src/lib/roles.ts +36 -10
  95. package/src/options.ts +19 -3
  96. package/src/pages/account.tsx +1 -1
  97. package/src/pages/audit.tsx +56 -16
  98. package/src/pages/environment.tsx +227 -352
  99. package/src/pages/project-environments.tsx +20 -322
  100. package/src/pages/service-accounts.tsx +1 -1
  101. package/src/pages/settings.tsx +129 -48
  102. package/src/pages/users.tsx +1 -1
  103. package/src/parity.ts +18 -11
  104. package/src/styles/globals.css +271 -89
  105. package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
  106. package/dist/chunks/directory-BM8yoiJN.js.map +0 -1
  107. package/dist/chunks/grants-CjVmOgb2.js.map +0 -1
  108. package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
  109. package/dist/chunks/page-JTORvh-N.js.map +0 -1
  110. package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
  111. package/dist/chunks/protected-y7KVhtHd.js +0 -77
  112. package/dist/chunks/protected-y7KVhtHd.js.map +0 -1
  113. package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
  114. package/dist/chunks/role-field-DswIpPqY.js.map +0 -1
  115. package/dist/chunks/use-roles-DswiNxBk.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { a as ErrorLine, l as Spinner } from "../chunks/ui-D-blFWfx.js";
2
- import { K as ProviderMark, L as Lock, X as ShieldCheck, n as ClosedDoor } from "../chunks/page-JTORvh-N.js";
3
- import { t as useShell } from "../chunks/use-shell-zpjE_MKh.js";
1
+ import { a as ErrorLine, l as Spinner } from "../chunks/ui-CGdORVzW.js";
2
+ import { R as Lock, Z as ShieldCheck, n as ClosedDoor, q as ProviderMark } from "../chunks/page-CfhC9Hp1.js";
3
+ import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
4
4
  import { n as signinErrorMessage } from "../chunks/signin-errors-TlQmQe0t.js";
5
5
  import { t as useOneTime } from "../chunks/one-time-DXEl9hbg.js";
6
6
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
@@ -1,5 +1,5 @@
1
- import { a as ErrorLine, c as Notice, l as Spinner } from "../chunks/ui-D-blFWfx.js";
2
- import { $ as SlashCircle, F as Link, c as statusOf, g as ArrowRight, n as ClosedDoor, o as failureMessage, u as useCoffre } from "../chunks/page-JTORvh-N.js";
1
+ import { a as ErrorLine, c as Notice, l as Spinner } from "../chunks/ui-CGdORVzW.js";
2
+ import { I as Link, c as statusOf, et as SlashCircle, g as ArrowRight, n as ClosedDoor, o as failureMessage, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
3
3
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
4
4
  import { useState } from "react";
5
5
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -1,15 +1,15 @@
1
- import { c as listsServices, x as queries } from "../chunks/queries-2jdgTwfZ.js";
2
- import { c as Notice, i as EmptyState, l as Spinner, s as Modal } from "../chunks/ui-D-blFWfx.js";
3
- import { G as Plus, J as Search, M as Key, _ as Check, it as User, u as useCoffre } from "../chunks/page-JTORvh-N.js";
4
- import { t as useShell } from "../chunks/use-shell-zpjE_MKh.js";
5
- import { Z as projectAccessLabel, t as useChange, v as grantAccess, y as grantId } from "../chunks/use-change-BC4xo02c.js";
6
- import { f as roleNameOf, t as useRoles } from "../chunks/use-roles-DswiNxBk.js";
7
- import { n as PrincipalLink, t as PrincipalAvatar } from "../chunks/principal-DFBswTBr.js";
8
- import { r as KIND } from "../chunks/directory-BM8yoiJN.js";
1
+ import { c as listsServices, x as queries } from "../chunks/queries-D1JuimTu.js";
2
+ import { c as Notice, i as EmptyState, l as Spinner, s as Modal } from "../chunks/ui-CGdORVzW.js";
3
+ import { K as Plus, N as Key, Y as Search, _ as Check, at as User, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
4
+ import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
5
+ import { Z as projectAccessLabel, t as useChange, v as grantAccess, y as grantId } from "../chunks/use-change-BorW2R6C.js";
6
+ import { m as roleNameOf, t as useRoles } from "../chunks/use-roles-BZnJ9Cq0.js";
7
+ import { n as PrincipalLink, t as PrincipalAvatar } from "../chunks/principal-CI17XK13.js";
8
+ import { r as KIND } from "../chunks/directory-DrswWQLT.js";
9
9
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
10
- import { a as ReferencesInto } from "../chunks/references-CRT2BsOS.js";
11
- import { i as useRefusedGrants, n as GrantsTable, r as RefusedGrants, t as GrantRowView } from "../chunks/grants-CjVmOgb2.js";
12
- import { t as useProject } from "../chunks/project-page-BjwEoXfU.js";
10
+ import { a as ReferencesInto } from "../chunks/references-D5llUGQL.js";
11
+ import { i as useRefusedGrants, n as GrantsTable, r as RefusedGrants, t as GrantRowView } from "../chunks/grants-C0cb2oii.js";
12
+ import { t as useProject } from "../chunks/project-page-CHxjBE97.js";
13
13
  import { useId, useState } from "react";
14
14
  import { Link } from "@tanstack/react-router";
15
15
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -1,21 +1,17 @@
1
- import { A as isActiveAccessibleEnvironment, k as hasEnvironmentDetails, o as keys, t as affects, x as queries } from "../chunks/queries-2jdgTwfZ.js";
2
- import { a as ErrorLine, c as Notice, i as EmptyState, n as ConfirmDialog, o as MenuPopup, s as Modal, u as Timestamp } from "../chunks/ui-D-blFWfx.js";
3
- import { G as Plus, H as MoreHorizontal, W as Pencil, b as ChevronRight, h as Archive, nt as Trash, q as RotateBack, t as Card, u as useCoffre } from "../chunks/page-JTORvh-N.js";
4
- import { a as rowClass, i as RowPending, t as ItemFailure } from "../chunks/row-state-xtRGFnDc.js";
5
- import { t as useShell } from "../chunks/use-shell-zpjE_MKh.js";
6
- import { O as renameEnvironment, g as environmentId, l as createEnvironment, n as useChangeStatus, o as archiveEnvironment, t as useChange } from "../chunks/use-change-BC4xo02c.js";
7
- import { t as environmentSlugProblem } from "../chunks/validation-DiHIwZRA.js";
8
- import { t as PrincipalAvatar } from "../chunks/principal-DFBswTBr.js";
1
+ import { M as isActiveAccessibleEnvironment, j as hasEnvironmentDetails, n as affects, o as keys, x as queries } from "../chunks/queries-D1JuimTu.js";
2
+ import { a as ErrorLine, i as EmptyState, n as ConfirmDialog, u as Timestamp } from "../chunks/ui-CGdORVzW.js";
3
+ import { K as Plus, b as ChevronRight, rt as Trash, t as Card, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
4
+ import { a as rowClass, i as RowPending, t as ItemFailure } from "../chunks/row-state-CYH7kZHl.js";
5
+ import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
6
+ import { g as environmentId, n as useChangeStatus } from "../chunks/use-change-BorW2R6C.js";
7
+ import { t as PrincipalAvatar } from "../chunks/principal-CI17XK13.js";
9
8
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
10
- import { t as useAction } from "../chunks/use-action-CXEFFjx5.js";
11
- import { t as Protection } from "../chunks/protected-y7KVhtHd.js";
12
- import { o as archiveBlockers, t as ArchiveBlocked } from "../chunks/references-CRT2BsOS.js";
13
- import { t as useProject } from "../chunks/project-page-BjwEoXfU.js";
14
- import { t as DeletePlaceDialog } from "../chunks/delete-place-dIVoK87I.js";
9
+ import { t as useAction } from "../chunks/use-action-BxrHTBZw.js";
10
+ import { n as NewEnvironment, r as Protection, t as EnvironmentMenu } from "../chunks/environment-actions-8rL9Cw6X.js";
11
+ import { t as useProject } from "../chunks/project-page-CHxjBE97.js";
15
12
  import { useState } from "react";
16
13
  import { Link } from "@tanstack/react-router";
17
14
  import { toast } from "sonner";
18
- import { Menu } from "@base-ui/react/menu";
19
15
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
20
16
  import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
21
17
  //#region src/pages/project-environments.tsx
@@ -60,7 +56,6 @@ function EnvironmentsPanel({ project, canManage, grants }) {
60
56
  children: [current.map((environment) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(EnvironmentCard, {
61
57
  project: project.slug,
62
58
  environment,
63
- isAdmin: canManage,
64
59
  grants
65
60
  }) }, `${project.slug}:${environment.slug}`)), refused.map(({ mutationId, vars, status }) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", {
66
61
  className: "env-card is-muted is-failed",
@@ -79,11 +74,7 @@ function EnvironmentsPanel({ project, canManage, grants }) {
79
74
  }),
80
75
  canManage && /* @__PURE__ */ jsx("div", {
81
76
  className: "table-actions",
82
- children: /* @__PURE__ */ jsx(NewEnvironment, {
83
- project: project.slug,
84
- sources: current.filter((environment) => isActiveAccessibleEnvironment(environment) && !environment.personal).map((environment) => environment.slug),
85
- guarded: current.filter((environment) => environment.protected).map((environment) => environment.slug)
86
- })
77
+ children: /* @__PURE__ */ jsx(AddEnvironment, { project: project.slug })
87
78
  }),
88
79
  canManage && /* @__PURE__ */ jsx(PersonalConfigs, { project: project.slug }),
89
80
  archived.length > 0 && /* @__PURE__ */ jsxs("section", {
@@ -97,7 +88,6 @@ function EnvironmentsPanel({ project, canManage, grants }) {
97
88
  children: archived.map((environment) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(EnvironmentCard, {
98
89
  project: project.slug,
99
90
  environment,
100
- isAdmin: canManage,
101
91
  grants
102
92
  }) }, environment.slug))
103
93
  })]
@@ -136,23 +126,8 @@ function useLastChange(project, environment, enabled) {
136
126
  return last;
137
127
  }
138
128
  var SHOWN_HOLDERS = 4;
139
- function EnvironmentCard({ project, environment, isAdmin, grants }) {
140
- const [renaming, setRenaming] = useState(false);
141
- const [confirming, setConfirming] = useState(false);
142
- const [deleting, setDeleting] = useState(false);
143
- const { capabilities } = useShell();
144
- const [slug, setSlug] = useState(environment.slug);
145
- const coffre = useCoffre();
146
- const rename = useChange(renameEnvironment(coffre, project));
147
- const archive = useChange(archiveEnvironment(coffre, project));
148
- const place = `${project}/${environment.slug}`;
149
- const archiving = confirming && environment.details?.archivedAt == null;
150
- const { data: lent } = useQuery({
151
- ...queries.references(coffre, place),
152
- enabled: archiving
153
- });
154
- const blockers = archiving && lent?.ok === true ? archiveBlockers(place, lent.references) : [];
155
- const asking = archiving && lent === void 0;
129
+ function EnvironmentCard({ project, environment, grants }) {
130
+ const { principal } = useShell();
156
131
  const { status, dismiss } = useChangeStatus(keys.projects);
157
132
  const state = status(environmentId(project, environment.slug));
158
133
  const pending = state.state === "pending";
@@ -160,12 +135,8 @@ function EnvironmentCard({ project, environment, isAdmin, grants }) {
160
135
  const isArchived = details !== null && details.archivedAt !== null;
161
136
  const secretCount = details?.secretCount ?? null;
162
137
  const opens = details !== null && !isArchived && environment.accessible && !pending;
163
- const manageable = isAdmin && details !== null;
164
- const deletable = manageable && isArchived && capabilities.runsInstance;
165
- const slugError = slug === "" ? null : environmentSlugProblem(slug);
166
138
  const lastChange = useLastChange(project, environment.slug, opens);
167
139
  const holders = environment.personal === true ? [] : holdersOf(grants, environment.slug);
168
- const reslugged = slug !== environment.slug && slug !== "" && slugError === null;
169
140
  return /* @__PURE__ */ jsxs("div", {
170
141
  className: `env-card${opens ? " is-link" : " is-muted"} ${rowClass(state)}`,
171
142
  children: [
@@ -188,8 +159,8 @@ function EnvironmentCard({ project, environment, isAdmin, grants }) {
188
159
  children: environment.slug
189
160
  }),
190
161
  /* @__PURE__ */ jsx(Protection, {
191
- project,
192
- environment
162
+ environment,
163
+ compact: true
193
164
  }),
194
165
  environment.personal === true ? /* @__PURE__ */ jsx("span", {
195
166
  className: "tag tag-blue",
@@ -252,169 +223,14 @@ function EnvironmentCard({ project, environment, isAdmin, grants }) {
252
223
  "aria-hidden": true
253
224
  }),
254
225
  pending && /* @__PURE__ */ jsx(RowPending, { status: state }),
255
- manageable && !pending && environment.personal !== true && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
256
- className: "act act-quiet env-card-menu",
257
- "aria-label": `Actions for ${environment.slug}`,
258
- children: /* @__PURE__ */ jsx(MoreHorizontal, { size: 16 })
259
- }), /* @__PURE__ */ jsxs(MenuPopup, {
260
- align: "end",
261
- children: [
262
- /* @__PURE__ */ jsxs(Menu.Item, {
263
- className: "menu-item",
264
- onClick: () => {
265
- setSlug(environment.slug);
266
- setRenaming(true);
267
- },
268
- children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Rename"]
269
- }),
270
- /* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }),
271
- /* @__PURE__ */ jsxs(Menu.Item, {
272
- className: `menu-item${isArchived ? "" : " menu-item-danger"}`,
273
- onClick: () => setConfirming(true),
274
- children: [isArchived ? /* @__PURE__ */ jsx(RotateBack, { size: 14 }) : /* @__PURE__ */ jsx(Archive, { size: 14 }), isArchived ? "Restore" : "Archive…"]
275
- }),
276
- deletable && /* @__PURE__ */ jsxs(Menu.Item, {
277
- className: "menu-item menu-item-danger",
278
- onClick: () => setDeleting(true),
279
- children: [/* @__PURE__ */ jsx(Trash, { size: 14 }), "Delete…"]
280
- })
281
- ]
282
- })] }),
283
- manageable && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Modal, {
284
- open: renaming,
285
- onOpenChange: setRenaming,
286
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
287
- "Rename",
288
- " ",
289
- /* @__PURE__ */ jsxs("span", {
290
- className: "mono",
291
- children: [
292
- project,
293
- "/",
294
- environment.slug
295
- ]
296
- })
297
- ] }),
298
- children: /* @__PURE__ */ jsxs("form", {
299
- className: "form",
300
- onSubmit: (event) => {
301
- event.preventDefault();
302
- rename({
303
- from: environment.slug,
304
- slug
305
- });
306
- setRenaming(false);
307
- },
308
- children: [
309
- /* @__PURE__ */ jsxs("label", {
310
- className: "field",
311
- children: [
312
- /* @__PURE__ */ jsx("span", {
313
- className: "label",
314
- children: "Slug"
315
- }),
316
- /* @__PURE__ */ jsx("input", {
317
- className: "input input-mono",
318
- autoFocus: true,
319
- spellCheck: false,
320
- value: slug,
321
- "aria-invalid": slugError !== null,
322
- onChange: (event) => setSlug(event.target.value)
323
- }),
324
- /* @__PURE__ */ jsx("span", {
325
- className: `hint${slugError !== null ? " edit-note-error" : ""}`,
326
- children: slugError ?? `Anything running coffre run ${project}/${environment.slug} will need the new path.`
327
- })
328
- ]
329
- }),
330
- reslugged && /* @__PURE__ */ jsxs(Notice, {
331
- tone: "info",
332
- children: [
333
- "Instance roles scoped to ",
334
- /* @__PURE__ */ jsx("span", {
335
- className: "mono",
336
- children: environment.slug
337
- }),
338
- " stop reaching it; those scoped to ",
339
- /* @__PURE__ */ jsx("span", {
340
- className: "mono",
341
- children: slug
342
- }),
343
- " start."
344
- ]
345
- }),
346
- /* @__PURE__ */ jsxs("div", {
347
- className: "dialog-actions",
348
- children: [/* @__PURE__ */ jsx("button", {
349
- className: "btn",
350
- type: "button",
351
- onClick: () => setRenaming(false),
352
- children: "Cancel"
353
- }), /* @__PURE__ */ jsx("button", {
354
- className: "btn btn-primary",
355
- type: "submit",
356
- disabled: slug === environment.slug || slug === "" || slugError !== null,
357
- children: "Save"
358
- })]
359
- })
360
- ]
361
- })
362
- }), /* @__PURE__ */ jsx(ConfirmDialog, {
363
- open: confirming,
364
- onOpenChange: setConfirming,
365
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
366
- isArchived ? "Restore" : "Archive",
367
- " ",
368
- /* @__PURE__ */ jsxs("span", {
369
- className: "mono",
370
- children: [
371
- project,
372
- "/",
373
- environment.slug
374
- ]
375
- }),
376
- "?"
377
- ] }),
378
- body: secretCount === null ? /* @__PURE__ */ jsx(Fragment$1, { children: "This changes whether the environment serves its secrets. Values and history stay stored." }) : isArchived ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
379
- "It serves its ",
380
- secretCount,
381
- " secret",
382
- secretCount === 1 ? "" : "s",
383
- " again, to everyone with a grant on it."
384
- ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
385
- "Its ",
386
- secretCount,
387
- " secret",
388
- secretCount === 1 ? "" : "s",
389
- " stop being served, so anything running ",
390
- /* @__PURE__ */ jsx("code", { children: "coffre run" }),
391
- " against",
392
- " ",
393
- /* @__PURE__ */ jsxs("span", {
394
- className: "mono",
395
- children: [
396
- project,
397
- "/",
398
- environment.slug
399
- ]
400
- }),
401
- " ",
402
- "loses them at its next start. Values and history survive, and restoring is one click."
403
- ] }),
404
- detail: /* @__PURE__ */ jsx(ArchiveBlocked, { references: blockers }),
405
- confirmLabel: isArchived ? "Restore environment" : "Archive environment",
406
- confirmDisabled: asking || blockers.length > 0,
407
- destructive: !isArchived,
408
- onConfirm: () => archive({
409
- slug: environment.slug,
410
- archived: !isArchived
411
- })
412
- })] }),
413
- deletable && /* @__PURE__ */ jsx(DeletePlaceDialog, {
414
- path: `${project}/${environment.slug}`,
415
- open: deleting,
416
- onOpenChange: setDeleting,
417
- onDeleted: () => toast.success(`${project}/${environment.slug} deleted`)
226
+ !pending && /* @__PURE__ */ jsx(EnvironmentMenu, {
227
+ project,
228
+ environment: environment.slug,
229
+ inProject: environment,
230
+ ownConfig: principal?.type === "user" && isActiveAccessibleEnvironment(environment) && environment.personal !== true,
231
+ busy: false,
232
+ follow: false,
233
+ className: "act act-quiet env-card-menu"
418
234
  }),
419
235
  /* @__PURE__ */ jsx(ItemFailure, {
420
236
  status: state,
@@ -496,164 +312,17 @@ function PersonalConfigs({ project }) {
496
312
  ]
497
313
  });
498
314
  }
499
- /**
500
- * A new environment, empty, or forked from one you can read: inheriting
501
- * its keys live (docs/design/forking.md), or each of them copied, value and
502
- * folder, without history, or a reference to it. Copying is a read, and
503
- * logged as one; inheriting reads nothing until the fork is read.
504
- */
505
- function NewEnvironment({ project, sources, guarded }) {
315
+ /** Add environment, and the dialog it opens. */
316
+ function AddEnvironment({ project }) {
506
317
  const [open, setOpen] = useState(false);
507
- const [slug, setSlug] = useState("");
508
- const [start, setStart] = useState("");
509
- const [how, from] = start === "" ? ["", ""] : start.split(":");
510
- const coffre = useCoffre();
511
- const { data: parent } = useQuery({
512
- ...queries.secrets(coffre, {
513
- project,
514
- environment: from
515
- }),
516
- enabled: how === "ref"
517
- });
518
- const copied = how === "ref" && parent?.ok === true ? parent.keys.filter((key) => !key.archived && key.reference !== null && !key.reference.canOpenSource).map((key) => key.key) : [];
519
- const create = useChange(createEnvironment(coffre, project));
520
- const slugError = slug === "" ? null : environmentSlugProblem(slug);
521
- function close() {
522
- setOpen(false);
523
- }
524
318
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("button", {
525
319
  className: "btn btn-primary",
526
320
  onClick: () => setOpen(true),
527
321
  children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "Add environment"]
528
- }), /* @__PURE__ */ jsx(Modal, {
322
+ }), /* @__PURE__ */ jsx(NewEnvironment, {
323
+ project,
529
324
  open,
530
- onOpenChange: (next) => next ? setOpen(true) : close(),
531
- title: /* @__PURE__ */ jsxs(Fragment$1, { children: ["New environment in ", /* @__PURE__ */ jsx("span", {
532
- className: "mono",
533
- children: project
534
- })] }),
535
- children: /* @__PURE__ */ jsxs("form", {
536
- className: "form",
537
- onSubmit: (event) => {
538
- event.preventDefault();
539
- create({
540
- slug,
541
- ...from === "" ? {} : { from },
542
- ...how === "ref" ? { references: true } : {},
543
- ...how === "inherit" ? { inherit: true } : {}
544
- });
545
- setSlug("");
546
- setStart("");
547
- close();
548
- },
549
- children: [
550
- /* @__PURE__ */ jsxs("label", {
551
- className: "field",
552
- children: [
553
- /* @__PURE__ */ jsx("span", {
554
- className: "label",
555
- children: "Slug"
556
- }),
557
- /* @__PURE__ */ jsx("input", {
558
- className: "input input-mono",
559
- autoFocus: true,
560
- spellCheck: false,
561
- autoComplete: "off",
562
- placeholder: "staging",
563
- value: slug,
564
- "aria-invalid": slugError !== null,
565
- onChange: (event) => setSlug(event.target.value)
566
- }),
567
- /* @__PURE__ */ jsx("span", {
568
- className: `hint${slugError !== null ? " edit-note-error" : ""}`,
569
- children: slugError ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [
570
- "The CLI will address it as",
571
- " ",
572
- /* @__PURE__ */ jsxs("span", {
573
- className: "mono",
574
- children: [
575
- project,
576
- "/",
577
- slug === "" ? "staging" : slug
578
- ]
579
- }),
580
- "."
581
- ] })
582
- })
583
- ]
584
- }),
585
- sources.length > 0 && /* @__PURE__ */ jsxs("label", {
586
- className: "field",
587
- children: [
588
- /* @__PURE__ */ jsx("span", {
589
- className: "label",
590
- children: "Start from"
591
- }),
592
- /* @__PURE__ */ jsxs("select", {
593
- className: "select",
594
- value: start,
595
- onChange: (event) => setStart(event.target.value),
596
- children: [
597
- /* @__PURE__ */ jsx("option", {
598
- value: "",
599
- children: "Empty"
600
- }),
601
- sources.map((source) => /* @__PURE__ */ jsxs("option", {
602
- value: `inherit:${source}`,
603
- children: ["Inheriting from ", source]
604
- }, `inherit:${source}`)),
605
- sources.map((source) => /* @__PURE__ */ jsxs("option", {
606
- value: `copy:${source}`,
607
- children: ["A copy of ", source]
608
- }, `copy:${source}`)),
609
- sources.map((source) => /* @__PURE__ */ jsxs("option", {
610
- value: `ref:${source}`,
611
- children: ["References to ", source]
612
- }, `ref:${source}`))
613
- ]
614
- }),
615
- /* @__PURE__ */ jsx("span", {
616
- className: "hint",
617
- children: how === "" ? "No secrets yet." : how === "inherit" ? `Keeps reading ${from}'s keys, live, except those you set or remove here. Whoever reads ${slug === "" ? "the new environment" : slug} needs read on ${from} too, for those.` : how === "copy" ? `Each of ${from}'s keys, with its current value and folder, without history.` : `Each key follows ${from}'s until it gets a value of its own. Whoever can read ${slug === "" ? "the new environment" : slug} will read ${from}'s values through them, even without access to ${from}.`
618
- }),
619
- from !== "" && guarded.includes(from) && /* @__PURE__ */ jsxs("span", {
620
- className: "hint",
621
- children: [/* @__PURE__ */ jsx("span", {
622
- className: "mono",
623
- children: from
624
- }), " is protected, so the new environment is too, from its first moment."]
625
- }),
626
- copied.length > 0 && /* @__PURE__ */ jsxs("span", {
627
- className: "hint",
628
- children: [
629
- "Copied instead, since you read their source only through ",
630
- from,
631
- ": ",
632
- /* @__PURE__ */ jsx("span", {
633
- className: "mono",
634
- children: copied.join(", ")
635
- }),
636
- "."
637
- ]
638
- })
639
- ]
640
- }),
641
- /* @__PURE__ */ jsxs("div", {
642
- className: "dialog-actions",
643
- children: [/* @__PURE__ */ jsx("button", {
644
- className: "btn",
645
- type: "button",
646
- onClick: close,
647
- children: "Cancel"
648
- }), /* @__PURE__ */ jsx("button", {
649
- className: "btn btn-primary",
650
- type: "submit",
651
- disabled: slug === "" || slugError !== null,
652
- children: "Add environment"
653
- })]
654
- })
655
- ]
656
- })
325
+ onOpenChange: setOpen
657
326
  })] });
658
327
  }
659
328
  //#endregion