@coffre/ui 0.14.5 → 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 +21 -18
  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
@@ -0,0 +1,508 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Menu } from '@base-ui/react/menu';
3
+ import { useQuery } from '@tanstack/react-query';
4
+ import { Link, useNavigate } from '@tanstack/react-router';
5
+ import { toast } from 'sonner';
6
+ import { archiveEnvironment, createEnvironment, renameEnvironment } from '../lib/changes';
7
+ import { useCoffre } from '../lib/coffre';
8
+ import { isActiveAccessibleEnvironment, type ProjectEnvironment } from '../lib/project-environments';
9
+ import { affects, queries } from '../lib/queries';
10
+ import { useAction } from '../lib/use-action';
11
+ import { useChange } from '../lib/use-change';
12
+ import { useShell } from '../lib/use-shell';
13
+ import { environmentSlugProblem } from '../lib/validation';
14
+ import { DeletePlaceDialog } from './delete-place';
15
+ import { Archive, Fork, Key, Lock, MoreHorizontal, Pencil, RotateBack, Trash } from './icons';
16
+ import { changesProtection, ProtectDialog } from './protected';
17
+ import { ArchiveBlocked, archiveBlockers } from './references';
18
+ import { ConfirmDialog, ErrorLine, MenuPopup, Modal, Notice } from './ui';
19
+
20
+ /**
21
+ * Renaming an environment, `market/dev` to `market/develop`: shown at once
22
+ * where it is listed, which says if the server refuses; `onRenamed` once it
23
+ * has not.
24
+ */
25
+ export function RenameEnvironment({
26
+ project,
27
+ environment,
28
+ open,
29
+ onOpenChange,
30
+ onRenamed,
31
+ }: {
32
+ project: string;
33
+ environment: string;
34
+ open: boolean;
35
+ onOpenChange: (open: boolean) => void;
36
+ onRenamed?: (slug: string) => void;
37
+ }) {
38
+ const rename = useChange(renameEnvironment(useCoffre(), project));
39
+ const [slug, setSlug] = useState(environment);
40
+ useEffect(() => {
41
+ if (open) setSlug(environment);
42
+ }, [open, environment]);
43
+ const slugError = slug === '' ? null : environmentSlugProblem(slug);
44
+ // Scopes match environments by slug: a new one is said to move them before the rename is saved.
45
+ const reslugged = slug !== environment && slug !== '' && slugError === null;
46
+ return (
47
+ <Modal
48
+ open={open}
49
+ onOpenChange={onOpenChange}
50
+ title={
51
+ <>
52
+ Rename{' '}
53
+ <span className="mono">
54
+ {project}/{environment}
55
+ </span>
56
+ </>
57
+ }
58
+ >
59
+ <form
60
+ className="form"
61
+ onSubmit={(event) => {
62
+ event.preventDefault();
63
+ rename({ from: environment, slug }, { onSuccess: () => onRenamed?.(slug) });
64
+ onOpenChange(false);
65
+ }}
66
+ >
67
+ <label className="field">
68
+ <span className="label">Slug</span>
69
+ <input
70
+ className="input input-mono"
71
+ autoFocus
72
+ spellCheck={false}
73
+ value={slug}
74
+ aria-invalid={slugError !== null}
75
+ onChange={(event) => setSlug(event.target.value)}
76
+ />
77
+ <span className={`hint${slugError !== null ? ' edit-note-error' : ''}`}>
78
+ {slugError ?? `Anything running coffre run ${project}/${environment} will need the new path.`}
79
+ </span>
80
+ </label>
81
+ {reslugged && (
82
+ <Notice tone="info">
83
+ Global roles scoped to <span className="mono">{environment}</span> stop reaching it; those scoped
84
+ to <span className="mono">{slug}</span> start.
85
+ </Notice>
86
+ )}
87
+
88
+ <div className="dialog-actions">
89
+ <button className="btn" type="button" onClick={() => onOpenChange(false)}>
90
+ Cancel
91
+ </button>
92
+ <button
93
+ className="btn btn-primary"
94
+ type="submit"
95
+ disabled={slug === environment || slug === '' || slugError !== null}
96
+ >
97
+ Save
98
+ </button>
99
+ </div>
100
+ </form>
101
+ </Modal>
102
+ );
103
+ }
104
+
105
+ /**
106
+ * Archiving an environment, or restoring an archived one. What archiving
107
+ * would stop is asked once the dialog opens (D41), and Archive waits for
108
+ * the answer; `onArchived` once the server has archived it.
109
+ */
110
+ export function ArchiveEnvironment({
111
+ project,
112
+ environment,
113
+ open,
114
+ onOpenChange,
115
+ onArchived,
116
+ }: {
117
+ project: string;
118
+ environment: ProjectEnvironment;
119
+ open: boolean;
120
+ onOpenChange: (open: boolean) => void;
121
+ onArchived?: () => void;
122
+ }) {
123
+ const coffre = useCoffre();
124
+ const archive = useChange(archiveEnvironment(coffre, project));
125
+ const place = `${project}/${environment.slug}`;
126
+ const isArchived = environment.details !== null && environment.details.archivedAt !== null;
127
+ const secretCount = environment.details?.secretCount ?? null;
128
+ const archiving = open && !isArchived;
129
+ const { data: lent } = useQuery({ ...queries.references(coffre, place), enabled: archiving });
130
+ const blockers = archiving && lent?.ok === true ? archiveBlockers(place, lent.references) : [];
131
+ const asking = archiving && lent === undefined;
132
+ return (
133
+ <ConfirmDialog
134
+ open={open}
135
+ onOpenChange={onOpenChange}
136
+ title={
137
+ <>
138
+ {isArchived ? 'Restore' : 'Archive'} <span className="mono">{place}</span>?
139
+ </>
140
+ }
141
+ body={
142
+ secretCount === null ? (
143
+ <>This changes whether the environment serves its secrets. Values and history stay stored.</>
144
+ ) : isArchived ? (
145
+ <>
146
+ It serves its {secretCount} secret{secretCount === 1 ? '' : 's'} again, to everyone with a grant on it.
147
+ </>
148
+ ) : (
149
+ <>
150
+ Its {secretCount} secret{secretCount === 1 ? '' : 's'} stop being served, so anything running{' '}
151
+ <code>coffre run</code> against <span className="mono">{place}</span> loses them at its next start.
152
+ Values and history survive, and restoring is one click.
153
+ </>
154
+ )
155
+ }
156
+ detail={<ArchiveBlocked references={blockers} />}
157
+ confirmLabel={isArchived ? 'Restore environment' : 'Archive environment'}
158
+ confirmDisabled={asking || blockers.length > 0}
159
+ destructive={!isArchived}
160
+ onConfirm={() => archive({ slug: environment.slug, archived: !isArchived }, { onSuccess: () => !isArchived && onArchived?.() })}
161
+ />
162
+ );
163
+ }
164
+
165
+ /**
166
+ * A new environment, empty, or forked from one you can read: inheriting
167
+ * its keys live (docs/design/forking.md), or each of them copied, value and
168
+ * folder, without history, or a reference to it. Copying is a read, and
169
+ * logged as one; inheriting reads nothing until the fork is read. `from`
170
+ * starts it as a fork of that environment, inheriting.
171
+ */
172
+ export function NewEnvironment({
173
+ project,
174
+ from: forked,
175
+ open,
176
+ onOpenChange,
177
+ onCreated,
178
+ }: {
179
+ project: string;
180
+ from?: string;
181
+ open: boolean;
182
+ onOpenChange: (open: boolean) => void;
183
+ onCreated?: (slug: string) => void;
184
+ }) {
185
+ const environments = useShell().projects.find((entry) => entry.slug === project)?.environments ?? [];
186
+ // Your personal config is nobody's source: its values are yours alone.
187
+ const sources = environments.filter((environment) => isActiveAccessibleEnvironment(environment) && !environment.personal).map((environment) => environment.slug);
188
+ // The protected ones: a fork of one is protected too.
189
+ const guarded = environments.filter((environment) => environment.protected).map((environment) => environment.slug);
190
+ // '' for empty, 'inherit:prod' for a fork that inherits, 'copy:prod' for a copy, 'ref:prod' for references to prod.
191
+ const initial = forked === undefined ? '' : `inherit:${forked}`;
192
+ const [slug, setSlug] = useState('');
193
+ const [start, setStart] = useState(initial);
194
+ // Set back as it closes, not as it opens: opened again, it never starts, even for a render, from the last choice,
195
+ // whose source it would read.
196
+ const close = () => {
197
+ setSlug('');
198
+ setStart(initial);
199
+ onOpenChange(false);
200
+ };
201
+ const [how, from] = start === '' ? ['', ''] : (start.split(':') as ['inherit' | 'copy' | 'ref', string]);
202
+ const coffre = useCoffre();
203
+ // A fork as references copies the keys whose source you read only through their parent: said before you confirm,
204
+ // and read only while the dialog is open.
205
+ const { data: parent } = useQuery({ ...queries.secrets(coffre, { project, environment: from }), enabled: open && how === 'ref' });
206
+ const copied = how === 'ref' && parent?.ok === true
207
+ ? parent.keys.filter((key) => !key.archived && key.reference !== null && !key.reference.canOpenSource).map((key) => key.key)
208
+ : [];
209
+ const create = useChange(createEnvironment(coffre, project));
210
+ const slugError = slug === '' ? null : environmentSlugProblem(slug);
211
+
212
+ return (
213
+ <Modal
214
+ open={open}
215
+ onOpenChange={(next) => (next ? onOpenChange(true) : close())}
216
+ title={
217
+ forked === undefined ? (
218
+ <>
219
+ New environment in <span className="mono">{project}</span>
220
+ </>
221
+ ) : (
222
+ <>
223
+ Fork <span className="mono">{project}/{forked}</span>
224
+ </>
225
+ )
226
+ }
227
+ >
228
+ <form
229
+ className="form"
230
+ onSubmit={(event) => {
231
+ event.preventDefault();
232
+ // Listed at once, as saving; the list says if the server refuses.
233
+ const made = slug;
234
+ create(
235
+ { slug: made, ...(from === '' ? {} : { from }), ...(how === 'ref' ? { references: true } : {}), ...(how === 'inherit' ? { inherit: true } : {}) },
236
+ { onSuccess: () => onCreated?.(made) },
237
+ );
238
+ close();
239
+ }}
240
+ >
241
+ <label className="field">
242
+ <span className="label">Slug</span>
243
+ <input
244
+ className="input input-mono"
245
+ autoFocus
246
+ spellCheck={false}
247
+ autoComplete="off"
248
+ placeholder="staging"
249
+ value={slug}
250
+ aria-invalid={slugError !== null}
251
+ onChange={(event) => setSlug(event.target.value)}
252
+ />
253
+ <span className={`hint${slugError !== null ? ' edit-note-error' : ''}`}>
254
+ {slugError ?? (
255
+ <>
256
+ The CLI will address it as{' '}
257
+ <span className="mono">
258
+ {project}/{slug === '' ? 'staging' : slug}
259
+ </span>
260
+ .
261
+ </>
262
+ )}
263
+ </span>
264
+ </label>
265
+ {sources.length > 0 && (
266
+ <label className="field">
267
+ <span className="label">Start from</span>
268
+ <select className="select" value={start} onChange={(event) => setStart(event.target.value)}>
269
+ <option value="">Empty</option>
270
+ {sources.map((source) => (
271
+ <option key={`inherit:${source}`} value={`inherit:${source}`}>
272
+ Inheriting from {source}
273
+ </option>
274
+ ))}
275
+ {sources.map((source) => (
276
+ <option key={`copy:${source}`} value={`copy:${source}`}>
277
+ A copy of {source}
278
+ </option>
279
+ ))}
280
+ {sources.map((source) => (
281
+ <option key={`ref:${source}`} value={`ref:${source}`}>
282
+ References to {source}
283
+ </option>
284
+ ))}
285
+ </select>
286
+ <span className="hint">
287
+ {how === ''
288
+ ? 'No secrets yet.'
289
+ : how === 'inherit'
290
+ ? `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.`
291
+ : how === 'copy'
292
+ ? `Each of ${from}'s keys, with its current value and folder, without history.`
293
+ : `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}.`}
294
+ </span>
295
+ {from !== '' && guarded.includes(from) && (
296
+ <span className="hint">
297
+ <span className="mono">{from}</span> is protected, so the new environment is too, from its first moment.
298
+ </span>
299
+ )}
300
+ {copied.length > 0 && (
301
+ <span className="hint">
302
+ Copied instead, since you read their source only through {from}: <span className="mono">{copied.join(', ')}</span>.
303
+ </span>
304
+ )}
305
+ </label>
306
+ )}
307
+
308
+ <div className="dialog-actions">
309
+ <button className="btn" type="button" onClick={close}>
310
+ Cancel
311
+ </button>
312
+ <button className="btn btn-primary" type="submit" disabled={slug === '' || slugError !== null}>
313
+ Add environment
314
+ </button>
315
+ </div>
316
+ </form>
317
+ </Modal>
318
+ );
319
+ }
320
+
321
+ /**
322
+ * What is done to an environment itself, in one menu, on its card and its
323
+ * page alike: rename, protect, fork, your own config of it, archive or
324
+ * restore, and delete once archived; in your own config, delete it. Each
325
+ * shows only to whoever may do it, as the project tree says, so it asks
326
+ * the server nothing more.
327
+ */
328
+ export function EnvironmentMenu({
329
+ project,
330
+ environment,
331
+ inProject,
332
+ ownConfig,
333
+ busy,
334
+ follow,
335
+ className,
336
+ }: {
337
+ project: string;
338
+ environment: string;
339
+ /** It as the project tree has it. */
340
+ inProject: ProjectEnvironment | undefined;
341
+ /** Whether to offer your own config of it, `dev@me`. */
342
+ ownConfig: boolean;
343
+ /** Whether a change of it, a rename, its protection or its archiving, is on its way: another waits for its answer. */
344
+ busy: boolean;
345
+ /**
346
+ * Whether it goes where a change leads, as its own page does: to its new
347
+ * name, to its fork, back to the project once it is archived, and to the
348
+ * environment your own config was of once you delete it.
349
+ */
350
+ follow: boolean;
351
+ /** The trigger's look: the page header's button, or a card's quiet act. */
352
+ className: string;
353
+ }) {
354
+ const navigate = useNavigate();
355
+ const { projects, capabilities } = useShell();
356
+ const [open, setOpen] = useState<'rename' | 'protect' | 'fork' | 'archive' | 'delete' | null>(null);
357
+ const dialog = (which: NonNullable<typeof open>) => ({
358
+ open: open === which,
359
+ onOpenChange: (next: boolean) => setOpen(next ? which : null),
360
+ });
361
+ const toEnvironment = follow ? (slug: string) => void navigate({ to: '/projects/$project/$environment', params: { project, environment: slug } }) : undefined;
362
+ // Your own config, `dev@me`: deleted, nothing else; the environment it is yours of.
363
+ const personalOf = inProject?.personal === true ? inProject.parent : null;
364
+ // Its dialogs stay mounted by the project's permission, not by its entry in the tree: a rename moves that entry at
365
+ // once, and a dialog gone with it would drop the rename's answer, and with it the move to its new address.
366
+ const managesProject = personalOf === null && projects.find((entry) => entry.slug === project)?.permissions.includes('environment.manage') === true;
367
+ const manages = managesProject && inProject !== undefined && inProject.details !== null;
368
+ const archived = manages && inProject!.details!.archivedAt !== null;
369
+ const protects = personalOf === null && inProject !== undefined && changesProtection(projects, project, inProject);
370
+ const forks = manages && isActiveAccessibleEnvironment(inProject!);
371
+ // Deleting is for those who run the instance, and only once the environment is archived.
372
+ const deletes = archived && capabilities.runsInstance;
373
+ const offers = personalOf !== null || manages || protects || ownConfig;
374
+ return (
375
+ <>
376
+ {offers && (
377
+ <Menu.Root>
378
+ <Menu.Trigger className={className} aria-label={`Actions for ${project}/${environment}`}>
379
+ <MoreHorizontal size={16} />
380
+ </Menu.Trigger>
381
+ <MenuPopup align="end">
382
+ {personalOf !== null ? (
383
+ <Menu.Item className="menu-item menu-item-danger" onClick={() => setOpen('delete')}>
384
+ <Trash size={14} />
385
+ Delete…
386
+ </Menu.Item>
387
+ ) : (
388
+ <>
389
+ {manages && (
390
+ <Menu.Item className="menu-item" disabled={busy} onClick={() => setOpen('rename')}>
391
+ <Pencil size={14} />
392
+ Rename…
393
+ </Menu.Item>
394
+ )}
395
+ {protects && (
396
+ <Menu.Item className="menu-item" disabled={busy} onClick={() => setOpen('protect')}>
397
+ <Lock size={14} />
398
+ {inProject!.protected ? 'Unprotect…' : 'Protect…'}
399
+ </Menu.Item>
400
+ )}
401
+ {forks && (
402
+ <Menu.Item className="menu-item" onClick={() => setOpen('fork')}>
403
+ <Fork size={14} />
404
+ Fork…
405
+ </Menu.Item>
406
+ )}
407
+ {ownConfig && (
408
+ <Menu.LinkItem
409
+ className="menu-item"
410
+ closeOnClick
411
+ render={<Link to="/projects/$project/$environment" params={{ project, environment: `${environment}@me` }} />}
412
+ >
413
+ <Key size={14} />
414
+ My own {environment}
415
+ </Menu.LinkItem>
416
+ )}
417
+ {manages && (
418
+ <>
419
+ <Menu.Separator className="menu-sep" />
420
+ <Menu.Item className={`menu-item${archived ? '' : ' menu-item-danger'}`} disabled={busy} onClick={() => setOpen('archive')}>
421
+ {archived ? <RotateBack size={14} /> : <Archive size={14} />}
422
+ {archived ? 'Restore…' : 'Archive…'}
423
+ </Menu.Item>
424
+ </>
425
+ )}
426
+ {deletes && (
427
+ <Menu.Item className="menu-item menu-item-danger" disabled={busy} onClick={() => setOpen('delete')}>
428
+ <Trash size={14} />
429
+ Delete…
430
+ </Menu.Item>
431
+ )}
432
+ </>
433
+ )}
434
+ </MenuPopup>
435
+ </Menu.Root>
436
+ )}
437
+ {managesProject && (
438
+ <>
439
+ <RenameEnvironment project={project} environment={environment} {...dialog('rename')} onRenamed={toEnvironment} />
440
+ <NewEnvironment project={project} from={environment} {...dialog('fork')} onCreated={toEnvironment} />
441
+ </>
442
+ )}
443
+ {manages && (
444
+ <ArchiveEnvironment
445
+ project={project}
446
+ environment={inProject!}
447
+ {...dialog('archive')}
448
+ onArchived={follow ? () => {
449
+ toast.success(`${project}/${environment} archived`);
450
+ void navigate({ to: '/projects/$project', params: { project } });
451
+ } : undefined}
452
+ />
453
+ )}
454
+ {protects && <ProtectDialog project={project} environment={inProject!} {...dialog('protect')} />}
455
+ {deletes && (
456
+ <DeletePlaceDialog
457
+ path={`${project}/${environment}`}
458
+ {...dialog('delete')}
459
+ onDeleted={() => toast.success(`${project}/${environment} deleted`)}
460
+ />
461
+ )}
462
+ {personalOf !== null && (
463
+ <DeletePersonal project={project} environment={environment} of={personalOf} {...dialog('delete')} onDeleted={toEnvironment} />
464
+ )}
465
+ </>
466
+ );
467
+ }
468
+
469
+ /** Delete your personal config: its values erased; the environment it is yours of untouched. */
470
+ function DeletePersonal({
471
+ project,
472
+ environment,
473
+ of,
474
+ open,
475
+ onOpenChange,
476
+ onDeleted,
477
+ }: {
478
+ project: string;
479
+ environment: string;
480
+ of: string;
481
+ open: boolean;
482
+ onOpenChange: (open: boolean) => void;
483
+ /** Once deleted, with the environment it was yours of. */
484
+ onDeleted?: (of: string) => void;
485
+ }) {
486
+ const coffre = useCoffre();
487
+ const { error, run } = useAction();
488
+ return (
489
+ <>
490
+ {error !== null && <ErrorLine error={error} />}
491
+ <ConfirmDialog
492
+ open={open}
493
+ onOpenChange={onOpenChange}
494
+ title={<>Delete your own <span className="mono">{of}</span>?</>}
495
+ body={`The values you set in ${project}/${environment} are erased for good. ${project}/${of} is untouched, and ${environment} reads it again.`}
496
+ confirmLabel="Delete"
497
+ onConfirm={() =>
498
+ void run(() => coffre.environments.delete(`${project}/${environment}`), {
499
+ affects: [...affects.secrets({ project, environment }), ...affects.places()],
500
+ onSuccess: () => {
501
+ toast.success(`Your own ${of} is deleted`);
502
+ onDeleted?.(of);
503
+ },
504
+ })}
505
+ />
506
+ </>
507
+ );
508
+ }
@@ -79,8 +79,8 @@ export function GrantRowView({
79
79
  <td className="col-access" data-label="Permissions">
80
80
  <span className={`tag${grant.role === 'owner' ? ' tag-violet' : ''}`}>{label}</span>
81
81
  {byRole && (
82
- <span className="role-scope" title="Their instance role reaches this project. Change it on their page in Users.">
83
- instance role
82
+ <span className="role-scope" title="Their global role reaches this project. Change it on their page in Users.">
83
+ global role
84
84
  </span>
85
85
  )}
86
86
  </td>
@@ -16,6 +16,7 @@ import {
16
16
  Eye as EyeGlyph,
17
17
  EyeOff as EyeOffGlyph,
18
18
  Folder as FolderGlyph,
19
+ GitFork,
19
20
  Hash as HashGlyph,
20
21
  History as HistoryGlyph,
21
22
  Inbox as InboxGlyph,
@@ -143,6 +144,7 @@ function lucide(Glyph: LucideIcon) {
143
144
 
144
145
  // Places
145
146
  export const Folder = lucide(FolderGlyph);
147
+ export const Fork = lucide(GitFork);
146
148
  export const Layers = lucide(LayersGlyph);
147
149
  export const Users = lucide(UsersGlyph);
148
150
  export const User = lucide(UserGlyph);
@@ -4,6 +4,7 @@ import type { PrincipalReport, RemovedPrincipal } from '../shared/models';
4
4
  import { Card } from './page';
5
5
  import { EmptyState, Notice, Timestamp } from './ui';
6
6
  import { PrincipalLink } from './principal';
7
+ import { ReadsLag } from './actions-log';
7
8
  import { referenceProblem } from './references';
8
9
  import { ChevronRight, Key, User } from './icons';
9
10
  import { serviceName } from '@coffre/client';
@@ -57,9 +58,12 @@ export function RemovedNotice({ report }: { report: PrincipalReport }) {
57
58
  export function RemovedList({
58
59
  principalType,
59
60
  removed,
61
+ reads,
60
62
  }: {
61
63
  principalType: RemovedPrincipal['principalType'];
62
64
  removed: RemovedPrincipal[];
65
+ /** How far reads are listed, which the counts to rotate are as of (0.15's log). */
66
+ reads?: Parameters<typeof ReadsLag>[0]['reads'];
63
67
  }) {
64
68
  const users = principalType === 'user';
65
69
  const rows = removed.filter((principal) => principal.principalType === principalType);
@@ -67,6 +71,7 @@ export function RemovedList({
67
71
  return (
68
72
  <>
69
73
  <h2 className="section-title">Removed</h2>
74
+ <ReadsLag reads={reads} />
70
75
  <section className="card" aria-label={users ? 'Removed users' : 'Removed service accounts'}>
71
76
  <div className="dt-wrap">
72
77
  <table className="dt directory stacks">
@@ -127,6 +132,8 @@ function ConsiderRotating({ report, person }: { report: PrincipalReport; person:
127
132
  )
128
133
  }
129
134
  >
135
+ {/* Reads sealed since may yet be listed, and named here. */}
136
+ <ReadsLag reads={report.reads} />
130
137
  {report.exposed.length === 0 ? (
131
138
  <EmptyState title="Nothing left to rotate">
132
139
  {report.rotated > 0
@@ -88,11 +88,12 @@ export function Card({
88
88
  }
89
89
 
90
90
  /** One labelled fact in a card's `dl.facts`. */
91
- export function Fact({ label, children }: { label: string; children: ReactNode }) {
91
+ export function Fact({ label, children, action }: { label: string; children: ReactNode; /** What changes it, beside it. */ action?: ReactNode }) {
92
92
  return (
93
- <div className="fact">
93
+ <div className={action === undefined ? 'fact' : 'fact fact-with-action'}>
94
94
  <dt>{label}</dt>
95
95
  <dd>{children}</dd>
96
+ {action}
96
97
  </div>
97
98
  );
98
99
  }
@@ -356,7 +356,7 @@ function InstanceRoleNote({ access }: { access: MemberAccess }) {
356
356
  <div className="report-notice">
357
357
  <Notice tone="info">
358
358
  <strong>{name}</strong>
359
- {access.scope === null ? '' : unscoped(access.scope) ? ' in every project' : `: ${scopeInWords(access.scope)}`}, from their instance role. The
359
+ {access.scope === null ? '' : unscoped(access.scope) ? ' in every project' : `: ${scopeInWords(access.scope)}`}, from their global role. The
360
360
  grants below add to it.
361
361
  </Notice>
362
362
  </div>