@coffre/ui 0.15.0 → 0.16.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 (139) hide show
  1. package/dist/audit-sentences.d.ts +56 -0
  2. package/dist/audit-sentences.js +886 -0
  3. package/dist/audit-sentences.js.map +1 -0
  4. package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
  5. package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
  6. package/dist/chunks/{connected-apps-CGUQlFMx.js → connected-apps-6sMSgQ9U.js} +5 -5
  7. package/dist/chunks/{connected-apps-CGUQlFMx.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
  8. package/dist/chunks/{delete-place-CswZ-meh.js → delete-place-T469tSN9.js} +5 -5
  9. package/dist/chunks/{delete-place-CswZ-meh.js.map → delete-place-T469tSN9.js.map} +1 -1
  10. package/dist/chunks/{directory-DrswWQLT.js → directory-B_gVf7UL.js} +18 -17
  11. package/dist/chunks/directory-B_gVf7UL.js.map +1 -0
  12. package/dist/chunks/{folders-A6sbR_PG.js → folders-CVYauIDz.js} +3 -3
  13. package/dist/chunks/{folders-A6sbR_PG.js.map → folders-CVYauIDz.js.map} +1 -1
  14. package/dist/chunks/{grants-C0cb2oii.js → grants-Dn_EW2XW.js} +8 -8
  15. package/dist/chunks/grants-Dn_EW2XW.js.map +1 -0
  16. package/dist/chunks/{multi-combobox-B3SEv1gq.js → multi-combobox-fbBRzi9z.js} +3 -3
  17. package/dist/chunks/{multi-combobox-B3SEv1gq.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
  18. package/dist/chunks/{offboarding-C1jbG_dk.js → offboarding-CXM464J_.js} +81 -80
  19. package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
  20. package/dist/chunks/{page-CfhC9Hp1.js → page-Cb0ZjGda.js} +7 -12
  21. package/dist/chunks/page-Cb0ZjGda.js.map +1 -0
  22. package/dist/chunks/{personal-tokens-xC9wulhg.js → personal-tokens-CSHMlRHy.js} +7 -7
  23. package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
  24. package/dist/chunks/{principal-CI17XK13.js → principal-BKJxbAtE.js} +2 -2
  25. package/dist/chunks/{principal-CI17XK13.js.map → principal-BKJxbAtE.js.map} +1 -1
  26. package/dist/chunks/{principal-page-CdSeftGD.js → principal-page-COPmTDVW.js} +132 -19
  27. package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
  28. package/dist/chunks/{project-page-CHxjBE97.js → project-page-g5_n46Nz.js} +3 -3
  29. package/dist/chunks/{project-page-CHxjBE97.js.map → project-page-g5_n46Nz.js.map} +1 -1
  30. package/dist/chunks/protected-DEWeOrmI.js +77 -0
  31. package/dist/chunks/protected-DEWeOrmI.js.map +1 -0
  32. package/dist/chunks/{queries-D1JuimTu.js → queries-D4_o-bz3.js} +22 -155
  33. package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
  34. package/dist/chunks/{references-D5llUGQL.js → references-wTh_DT0M.js} +27 -23
  35. package/dist/chunks/references-wTh_DT0M.js.map +1 -0
  36. package/dist/chunks/{role-field-CoCv8wse.js → role-field-BiP09qfN.js} +5 -5
  37. package/dist/chunks/role-field-BiP09qfN.js.map +1 -0
  38. package/dist/chunks/{row-state-CYH7kZHl.js → row-state-CYhtmUkc.js} +3 -3
  39. package/dist/chunks/{row-state-CYH7kZHl.js.map → row-state-CYhtmUkc.js.map} +1 -1
  40. package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
  41. package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
  42. package/dist/chunks/{theme-rF44Wbmm.js → theme-imSolE1q.js} +3 -3
  43. package/dist/chunks/{theme-rF44Wbmm.js.map → theme-imSolE1q.js.map} +1 -1
  44. package/dist/chunks/{ui-CGdORVzW.js → ui-Q_Eczt7m.js} +7 -3
  45. package/dist/chunks/{ui-CGdORVzW.js.map → ui-Q_Eczt7m.js.map} +1 -1
  46. package/dist/chunks/{use-action-BxrHTBZw.js → use-action-BfnN-De2.js} +3 -3
  47. package/dist/chunks/{use-action-BxrHTBZw.js.map → use-action-BfnN-De2.js.map} +1 -1
  48. package/dist/chunks/{use-change-BorW2R6C.js → use-change-Cc0X4sF3.js} +6 -4
  49. package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
  50. package/dist/chunks/{use-roles-BZnJ9Cq0.js → use-roles-stcv2QFj.js} +13 -56
  51. package/dist/chunks/use-roles-stcv2QFj.js.map +1 -0
  52. package/dist/chunks/{use-shell-CPskgi1k.js → use-shell-DMhLa2sh.js} +3 -3
  53. package/dist/chunks/{use-shell-CPskgi1k.js.map → use-shell-DMhLa2sh.js.map} +1 -1
  54. package/dist/index.d.ts +23 -55
  55. package/dist/index.js +12 -31
  56. package/dist/index.js.map +1 -1
  57. package/dist/pages/account.js +12 -12
  58. package/dist/pages/account.js.map +1 -1
  59. package/dist/pages/approval.js +2 -2
  60. package/dist/pages/audit.js +173 -196
  61. package/dist/pages/audit.js.map +1 -1
  62. package/dist/pages/device-login.js +2 -2
  63. package/dist/pages/environment.js +445 -252
  64. package/dist/pages/environment.js.map +1 -1
  65. package/dist/pages/login.js +6 -15
  66. package/dist/pages/login.js.map +1 -1
  67. package/dist/pages/oauth-authorize.js +2 -2
  68. package/dist/pages/project-access.js +11 -11
  69. package/dist/pages/project-environments.js +359 -28
  70. package/dist/pages/project-environments.js.map +1 -1
  71. package/dist/pages/project-settings.js +8 -8
  72. package/dist/pages/project.js +3 -3
  73. package/dist/pages/projects.js +8 -8
  74. package/dist/pages/service-account.js +19 -16
  75. package/dist/pages/service-account.js.map +1 -1
  76. package/dist/pages/service-accounts.js +6 -7
  77. package/dist/pages/service-accounts.js.map +1 -1
  78. package/dist/pages/settings.d.ts +1 -6
  79. package/dist/pages/settings.js +155 -286
  80. package/dist/pages/settings.js.map +1 -1
  81. package/dist/pages/unregistered.js +2 -2
  82. package/dist/pages/user.js +7 -8
  83. package/dist/pages/user.js.map +1 -1
  84. package/dist/pages/users.js +6 -7
  85. package/dist/pages/users.js.map +1 -1
  86. package/package.json +8 -3
  87. package/src/components/actions-log.tsx +8 -61
  88. package/src/components/directory.tsx +10 -9
  89. package/src/components/grants.tsx +2 -2
  90. package/src/components/icons.tsx +0 -2
  91. package/src/components/offboarding.tsx +9 -16
  92. package/src/components/page.tsx +2 -3
  93. package/src/components/personal-tokens.tsx +5 -2
  94. package/src/components/principal-page.tsx +5 -4
  95. package/src/components/protected.tsx +39 -52
  96. package/src/components/references.tsx +18 -7
  97. package/src/components/role-editor.tsx +68 -99
  98. package/src/components/role-field.tsx +1 -1
  99. package/src/components/trusted-workloads.tsx +6 -5
  100. package/src/components/ui.tsx +5 -0
  101. package/src/lib/audit-proofs.ts +51 -0
  102. package/src/lib/audit-sentences.ts +490 -529
  103. package/src/lib/bindings.ts +6 -0
  104. package/src/lib/changes.ts +3 -1
  105. package/src/lib/coffre.ts +2 -2
  106. package/src/lib/queries.ts +19 -168
  107. package/src/lib/reveal.ts +32 -5
  108. package/src/lib/roles.ts +10 -36
  109. package/src/lib/row-reads.ts +2 -2
  110. package/src/lib/signin-errors.ts +5 -33
  111. package/src/options.ts +3 -19
  112. package/src/pages/account.tsx +1 -1
  113. package/src/pages/audit.tsx +151 -228
  114. package/src/pages/environment.tsx +373 -247
  115. package/src/pages/login.tsx +2 -4
  116. package/src/pages/project-environments.tsx +322 -20
  117. package/src/pages/service-accounts.tsx +1 -1
  118. package/src/pages/settings.tsx +49 -134
  119. package/src/pages/user.tsx +2 -2
  120. package/src/pages/users.tsx +1 -1
  121. package/src/parity.ts +11 -20
  122. package/src/styles/globals.css +107 -273
  123. package/dist/chunks/actions-log-DupYCEyV.js +0 -1134
  124. package/dist/chunks/actions-log-DupYCEyV.js.map +0 -1
  125. package/dist/chunks/directory-DrswWQLT.js.map +0 -1
  126. package/dist/chunks/environment-actions-8rL9Cw6X.js +0 -576
  127. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +0 -1
  128. package/dist/chunks/grants-C0cb2oii.js.map +0 -1
  129. package/dist/chunks/offboarding-C1jbG_dk.js.map +0 -1
  130. package/dist/chunks/page-CfhC9Hp1.js.map +0 -1
  131. package/dist/chunks/personal-tokens-xC9wulhg.js.map +0 -1
  132. package/dist/chunks/principal-page-CdSeftGD.js.map +0 -1
  133. package/dist/chunks/queries-D1JuimTu.js.map +0 -1
  134. package/dist/chunks/references-D5llUGQL.js.map +0 -1
  135. package/dist/chunks/role-field-CoCv8wse.js.map +0 -1
  136. package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
  137. package/dist/chunks/use-change-BorW2R6C.js.map +0 -1
  138. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +0 -1
  139. package/src/components/environment-actions.tsx +0 -508
@@ -1,19 +1,19 @@
1
- import { A as canRevealSecrets, M as isActiveAccessibleEnvironment, n as affects, o as keys, x as queries } from "../chunks/queries-D1JuimTu.js";
2
- import { a as ErrorLine, c as Notice, d as Tip, g as createCopier, h as breakAfterUnderscores, i as EmptyState, l as Spinner, n as ConfirmDialog, o as MenuPopup, r as CopyButton, s as Modal, t as ConfirmButton, u as Timestamp } from "../chunks/ui-CGdORVzW.js";
1
+ import { D as isActiveAccessibleEnvironment, T as canRevealSecrets, i as keys, t as affects, y as queries } from "../chunks/queries-D4_o-bz3.js";
2
+ import { _ as createCopier, a as ErrorLine, c as Notice, d as Tip, h as breakAfterUnderscores, i as EmptyState, l as Spinner, n as ConfirmDialog, o as MenuPopup, r as CopyButton, s as Modal, t as ConfirmButton, u as Timestamp } from "../chunks/ui-Q_Eczt7m.js";
3
3
  import { i as SecretReadOnly } from "../chunks/affordances-Dtyha68j.js";
4
- import { A as Hash, E as Folder, G as Pencil, J as RotateBack, K as Plus, N as Key, O as Generate, Q as Shuffle, R as Lock, S as Clock, T as EyeOff, U as MoreHorizontal, Y as Search, _ as Check, et as SlashCircle, g as ArrowRight, h as Archive, i as PageHeader, it as Upload, j as History, n as ClosedDoor, nt as Terminal, o as failureMessage, p as AlertCircle, t as Card, u as useCoffre, w as Eye, x as ChevronsUpDown, y as ChevronDown } from "../chunks/page-CfhC9Hp1.js";
5
- import { a as rowClass, i as RowPending, r as RowFailure, t as ItemFailure } from "../chunks/row-state-CYH7kZHl.js";
6
- import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
7
- import { A as restoreSecret, B as valueEdit, G as stricter, H as SENSITIVITIES, I as companionsOf, J as regenerateWaits, K as waitsForValue, L as hasSecretEditConflict, P as saveSecrets, R as madeSensitive, S as moveSecret, T as regenerateSecret, U as levelsIn, V as LEVELS, W as markable, Y as regeneratedKeys, _ as forkKey, a as UnsavedEdits, g as environmentId, i as changeOptions, k as restoreMissing, m as dismissMissing, n as useChangeStatus, q as liveGeneration, r as changeKey, s as archiveSecret, t as useChange, x as missingList, z as secretChangeFor } from "../chunks/use-change-BorW2R6C.js";
4
+ import { $ as SlashCircle, A as History, D as Generate, E as Folder, G as Plus, H as MoreHorizontal, J as Search, L as Lock, M as Key, S as Clock, T as EyeOff, W as Pencil, Z as Shuffle, _ as Check, g as ArrowRight, h as Archive, i as PageHeader, k as Hash, n as ClosedDoor, nt as Trash, o as failureMessage, p as AlertCircle, q as RotateBack, rt as Upload, st as X, t as Card, tt as Terminal, u as useCoffre, w as Eye, x as ChevronsUpDown, y as ChevronDown } from "../chunks/page-Cb0ZjGda.js";
5
+ import { a as rowClass, i as RowPending, r as RowFailure, t as ItemFailure } from "../chunks/row-state-CYhtmUkc.js";
6
+ import { t as useShell } from "../chunks/use-shell-DMhLa2sh.js";
7
+ import { A as restoreSecret, B as valueEdit, G as stricter, H as SENSITIVITIES, I as companionsOf, J as regenerateWaits, K as waitsForValue, L as hasSecretEditConflict, P as saveSecrets, R as madeSensitive, S as moveSecret, T as regenerateSecret, U as levelsIn, V as LEVELS, W as markable, Y as regeneratedKeys, _ as forkKey, a as UnsavedEdits, g as environmentId, i as changeOptions, k as restoreMissing, m as dismissMissing, n as useChangeStatus, q as liveGeneration, r as changeKey, s as archiveSecret, t as useChange, x as missingList, z as secretChangeFor } from "../chunks/use-change-Cc0X4sF3.js";
8
8
  import { i as secretKeyProblem, n as folderProblem } from "../chunks/validation-DiHIwZRA.js";
9
9
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
10
- import { t as useAction } from "../chunks/use-action-BxrHTBZw.js";
11
- import { r as Protection, t as EnvironmentMenu } from "../chunks/environment-actions-8rL9Cw6X.js";
12
- import { i as ReferenceValue, n as LentReferences, o as archiveBlockers, r as MakeReference, t as ArchiveBlocked } from "../chunks/references-D5llUGQL.js";
13
- import { n as FolderRow, r as MoveToFolder, t as FolderMenu } from "../chunks/folders-A6sbR_PG.js";
14
- import { t as MultiCombobox } from "../chunks/multi-combobox-B3SEv1gq.js";
10
+ import { t as useAction } from "../chunks/use-action-BfnN-De2.js";
11
+ import { t as Protection } from "../chunks/protected-DEWeOrmI.js";
12
+ import { n as FolderRow, r as MoveToFolder, t as FolderMenu } from "../chunks/folders-CVYauIDz.js";
13
+ import { t as MultiCombobox } from "../chunks/multi-combobox-fbBRzi9z.js";
14
+ import { i as ReferenceValue, n as LentReferences, o as archiveBlockers, r as MakeReference, t as ArchiveBlocked } from "../chunks/references-wTh_DT0M.js";
15
15
  import { useEffect, useId, useReducer, useRef, useState } from "react";
16
- import { Link } from "@tanstack/react-router";
16
+ import { Link, useNavigate } from "@tanstack/react-router";
17
17
  import { toast } from "sonner";
18
18
  import { Menu } from "@base-ui/react/menu";
19
19
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -23,7 +23,29 @@ import { DEFAULT_RECIPE, ENCODINGS, MAX_BYTES, MIN_BYTES, PAIRS, describeRecipe,
23
23
  import { parseDotenv } from "@coffre/core/dotenv";
24
24
  //#region src/lib/reveal.ts
25
25
  function revealIsCurrent(reveal, currentVersion, currentFrom) {
26
- return reveal !== null && reveal.version === currentVersion && reveal.from === currentFrom;
26
+ return reveal !== null && reveal.from !== null && reveal.version === currentVersion && reveal.from === currentFrom;
27
+ }
28
+ /**
29
+ * A value read for the row `row` was when asked, stamped with the version it
30
+ * opened. A read that opened another number than the row's has outrun the
31
+ * listing, or the listing it: `refetch` brings the listing up to date first,
32
+ * so that once the value shows, the row says its number too. If the listing
33
+ * has moved past it by then, the value hides, as it is no longer the value.
34
+ *
35
+ * It is stamped with the secret the read says it opened, never the row's:
36
+ * a read across a reset, an override or a repointed reference opened
37
+ * another secret, maybe at the very number the row shows by then, and
38
+ * hides rather than show that secret's value as this one's.
39
+ */
40
+ async function stampedRead(row, read, refetch) {
41
+ const { value, version, from } = await read();
42
+ if (version !== row.version || from !== row.from) await refetch();
43
+ return {
44
+ value,
45
+ version,
46
+ from,
47
+ at: Date.now()
48
+ };
27
49
  }
28
50
  //#endregion
29
51
  //#region src/lib/row-reads.ts
@@ -80,8 +102,8 @@ function revealToggleDisabled(state, shown) {
80
102
  * whose reason the row says. It always opens: writing a value takes no read
81
103
  * of the one it replaces.
82
104
  */
83
- async function valueToEdit(row, read) {
84
- if (row.value !== null) return row.value;
105
+ async function valueToEdit(row, read, listed) {
106
+ if (row.value !== null) return listed(row.value);
85
107
  return row.readable ? read() : null;
86
108
  }
87
109
  //#endregion
@@ -808,9 +830,15 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
808
830
  const [changes, setChanges] = useState({});
809
831
  const [editing, setEditing] = useState(() => /* @__PURE__ */ new Set());
810
832
  const [saveError, setSaveError] = useState(null);
811
- const [attempted, setAttempted] = useState(false);
812
- if (attempted && drafts.length === 0 && Object.keys(changes).length === 0 && editing.size === 0) setAttempted(false);
813
833
  const [hiding, setHiding] = useState(null);
834
+ function confirmingSensitive(drafts, changes, go) {
835
+ const keys = madeSensitive(active, drafts, changes);
836
+ if (keys.length === 0) go();
837
+ else setHiding({
838
+ keys,
839
+ go
840
+ });
841
+ }
814
842
  const [query, setQuery] = useState(Route.useSearch().filter ?? "");
815
843
  const [sort, setSort] = useState({
816
844
  by: "key",
@@ -894,6 +922,54 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
894
922
  return rest;
895
923
  });
896
924
  }
925
+ /**
926
+ * One row's own Save: its change alone goes, and any other row's stays
927
+ * pending. A row opened and left as it was just closes.
928
+ */
929
+ function saveRow(key) {
930
+ const change = secretChangeFor(changes, key);
931
+ if (change === void 0) return dropChange(key);
932
+ confirmingSensitive([], { [key]: change }, () => {
933
+ dropChange(key);
934
+ sendAlone({
935
+ active,
936
+ drafts: [],
937
+ changes: { [key]: change }
938
+ });
939
+ });
940
+ }
941
+ function saveDraft(draft) {
942
+ confirmingSensitive([draft], {}, () => {
943
+ setDrafts((rows) => rows.filter((row) => row.id !== draft.id));
944
+ sendAlone({
945
+ active,
946
+ drafts: [draft],
947
+ changes: {}
948
+ });
949
+ });
950
+ }
951
+ /** Whether one row's change could go alone: named, well named, and clashing with nothing. */
952
+ function readyAlone(drafts, changes) {
953
+ const names = [
954
+ ...drafts.map((row) => row.key.trim()),
955
+ ...Object.values(changes).flatMap((change) => change.archived ? [] : [change.key.trim()]),
956
+ ...companionsOf(active, drafts, changes).map((companion) => companion.key.trim())
957
+ ];
958
+ return (drafts.length > 0 || Object.keys(changes).length > 0) && names.every((name) => name !== "" && secretKeyProblem(name) === null) && !hasSecretEditConflict(active, drafts, changes) && !active.some((entry) => waitsForValue(entry, secretChangeFor(changes, entry.key)));
959
+ }
960
+ function sendAlone(batch) {
961
+ setSaveError(null);
962
+ save(batch, { onError: (error) => {
963
+ forgetRefusal(batch);
964
+ const left = error instanceof UnsavedEdits ? error.outcome : batch;
965
+ setDrafts((rows) => [...rows, ...left.drafts]);
966
+ setChanges((current) => ({
967
+ ...current,
968
+ ...left.changes
969
+ }));
970
+ setSaveError(failureMessage(error));
971
+ } });
972
+ }
897
973
  function dropChange(key) {
898
974
  setChanges((current) => {
899
975
  const { [key]: _, ...rest } = current;
@@ -918,7 +994,6 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
918
994
  setChanges({});
919
995
  setEditing(/* @__PURE__ */ new Set());
920
996
  setSaveError(null);
921
- setAttempted(false);
922
997
  }
923
998
  /**
924
999
  * A refused save leaves its rows no failure of their own: its edits come
@@ -940,12 +1015,8 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
940
1015
  * bar under the table says why.
941
1016
  */
942
1017
  function saveChanges() {
943
- if (pendingCount === 0) return;
944
- setAttempted(true);
945
1018
  if (!ready) return;
946
- const keys = madeSensitive(active, drafts, changes);
947
- if (keys.length === 0) sendChanges();
948
- else setHiding(keys);
1019
+ confirmingSensitive(drafts, changes, sendChanges);
949
1020
  }
950
1021
  function sendChanges() {
951
1022
  const batch = {
@@ -957,7 +1028,6 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
957
1028
  setChanges({});
958
1029
  setEditing(/* @__PURE__ */ new Set());
959
1030
  setSaveError(null);
960
- setAttempted(false);
961
1031
  save(batch, { onError: (error) => {
962
1032
  forgetRefusal(batch);
963
1033
  const left = error instanceof UnsavedEdits ? error.outcome : batch;
@@ -1015,31 +1085,60 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
1015
1085
  document.addEventListener("keydown", onKeyDown);
1016
1086
  return () => document.removeEventListener("keydown", onKeyDown);
1017
1087
  }, [pendingCount]);
1018
- const tally = {
1019
- added: 0,
1020
- updated: 0,
1021
- archived: 0
1022
- };
1023
- for (const draft of drafts) tally[existing.has(draft.key.trim()) ? "updated" : "added"]++;
1024
- for (const entry of changedEntries) tally[secretChangeFor(changes, entry.key).archived ? "archived" : "updated"]++;
1088
+ const withCompanion = (what, companion) => companion === void 0 ? what : `${what}, with ${companion.key.trim()}`;
1089
+ const pending = [...drafts.map((draft) => ({
1090
+ key: draft.key.trim() || "unnamed",
1091
+ what: withCompanion(existing.has(draft.key.trim()) ? "new version" : "added", draft.companion)
1092
+ })), ...changedEntries.map((entry) => {
1093
+ const change = secretChangeFor(changes, entry.key);
1094
+ if (change.archived) return {
1095
+ key: entry.key,
1096
+ what: "archived"
1097
+ };
1098
+ const renamed = change.key.trim() !== entry.key;
1099
+ const level = change.sensitivity === void 0 || change.sensitivity === entry.sensitivity ? null : change.sensitivity;
1100
+ const written = change.value === null ? level === null ? null : `made ${level}` : withCompanion(level === null ? "new value" : `new value, ${level}`, change.companion);
1101
+ if (renamed) return {
1102
+ key: entry.key,
1103
+ what: written === null ? `→ ${change.key.trim()}` : `→ ${change.key.trim()}, ${written}`
1104
+ };
1105
+ if (entry.parent !== null && entry.parent.state !== "overridden") return {
1106
+ key: entry.key,
1107
+ what: withCompanion(`overrides ${entry.parent.from}`, change.companion)
1108
+ };
1109
+ return {
1110
+ key: entry.key,
1111
+ what: written ?? "new value"
1112
+ };
1113
+ })];
1114
+ const problem = unnamed ? null : hasConflict ? "Two pending edits would end up with the same name. Secret names are unique in an environment." : invalid ? "Names are letters, digits and underscores, and cannot start with a digit." : waiting !== void 0 ? `${waiting.key} waits for its value: type it again.` : null;
1025
1115
  const needle = query.trim().toLowerCase();
1026
1116
  const listed = sortKeys(needle === "" ? active : active.filter((entry) => entry.key.toLowerCase().includes(needle)), sort);
1027
1117
  const columns = 6;
1028
- const unnamedHidden = changedEntries.some((entry) => secretChangeFor(changes, entry.key).key.trim() === "" && !listed.includes(entry));
1029
- const problem = unnamed ? attempted && unnamedHidden ? "A secret the filter hides needs a name." : null : hasConflict ? "Two pending edits would end up with the same name. Secret names are unique in an environment." : invalid ? "Names are letters, digits and underscores, and cannot start with a digit." : waiting !== void 0 ? `${waiting.key} waits for its value: type it again.` : null;
1030
1118
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1031
1119
  /* @__PURE__ */ jsx(PageHeader, {
1032
1120
  tile: project,
1033
1121
  title: environment,
1034
- aside: inProject !== void 0 && /* @__PURE__ */ jsx(Protection, { environment: inProject }),
1035
- actions: /* @__PURE__ */ jsx(EnvironmentMenu, {
1122
+ aside: inProject !== void 0 && /* @__PURE__ */ jsx(Protection, {
1123
+ project,
1124
+ environment: inProject
1125
+ }),
1126
+ actions: personal ? /* @__PURE__ */ jsx(DeletePersonal, {
1036
1127
  project,
1037
1128
  environment,
1038
- inProject,
1039
- ownConfig: principal?.type === "user" && canList && !personal,
1040
- busy: protecting.state === "pending",
1041
- follow: true,
1042
- className: "btn btn-sm btn-icon"
1129
+ of: parents[0]
1130
+ }) : principal?.type === "user" && canList && /* @__PURE__ */ jsxs(Link, {
1131
+ className: "btn btn-sm",
1132
+ to: "/projects/$project/$environment",
1133
+ params: {
1134
+ project,
1135
+ environment: `${environment}@me`
1136
+ },
1137
+ children: [
1138
+ /* @__PURE__ */ jsx(Key, { size: 14 }),
1139
+ "My own ",
1140
+ environment
1141
+ ]
1043
1142
  }),
1044
1143
  meta: protecting.state === "pending" ? /* @__PURE__ */ jsx(RowPending, { status: protecting }) : protecting.state === "failed" ? /* @__PURE__ */ jsx(ItemFailure, {
1045
1144
  status: protecting,
@@ -1247,8 +1346,9 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
1247
1346
  onEdit: () => setEditing((current) => new Set(current).add(entry.key)),
1248
1347
  onPatch: (patch) => patchChange(entry, patch),
1249
1348
  onUndo: () => dropChange(entry.key),
1349
+ onSave: () => saveRow(entry.key),
1250
1350
  versionOf,
1251
- attempted,
1351
+ saveReady: change === void 0 || readyAlone([], { [entry.key]: change }),
1252
1352
  onMarkArchive: () => {
1253
1353
  setEditing((current) => {
1254
1354
  const next = new Set(current);
@@ -1286,14 +1386,15 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
1286
1386
  ...patch
1287
1387
  } : row)),
1288
1388
  onRemove: () => setDrafts((rows) => rows.filter((row) => row.id !== draft.id)),
1389
+ onSave: () => saveDraft(draft),
1289
1390
  versionOf,
1290
- attempted
1391
+ saveReady: readyAlone([draft], {})
1291
1392
  }, draft.id))
1292
1393
  ] })]
1293
1394
  })
1294
- }), (pendingCount > 0 || editing.size > 0) && /* @__PURE__ */ jsx(PendingBar, {
1295
- tally,
1296
- canSave: pendingCount > 0,
1395
+ }), pendingCount > 0 && /* @__PURE__ */ jsx(PendingBar, {
1396
+ pending,
1397
+ ready,
1297
1398
  error: saveError ?? problem,
1298
1399
  onDiscard: discardAll,
1299
1400
  onSave: saveChanges
@@ -1302,20 +1403,21 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
1302
1403
  /* @__PURE__ */ jsx(ConfirmDialog, {
1303
1404
  open: hiding !== null,
1304
1405
  onOpenChange: (open) => !open && setHiding(null),
1305
- title: hiding?.length === 1 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1406
+ title: hiding?.keys.length === 1 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1306
1407
  "Make ",
1307
1408
  /* @__PURE__ */ jsx("span", {
1308
1409
  className: "mono",
1309
- children: hiding[0]
1410
+ children: hiding.keys[0]
1310
1411
  }),
1311
1412
  " sensitive?"
1312
- ] }) : `Make ${hiding?.length ?? 0} keys sensitive?`,
1313
- body: `${hiding !== null && hiding.length > 1 ? `${hiding.join(", ")}: n` : "N"}obody, Owners included, will see ${hiding?.length === 1 ? "this value" : "these values"} again. Apps use ${hiding?.length === 1 ? "it" : "them"} through the proxy; service accounts still read ${hiding?.length === 1 ? "it" : "them"}.`,
1413
+ ] }) : `Make ${hiding?.keys.length ?? 0} keys sensitive?`,
1414
+ body: `${hiding !== null && hiding.keys.length > 1 ? `${hiding.keys.join(", ")}: n` : "N"}obody, Owners included, will see ${hiding?.keys.length === 1 ? "this value" : "these values"} again. Apps use ${hiding?.keys.length === 1 ? "it" : "them"} through the proxy; service accounts still read ${hiding?.keys.length === 1 ? "it" : "them"}.`,
1314
1415
  confirmLabel: "Make sensitive",
1315
1416
  destructive: false,
1316
1417
  onConfirm: () => {
1418
+ const go = hiding?.go;
1317
1419
  setHiding(null);
1318
- sendChanges();
1420
+ go?.();
1319
1421
  }
1320
1422
  }),
1321
1423
  canWrite && /* @__PURE__ */ jsxs("div", {
@@ -1403,19 +1505,12 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, pa
1403
1505
  ] });
1404
1506
  }
1405
1507
  /**
1406
- * The pending edits, at the foot of the table they are made in: how many
1407
- * secrets they add, update and archive, Discard and Save, which go for the
1408
- * whole table at once. It shows while any row is open for editing, so an
1409
- * edit opened and left as it was has its Discard too. It sticks to the
1410
- * bottom of the window while the table runs past it, so Save stays in
1411
- * reach of any row.
1508
+ * The pending edits, at the foot of the table they are made in: what they
1509
+ * are, Discard and Save. It sticks to the bottom of the window while the
1510
+ * table runs past it, so Save stays in reach of any row.
1412
1511
  */
1413
- function PendingBar({ tally, canSave, error, onDiscard, onSave }) {
1414
- const parts = [
1415
- "added",
1416
- "updated",
1417
- "archived"
1418
- ].filter((what) => tally[what] > 0).map((what) => `${tally[what]} ${what}`);
1512
+ function PendingBar({ pending, ready, error, onDiscard, onSave }) {
1513
+ const count = pending.length;
1419
1514
  return /* @__PURE__ */ jsxs("div", {
1420
1515
  className: "pending-bar",
1421
1516
  role: "region",
@@ -1423,10 +1518,27 @@ function PendingBar({ tally, canSave, error, onDiscard, onSave }) {
1423
1518
  children: [
1424
1519
  /* @__PURE__ */ jsxs("span", {
1425
1520
  className: "pending-count",
1426
- children: [/* @__PURE__ */ jsx("span", {
1427
- className: "dot",
1428
- "aria-hidden": true
1429
- }), parts.length === 0 ? "No changes yet" : parts.join(", ")]
1521
+ children: [
1522
+ /* @__PURE__ */ jsx("span", {
1523
+ className: "dot",
1524
+ "aria-hidden": true
1525
+ }),
1526
+ count,
1527
+ " unsaved change",
1528
+ count === 1 ? "" : "s"
1529
+ ]
1530
+ }),
1531
+ /* @__PURE__ */ jsxs("span", {
1532
+ className: "pending-summary",
1533
+ children: [pending.slice(0, 3).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [
1534
+ index > 0 && " · ",
1535
+ /* @__PURE__ */ jsx("span", {
1536
+ className: "mono",
1537
+ children: item.key
1538
+ }),
1539
+ " ",
1540
+ item.what
1541
+ ] }, `${item.key}:${index}`)), count > 3 && ` · and ${count - 3} more`]
1430
1542
  }),
1431
1543
  /* @__PURE__ */ jsxs("div", {
1432
1544
  className: "pending-actions",
@@ -1434,13 +1546,13 @@ function PendingBar({ tally, canSave, error, onDiscard, onSave }) {
1434
1546
  className: "btn btn-sm",
1435
1547
  onClick: onDiscard,
1436
1548
  children: "Discard"
1437
- }), /* @__PURE__ */ jsx("button", {
1549
+ }), /* @__PURE__ */ jsxs("button", {
1438
1550
  className: "btn btn-sm btn-primary",
1439
1551
  onClick: onSave,
1440
- disabled: !canSave,
1552
+ disabled: !ready,
1441
1553
  title: "Save (⌘ Enter or Ctrl Enter)",
1442
1554
  "aria-keyshortcuts": "Meta+Enter Control+Enter",
1443
- children: "Save"
1555
+ children: ["Save ", count === 1 ? "change" : `${count} changes`]
1444
1556
  })]
1445
1557
  }),
1446
1558
  error !== null && /* @__PURE__ */ jsxs("p", {
@@ -1565,10 +1677,9 @@ function AddFolder({ open, onOpenChange, keys, folders, onAdd }) {
1565
1677
  });
1566
1678
  }
1567
1679
  var lineCount = (text) => text.split("\n").length;
1568
- function ValueField({ label, value, start = "", onChange, placeholder, disabled, autoFocus, onEscape, generate, level, showable }) {
1680
+ function ValueField({ label, value, start = "", onChange, placeholder, disabled, autoFocus, onEscape, generate, plain = false }) {
1569
1681
  const [shown, setShown] = useState(false);
1570
1682
  const [generating, setGenerating] = useState(false);
1571
- const plain = level.value === "plain";
1572
1683
  const [lines, setLines] = useState(() => start.includes("\n") || value.includes("\n"));
1573
1684
  if (!lines && value.includes("\n")) setLines(true);
1574
1685
  const caret = useRef(null);
@@ -1592,7 +1703,7 @@ function ValueField({ label, value, start = "", onChange, placeholder, disabled,
1592
1703
  }
1593
1704
  };
1594
1705
  return /* @__PURE__ */ jsxs("div", {
1595
- className: "value-field",
1706
+ className: "input-group has-generate",
1596
1707
  children: [
1597
1708
  lines ? /* @__PURE__ */ jsx(MaskedTextarea, {
1598
1709
  ...field,
@@ -1619,36 +1730,24 @@ function ValueField({ label, value, start = "", onChange, placeholder, disabled,
1619
1730
  } else field.onKeyDown(event);
1620
1731
  }
1621
1732
  }),
1622
- /* @__PURE__ */ jsxs("div", {
1623
- className: "value-field-controls",
1624
- children: [
1625
- /* @__PURE__ */ jsx(SensitivityMenu, {
1626
- name: level.name,
1627
- value: level.value,
1628
- levels: level.levels,
1629
- disabled,
1630
- onChange: level.onChange
1631
- }),
1632
- /* @__PURE__ */ jsx(Tip, {
1633
- label: "Generate a value",
1634
- children: /* @__PURE__ */ jsx("button", {
1635
- type: "button",
1636
- className: "btn btn-quiet btn-sm btn-icon",
1637
- "aria-label": `Generate a value for ${generate.name.trim() === "" ? "the new secret" : generate.name.trim()}`,
1638
- disabled,
1639
- onClick: () => setGenerating(true),
1640
- children: /* @__PURE__ */ jsx(Generate, { size: 14 })
1641
- })
1642
- }),
1643
- showable && !plain && /* @__PURE__ */ jsx("button", {
1644
- type: "button",
1645
- className: "btn btn-quiet btn-sm btn-icon",
1646
- "aria-label": shown ? "Mask the value" : "Show the value",
1647
- "aria-pressed": shown,
1648
- onClick: () => setShown((current) => !current),
1649
- children: shown ? /* @__PURE__ */ jsx(EyeOff, { size: 14 }) : /* @__PURE__ */ jsx(Eye, { size: 14 })
1650
- })
1651
- ]
1733
+ /* @__PURE__ */ jsx(Tip, {
1734
+ label: "Generate a value",
1735
+ children: /* @__PURE__ */ jsx("button", {
1736
+ type: "button",
1737
+ className: "btn btn-quiet btn-sm btn-icon input-addon input-addon-generate",
1738
+ "aria-label": `Generate a value for ${generate.name.trim() === "" ? "the new secret" : generate.name.trim()}`,
1739
+ disabled,
1740
+ onClick: () => setGenerating(true),
1741
+ children: /* @__PURE__ */ jsx(Generate, { size: 14 })
1742
+ })
1743
+ }),
1744
+ !plain && /* @__PURE__ */ jsx("button", {
1745
+ type: "button",
1746
+ className: "btn btn-quiet btn-sm btn-icon input-addon",
1747
+ "aria-label": shown ? "Mask the value" : "Show the value",
1748
+ "aria-pressed": shown,
1749
+ onClick: () => setShown((current) => !current),
1750
+ children: shown ? /* @__PURE__ */ jsx(EyeOff, { size: 14 }) : /* @__PURE__ */ jsx(Eye, { size: 14 })
1652
1751
  }),
1653
1752
  /* @__PURE__ */ jsx(GenerateValue, {
1654
1753
  open: generating,
@@ -1688,7 +1787,7 @@ function useSecondsLeft(reveal) {
1688
1787
  if (reveal === null) return 0;
1689
1788
  return Math.max(0, Math.ceil(REVEAL_TTL_SECONDS - (now - reveal.at) / 1e3));
1690
1789
  }
1691
- function SecretRow({ number, project, environment, entry, generated, busy, onRegenerate, rotateAfterDays, change, editing, canWrite, canArchive, canReveal, canList, canLoosen, folders, onMove, lent, environments, status, disabled, onDismiss, columns, onFork, onEdit, onPatch, onUndo, versionOf, attempted, onMarkArchive, personal }) {
1790
+ function SecretRow({ number, project, environment, entry, generated, busy, onRegenerate, rotateAfterDays, change, editing, canWrite, canArchive, canReveal, canList, canLoosen, folders, onMove, lent, environments, status, disabled, onDismiss, columns, onFork, onEdit, onPatch, onUndo, onSave, versionOf, saveReady, onMarkArchive, personal }) {
1692
1791
  const [reads, dispatch] = useReducer(rowReads, noReads);
1693
1792
  const { reveal, revealing, error, copyError } = reads;
1694
1793
  const setReveal = (next) => dispatch({
@@ -1696,6 +1795,7 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1696
1795
  reveal: next
1697
1796
  });
1698
1797
  const coffre = useCoffre();
1798
+ const queryClient = useQueryClient();
1699
1799
  const [historyOpen, setHistoryOpen] = useState(false);
1700
1800
  const [moving, setMoving] = useState(false);
1701
1801
  const [referring, setReferring] = useState(false);
@@ -1715,7 +1815,7 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1715
1815
  const sensitive = entry.sensitivity === "sensitive";
1716
1816
  const canRead = entry.readable;
1717
1817
  const readVersion = reference === null ? entry.version : reference.version;
1718
- const readFrom = `${inherited ? parent.from : "."}:${reference?.source ?? ""}`;
1818
+ const readFrom = entry.secret;
1719
1819
  const holderPath = `${project}/${environment}/${entry.key}`;
1720
1820
  const rowPlain = entry.value !== null;
1721
1821
  const rowLevel = entry.sensitivity;
@@ -1745,20 +1845,21 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1745
1845
  if (!editing) setBase(null);
1746
1846
  }, [editing]);
1747
1847
  async function readValue({ show = true } = {}) {
1748
- if (shown !== null) return shown.value;
1848
+ if (shown !== null) return shown;
1749
1849
  dispatch({ type: "read-started" });
1750
1850
  try {
1751
- const value = await fetchValue();
1851
+ const read = await stampedRead({
1852
+ version: readVersion,
1853
+ from: readFrom
1854
+ }, fetchValue, () => queryClient.refetchQueries({ queryKey: keys.secrets({
1855
+ project,
1856
+ environment
1857
+ }) }));
1752
1858
  dispatch({
1753
1859
  type: "read-succeeded",
1754
- reveal: show ? {
1755
- value,
1756
- version: readVersion,
1757
- from: readFrom,
1758
- at: Date.now()
1759
- } : null
1860
+ reveal: show ? read : null
1760
1861
  });
1761
- return value;
1862
+ return read;
1762
1863
  } catch (failure) {
1763
1864
  dispatch({
1764
1865
  type: "read-failed",
@@ -1768,9 +1869,17 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1768
1869
  }
1769
1870
  }
1770
1871
  async function fetchValue() {
1771
- if (entry.value !== null) return entry.value;
1772
- const { values } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
1773
- return values[entry.key];
1872
+ if (entry.value !== null) return {
1873
+ value: entry.value,
1874
+ version: readVersion,
1875
+ from: readFrom
1876
+ };
1877
+ const { values, versions, secrets } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
1878
+ return {
1879
+ value: values[entry.key],
1880
+ version: versions[entry.key],
1881
+ from: secrets[entry.key]
1882
+ };
1774
1883
  }
1775
1884
  function toggleReveal() {
1776
1885
  if (shown !== null) setReveal(null);
@@ -1780,7 +1889,7 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1780
1889
  function copyValue() {
1781
1890
  dispatch({ type: "copy-started" });
1782
1891
  const read = { failed: false };
1783
- const text = shown !== null ? shown.value : fetchValue().catch((failure) => {
1892
+ const text = shown !== null ? shown.value : fetchValue().then(({ value }) => value, (failure) => {
1784
1893
  read.failed = true;
1785
1894
  read.failure = failure;
1786
1895
  throw failure;
@@ -1798,14 +1907,14 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1798
1907
  async function startEdit({ name = false } = {}) {
1799
1908
  setFocusName(name);
1800
1909
  setOpening(entry.value === null && canRead);
1801
- const value = await valueToEdit(entry, () => readValue({ show: false }));
1802
- setOpening(false);
1803
- if (value !== null) setBase({
1804
- value,
1910
+ const value = await valueToEdit(entry, () => readValue({ show: false }), (listed) => ({
1911
+ value: listed,
1805
1912
  version: readVersion,
1806
1913
  from: readFrom,
1807
1914
  at: Date.now()
1808
- });
1915
+ }));
1916
+ setOpening(false);
1917
+ if (value !== null) setBase(value);
1809
1918
  setReveal(null);
1810
1919
  onEdit();
1811
1920
  }
@@ -1833,12 +1942,12 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1833
1942
  const leaving = change.archived;
1834
1943
  const renamed = change.key !== entry.key;
1835
1944
  const valueChanged = change.value !== null || change.sensitivity !== void 0;
1836
- const keyProblem = editing ? nameProblem(change.key.trim(), attempted) : null;
1945
+ const keyProblem = editing ? secretKeyProblem(change.key.trim()) : null;
1837
1946
  const state = leaving ? " is-leaving" : editing && (renamed || valueChanged) ? " is-changed" : shown !== null ? " is-revealed" : removed ? " is-removed" : inherited ? " is-inherited" : "";
1838
1947
  const version = entry.version ?? 0;
1839
1948
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1840
1949
  /* @__PURE__ */ jsxs("tr", {
1841
- className: `secret-row${state}${editing ? " is-editing" : ""} ${rowClass(status)}`,
1950
+ className: `secret-row${state} ${rowClass(status)}`,
1842
1951
  children: [
1843
1952
  /* @__PURE__ */ jsx("td", {
1844
1953
  className: "n",
@@ -1924,6 +2033,7 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1924
2033
  value: change.value ?? (loosening ? "" : editBase?.value ?? ""),
1925
2034
  start: loosening ? void 0 : editBase?.value,
1926
2035
  placeholder: loosening ? "Its value, typed again" : editBase !== null ? "Value" : sensitive ? "Type a new value" : error !== null ? "New value; the current one could not be read" : canRead ? "New value" : "New value; the current one is hidden from you",
2036
+ plain: level === "plain",
1927
2037
  disabled,
1928
2038
  autoFocus: !focusName,
1929
2039
  onChange: (value) => onPatch({
@@ -1945,23 +2055,23 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
1945
2055
  recipe,
1946
2056
  sensitivity: level === "plain" ? "secret" : level
1947
2057
  })
1948
- },
1949
- level: {
1950
- name: change.key.trim() === "" ? entry.key : change.key.trim(),
1951
- value: level,
1952
- levels: levelsIn(personal),
1953
- onChange: (next) => onPatch({
1954
- ...valueEdit(from(), {
1955
- value: change.value,
1956
- sensitivity: next
1957
- }),
1958
- ...next === "plain" ? {
1959
- companion: void 0,
1960
- recipe: void 0
1961
- } : {}
1962
- })
1963
- },
1964
- showable: true
2058
+ }
2059
+ }),
2060
+ /* @__PURE__ */ jsx(SensitivityField, {
2061
+ name: change.key.trim() === "" ? entry.key : change.key.trim(),
2062
+ value: level,
2063
+ levels: levelsIn(personal),
2064
+ disabled,
2065
+ onChange: (next) => onPatch({
2066
+ ...valueEdit(from(), {
2067
+ value: change.value,
2068
+ sensitivity: next
2069
+ }),
2070
+ ...next === "plain" ? {
2071
+ companion: void 0,
2072
+ recipe: void 0
2073
+ } : {}
2074
+ })
1965
2075
  }),
1966
2076
  waitsForValue(entry, change) && /* @__PURE__ */ jsx("span", {
1967
2077
  className: "edit-note",
@@ -2019,9 +2129,27 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
2019
2129
  "aria-label": sensitive ? "Never shown" : "Hidden",
2020
2130
  children: "••••••••••••"
2021
2131
  })
2022
- }), status.state !== "pending" && !editing && !leaving && /* @__PURE__ */ jsx("div", {
2132
+ }), status.state !== "pending" && /* @__PURE__ */ jsx("div", {
2023
2133
  className: "acts value-acts",
2024
- children: removed ? canWrite && /* @__PURE__ */ jsx("button", {
2134
+ children: editing || leaving ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tip, {
2135
+ label: leaving ? "Archive now" : "Save",
2136
+ children: /* @__PURE__ */ jsx("button", {
2137
+ className: "act act-icon act-accent",
2138
+ onClick: onSave,
2139
+ disabled: disabled || !saveReady,
2140
+ "aria-label": `${leaving ? "Archive" : "Save"} ${entry.key} now`,
2141
+ children: /* @__PURE__ */ jsx(Check, { size: 15 })
2142
+ })
2143
+ }), /* @__PURE__ */ jsx(Tip, {
2144
+ label: leaving ? "Keep" : "Cancel",
2145
+ children: /* @__PURE__ */ jsx("button", {
2146
+ className: "act act-icon act-quiet",
2147
+ onClick: onUndo,
2148
+ disabled,
2149
+ "aria-label": leaving ? `Keep ${entry.key}` : `Cancel editing ${entry.key}`,
2150
+ children: /* @__PURE__ */ jsx(X, { size: 15 })
2151
+ })
2152
+ })] }) : removed ? canWrite && /* @__PURE__ */ jsx("button", {
2025
2153
  type: "button",
2026
2154
  className: "btn btn-sm",
2027
2155
  onClick: () => onFork("restore"),
@@ -2087,7 +2215,7 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
2087
2215
  }),
2088
2216
  /* @__PURE__ */ jsx("td", {
2089
2217
  className: "col-actions",
2090
- children: status.state === "pending" ? /* @__PURE__ */ jsx(RowPending, { status }) : !removed && (canList || leaving || canWrite && !editing && !leaving || canArchive && !leaving && own && !overridden) && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
2218
+ children: status.state === "pending" ? /* @__PURE__ */ jsx(RowPending, { status }) : !removed && (canList || canWrite && !editing && !leaving || canArchive && !leaving && own && !overridden) && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
2091
2219
  className: "act act-icon act-quiet",
2092
2220
  "aria-label": `More for ${entry.key}`,
2093
2221
  disabled,
@@ -2159,16 +2287,28 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
2159
2287
  onClick: () => setBreaking(holderPath),
2160
2288
  children: [/* @__PURE__ */ jsx(SlashCircle, { size: 14 }), "Break reference…"]
2161
2289
  }),
2162
- canWrite && !editing && !leaving && markable(entry) && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }), /* @__PURE__ */ jsx(SensitivityItems, {
2290
+ canWrite && !editing && !leaving && markable(entry) && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }), /* @__PURE__ */ jsxs(Menu.RadioGroup, {
2163
2291
  value: entry.sensitivity,
2164
- levels: levelsIn(personal),
2165
- onChange: chooseLevel
2292
+ onValueChange: (next) => chooseLevel(next),
2293
+ children: [/* @__PURE__ */ jsx(Menu.GroupLabel, {
2294
+ className: "menu-label",
2295
+ children: "Who sees it"
2296
+ }), SENSITIVITIES.map((each) => /* @__PURE__ */ jsxs(Menu.RadioItem, {
2297
+ value: each,
2298
+ className: "menu-item menu-item-level",
2299
+ closeOnClick: true,
2300
+ children: [/* @__PURE__ */ jsxs("span", {
2301
+ className: "menu-item-text",
2302
+ children: [levelsIn(personal)[each].label, /* @__PURE__ */ jsx("span", {
2303
+ className: "menu-item-hint",
2304
+ children: levelsIn(personal)[each].hint
2305
+ })]
2306
+ }), /* @__PURE__ */ jsx(Menu.RadioItemIndicator, {
2307
+ className: "menu-check",
2308
+ children: /* @__PURE__ */ jsx(Check, { size: 14 })
2309
+ })]
2310
+ }, each))]
2166
2311
  })] }),
2167
- leaving && /* @__PURE__ */ jsxs(Menu.Item, {
2168
- className: "menu-item",
2169
- onClick: onUndo,
2170
- children: [/* @__PURE__ */ jsx(RotateBack, { size: 14 }), "Don't archive"]
2171
- }),
2172
2312
  canArchive && !leaving && own && !overridden && /* @__PURE__ */ jsxs(Fragment$1, { children: [(canReveal || canWrite) && /* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }), /* @__PURE__ */ jsxs(Menu.Item, {
2173
2313
  className: "menu-item menu-item-danger",
2174
2314
  onClick: () => {
@@ -2327,6 +2467,52 @@ function SecretRow({ number, project, environment, entry, generated, busy, onReg
2327
2467
  })
2328
2468
  ] });
2329
2469
  }
2470
+ /** Delete your personal config, from its page: its values erased; dev itself untouched. */
2471
+ function DeletePersonal({ project, environment, of }) {
2472
+ const coffre = useCoffre();
2473
+ const navigate = useNavigate();
2474
+ const [open, setOpen] = useState(false);
2475
+ const { error, run } = useAction();
2476
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2477
+ /* @__PURE__ */ jsxs("button", {
2478
+ type: "button",
2479
+ className: "btn btn-sm",
2480
+ onClick: () => setOpen(true),
2481
+ children: [/* @__PURE__ */ jsx(Trash, { size: 14 }), "Delete…"]
2482
+ }),
2483
+ error !== null && /* @__PURE__ */ jsx(ErrorLine, { error }),
2484
+ /* @__PURE__ */ jsx(ConfirmDialog, {
2485
+ open,
2486
+ onOpenChange: setOpen,
2487
+ title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
2488
+ "Delete your own ",
2489
+ /* @__PURE__ */ jsx("span", {
2490
+ className: "mono",
2491
+ children: of
2492
+ }),
2493
+ "?"
2494
+ ] }),
2495
+ body: `The values you set in ${project}/${environment} are erased for good. ${project}/${of} is untouched, and ${environment} reads it again.`,
2496
+ confirmLabel: "Delete",
2497
+ onConfirm: () => void run(() => coffre.environments.delete(`${project}/${environment}`), {
2498
+ affects: [...affects.secrets({
2499
+ project,
2500
+ environment
2501
+ }), ...affects.places()],
2502
+ onSuccess: () => {
2503
+ toast.success(`Your own ${of} is deleted`);
2504
+ navigate({
2505
+ to: "/projects/$project/$environment",
2506
+ params: {
2507
+ project,
2508
+ environment: of
2509
+ }
2510
+ });
2511
+ }
2512
+ })
2513
+ })
2514
+ ] });
2515
+ }
2330
2516
  /**
2331
2517
  * `dev@me` while you have no personal dev: what one is, and Make, which
2332
2518
  * makes it empty; your first write would make it too. A read of
@@ -2465,7 +2651,7 @@ function SortHeader({ className, by, sort, onSort, children }) {
2465
2651
  */
2466
2652
  function Written({ entry, rotateAfterDays }) {
2467
2653
  const { reference } = entry;
2468
- const made = reference === null ? void 0 : `Reference made by ${shownMember(reference.createdBy).replace(/^user:/, "")} on ${reference.createdAt.slice(0, 10)}`;
2654
+ const made = reference?.createdBy == null || reference.createdAt === null ? void 0 : `Reference made by ${shownMember(reference.createdBy).replace(/^user:/, "")} on ${reference.createdAt.slice(0, 10)}`;
2469
2655
  if (entry.updatedAt === null) return /* @__PURE__ */ jsx("span", {
2470
2656
  className: "cell-muted",
2471
2657
  title: made,
@@ -2483,7 +2669,7 @@ function Written({ entry, rotateAfterDays }) {
2483
2669
  children: by.split("@")[0]
2484
2670
  }) : /* @__PURE__ */ jsx("span", {
2485
2671
  className: "written-by cell-muted",
2486
- title: `Its source's current version. ${made}`,
2672
+ title: made === void 0 ? "Its source's current version" : `Its source's current version. ${made}`,
2487
2673
  children: "source"
2488
2674
  }),
2489
2675
  /* @__PURE__ */ jsx("span", {
@@ -2510,57 +2696,37 @@ function Written({ entry, rotateAfterDays }) {
2510
2696
  });
2511
2697
  }
2512
2698
  /**
2513
- * Who sees the value being written, as a menu inside its field: the
2514
- * trigger names the level chosen, and each choice says what it means.
2699
+ * Who sees the value being written, loosest first, and beside it what the
2700
+ * level pointed at, or else the one chosen, means. Native radios: the arrow
2701
+ * keys move the choice, and a screen reader hears one group of three.
2515
2702
  */
2516
- function SensitivityMenu({ name, value, levels, disabled, onChange }) {
2517
- return /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsxs(Menu.Trigger, {
2518
- className: "value-level",
2519
- "aria-label": `Who sees ${name}: ${levels[value].label}`,
2520
- disabled,
2521
- children: [
2522
- value === "sensitive" && /* @__PURE__ */ jsx(Lock, {
2523
- size: 11,
2524
- "aria-hidden": true
2525
- }),
2526
- levels[value].label,
2527
- /* @__PURE__ */ jsx(ChevronDown, {
2528
- size: 12,
2529
- "aria-hidden": true
2530
- })
2531
- ]
2532
- }), /* @__PURE__ */ jsx(MenuPopup, {
2533
- align: "end",
2534
- children: /* @__PURE__ */ jsx(SensitivityItems, {
2535
- value,
2536
- levels,
2537
- onChange
2538
- })
2539
- })] });
2540
- }
2541
- /** The levels as a menu's radio group, loosest first, each with what it means. */
2542
- function SensitivityItems({ value, levels, onChange }) {
2543
- return /* @__PURE__ */ jsxs(Menu.RadioGroup, {
2544
- value,
2545
- onValueChange: (next) => onChange(next),
2546
- children: [/* @__PURE__ */ jsx(Menu.GroupLabel, {
2547
- className: "menu-label",
2548
- children: "Who sees it"
2549
- }), SENSITIVITIES.map((each) => /* @__PURE__ */ jsxs(Menu.RadioItem, {
2550
- value: each,
2551
- className: "menu-item menu-item-level",
2552
- closeOnClick: true,
2553
- children: [/* @__PURE__ */ jsxs("span", {
2554
- className: "menu-item-text",
2555
- children: [levels[each].label, /* @__PURE__ */ jsx("span", {
2556
- className: "menu-item-hint",
2557
- children: levels[each].hint
2558
- })]
2559
- }), /* @__PURE__ */ jsx(Menu.RadioItemIndicator, {
2560
- className: "menu-check",
2561
- children: /* @__PURE__ */ jsx(Check, { size: 14 })
2562
- })]
2563
- }, each))]
2703
+ function SensitivityField({ name, value, levels, disabled, onChange }) {
2704
+ const id = useId();
2705
+ const [pointed, setPointed] = useState(null);
2706
+ return /* @__PURE__ */ jsxs("div", {
2707
+ className: "edit-note sensitivity-field",
2708
+ children: [/* @__PURE__ */ jsx("div", {
2709
+ className: "segmented segmented-sm",
2710
+ role: "radiogroup",
2711
+ "aria-label": `Who sees ${name}`,
2712
+ "aria-describedby": `${id}-hint`,
2713
+ children: SENSITIVITIES.map((level) => /* @__PURE__ */ jsxs("label", {
2714
+ onPointerEnter: () => setPointed(level),
2715
+ onPointerLeave: () => setPointed(null),
2716
+ children: [/* @__PURE__ */ jsx("input", {
2717
+ type: "radio",
2718
+ className: "visually-hidden",
2719
+ name: id,
2720
+ value: level,
2721
+ checked: value === level,
2722
+ disabled,
2723
+ onChange: () => onChange(level)
2724
+ }), levels[level].label]
2725
+ }, level))
2726
+ }), /* @__PURE__ */ jsx("span", {
2727
+ id: `${id}-hint`,
2728
+ children: levels[pointed ?? value].hint
2729
+ })]
2564
2730
  });
2565
2731
  }
2566
2732
  /**
@@ -2568,15 +2734,15 @@ function SensitivityItems({ value, levels, onChange }) {
2568
2734
  *
2569
2735
  * This replaced a separate "Add a secret" form. The form made you look away
2570
2736
  * from the list to add to it, and only ever accepted one key at a time; a row
2571
- * in place accepts as many as you want to queue, saved together from the
2572
- * bar under the table.
2737
+ * in place accepts as many as you want to queue.
2573
2738
  */
2574
- function DraftRow({ draft, existingVersion, disabled, onChange, onRemove, versionOf, attempted, personal }) {
2739
+ function DraftRow({ draft, existingVersion, disabled, onChange, onRemove, onSave, versionOf, saveReady, personal }) {
2740
+ const [touched, setTouched] = useState(false);
2575
2741
  const trimmed = draft.key.trim();
2576
- const keyProblem = nameProblem(trimmed, attempted);
2742
+ const keyProblem = trimmed === "" ? touched ? "Give it a name." : null : secretKeyProblem(trimmed);
2577
2743
  const isNewVersion = trimmed !== "" && existingVersion !== null;
2578
2744
  return /* @__PURE__ */ jsxs("tr", {
2579
- className: "secret-row is-draft is-editing",
2745
+ className: "secret-row is-draft",
2580
2746
  children: [
2581
2747
  /* @__PURE__ */ jsx("td", {
2582
2748
  className: "n",
@@ -2598,57 +2764,89 @@ function DraftRow({ draft, existingVersion, disabled, onChange, onRemove, versio
2598
2764
  autoComplete: "off",
2599
2765
  value: draft.key,
2600
2766
  disabled,
2767
+ onBlur: () => setTouched(true),
2601
2768
  onChange: (event) => onChange({ key: event.target.value }),
2602
2769
  onKeyDown: (event) => {
2603
2770
  if (event.key === "Escape") onRemove();
2604
2771
  }
2605
2772
  }), (keyProblem !== null || isNewVersion) && /* @__PURE__ */ jsx("span", {
2606
2773
  className: `edit-note${keyProblem !== null ? " edit-note-error" : ""}`,
2607
- children: keyProblem ?? "Exists here already: saving adds a version."
2774
+ children: keyProblem ?? "This name exists here already. Saving adds a new version to it."
2608
2775
  })]
2609
2776
  })
2610
2777
  }),
2611
2778
  /* @__PURE__ */ jsx("td", {
2612
2779
  "data-label": "Value",
2613
2780
  children: /* @__PURE__ */ jsxs("div", {
2614
- className: "edit-stack",
2615
- children: [/* @__PURE__ */ jsx(ValueField, {
2616
- label: `Value for ${trimmed === "" ? "the new secret" : trimmed}`,
2617
- value: draft.value,
2618
- placeholder: "Value",
2619
- disabled,
2620
- onChange: (value) => onChange({
2621
- value,
2622
- companion: void 0,
2623
- recipe: void 0
2624
- }),
2625
- onEscape: onRemove,
2626
- generate: {
2627
- name: draft.key,
2628
- renamable: true,
2629
- companion: draft.companion,
2630
- onUse: ({ value, name, companion, recipe }) => onChange({
2631
- key: name,
2632
- value,
2633
- companion,
2634
- recipe,
2635
- sensitivity: draft.sensitivity === "plain" ? "secret" : draft.sensitivity
2781
+ className: "value-cell",
2782
+ children: [/* @__PURE__ */ jsx("div", {
2783
+ className: "value-content",
2784
+ children: /* @__PURE__ */ jsxs("div", {
2785
+ className: "edit-stack",
2786
+ children: [
2787
+ /* @__PURE__ */ jsx(ValueField, {
2788
+ label: `Value for ${trimmed === "" ? "the new secret" : trimmed}`,
2789
+ value: draft.value,
2790
+ plain: draft.sensitivity === "plain",
2791
+ placeholder: "Value",
2792
+ disabled,
2793
+ onChange: (value) => onChange({
2794
+ value,
2795
+ companion: void 0,
2796
+ recipe: void 0
2797
+ }),
2798
+ onEscape: onRemove,
2799
+ generate: {
2800
+ name: draft.key,
2801
+ renamable: true,
2802
+ companion: draft.companion,
2803
+ onUse: ({ value, name, companion, recipe }) => onChange({
2804
+ key: name,
2805
+ value,
2806
+ companion,
2807
+ recipe,
2808
+ sensitivity: draft.sensitivity === "plain" ? "secret" : draft.sensitivity
2809
+ })
2810
+ }
2811
+ }),
2812
+ /* @__PURE__ */ jsx(SensitivityField, {
2813
+ name: trimmed === "" ? "the new secret" : trimmed,
2814
+ value: draft.sensitivity,
2815
+ levels: levelsIn(personal),
2816
+ disabled,
2817
+ onChange: (sensitivity) => onChange(sensitivity === "plain" ? {
2818
+ sensitivity,
2819
+ companion: void 0,
2820
+ recipe: void 0
2821
+ } : { sensitivity })
2822
+ }),
2823
+ /* @__PURE__ */ jsx(CompanionNote, {
2824
+ companion: draft.companion,
2825
+ versionOf
2826
+ })
2827
+ ]
2828
+ })
2829
+ }), /* @__PURE__ */ jsxs("div", {
2830
+ className: "acts value-acts",
2831
+ children: [/* @__PURE__ */ jsx(Tip, {
2832
+ label: "Save",
2833
+ children: /* @__PURE__ */ jsx("button", {
2834
+ className: "act act-icon act-accent",
2835
+ onClick: onSave,
2836
+ disabled: disabled || !saveReady,
2837
+ "aria-label": trimmed === "" ? "Save this new secret now" : `Save ${trimmed} now`,
2838
+ children: /* @__PURE__ */ jsx(Check, { size: 15 })
2636
2839
  })
2637
- },
2638
- level: {
2639
- name: trimmed === "" ? "the new secret" : trimmed,
2640
- value: draft.sensitivity,
2641
- levels: levelsIn(personal),
2642
- onChange: (sensitivity) => onChange(sensitivity === "plain" ? {
2643
- sensitivity,
2644
- companion: void 0,
2645
- recipe: void 0
2646
- } : { sensitivity })
2647
- },
2648
- showable: false
2649
- }), /* @__PURE__ */ jsx(CompanionNote, {
2650
- companion: draft.companion,
2651
- versionOf
2840
+ }), /* @__PURE__ */ jsx(Tip, {
2841
+ label: "Cancel",
2842
+ children: /* @__PURE__ */ jsx("button", {
2843
+ className: "act act-icon act-quiet",
2844
+ onClick: onRemove,
2845
+ disabled,
2846
+ "aria-label": trimmed === "" ? "Remove this new secret" : `Remove new secret ${trimmed}`,
2847
+ children: /* @__PURE__ */ jsx(X, { size: 15 })
2848
+ })
2849
+ })]
2652
2850
  })]
2653
2851
  })
2654
2852
  }),
@@ -2676,11 +2874,6 @@ function DraftRow({ draft, existingVersion, disabled, onChange, onRemove, versio
2676
2874
  ]
2677
2875
  });
2678
2876
  }
2679
- /** What is wrong with a name being written: a blank one only once a save was asked for, a malformed one as it is typed. */
2680
- function nameProblem(name, attempted) {
2681
- if (name === "") return attempted ? "Give it a name." : null;
2682
- return secretKeyProblem(name);
2683
- }
2684
2877
  function ArchivedRow({ number, project, environment, entry, canArchive, canList, status: state, onRestore, onDismiss }) {
2685
2878
  const [historyOpen, setHistoryOpen] = useState(false);
2686
2879
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [