@coffre/ui 0.15.0 → 0.16.1
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.
- package/dist/audit-sentences.d.ts +56 -0
- package/dist/audit-sentences.js +886 -0
- package/dist/audit-sentences.js.map +1 -0
- package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
- package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
- package/dist/chunks/{connected-apps-CGUQlFMx.js → connected-apps-6sMSgQ9U.js} +5 -5
- package/dist/chunks/{connected-apps-CGUQlFMx.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
- package/dist/chunks/{delete-place-CswZ-meh.js → delete-place-T469tSN9.js} +5 -5
- package/dist/chunks/{delete-place-CswZ-meh.js.map → delete-place-T469tSN9.js.map} +1 -1
- package/dist/chunks/{directory-DrswWQLT.js → directory-B_gVf7UL.js} +18 -17
- package/dist/chunks/directory-B_gVf7UL.js.map +1 -0
- package/dist/chunks/{folders-A6sbR_PG.js → folders-CVYauIDz.js} +3 -3
- package/dist/chunks/{folders-A6sbR_PG.js.map → folders-CVYauIDz.js.map} +1 -1
- package/dist/chunks/{grants-C0cb2oii.js → grants-Dn_EW2XW.js} +8 -8
- package/dist/chunks/grants-Dn_EW2XW.js.map +1 -0
- package/dist/chunks/{multi-combobox-B3SEv1gq.js → multi-combobox-fbBRzi9z.js} +3 -3
- package/dist/chunks/{multi-combobox-B3SEv1gq.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
- package/dist/chunks/{offboarding-C1jbG_dk.js → offboarding-CXM464J_.js} +81 -80
- package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
- package/dist/chunks/{page-CfhC9Hp1.js → page-Cb0ZjGda.js} +7 -12
- package/dist/chunks/page-Cb0ZjGda.js.map +1 -0
- package/dist/chunks/{personal-tokens-xC9wulhg.js → personal-tokens-CSHMlRHy.js} +7 -7
- package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
- package/dist/chunks/{principal-CI17XK13.js → principal-BKJxbAtE.js} +2 -2
- package/dist/chunks/{principal-CI17XK13.js.map → principal-BKJxbAtE.js.map} +1 -1
- package/dist/chunks/{principal-page-CdSeftGD.js → principal-page-COPmTDVW.js} +132 -19
- package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
- package/dist/chunks/{project-page-CHxjBE97.js → project-page-g5_n46Nz.js} +3 -3
- package/dist/chunks/{project-page-CHxjBE97.js.map → project-page-g5_n46Nz.js.map} +1 -1
- package/dist/chunks/protected-DEWeOrmI.js +77 -0
- package/dist/chunks/protected-DEWeOrmI.js.map +1 -0
- package/dist/chunks/{queries-D1JuimTu.js → queries-D4_o-bz3.js} +22 -155
- package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
- package/dist/chunks/{references-D5llUGQL.js → references-wTh_DT0M.js} +27 -23
- package/dist/chunks/references-wTh_DT0M.js.map +1 -0
- package/dist/chunks/{role-field-CoCv8wse.js → role-field-BiP09qfN.js} +5 -5
- package/dist/chunks/role-field-BiP09qfN.js.map +1 -0
- package/dist/chunks/{row-state-CYH7kZHl.js → row-state-CYhtmUkc.js} +3 -3
- package/dist/chunks/{row-state-CYH7kZHl.js.map → row-state-CYhtmUkc.js.map} +1 -1
- package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
- package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
- package/dist/chunks/{theme-rF44Wbmm.js → theme-imSolE1q.js} +3 -3
- package/dist/chunks/{theme-rF44Wbmm.js.map → theme-imSolE1q.js.map} +1 -1
- package/dist/chunks/{ui-CGdORVzW.js → ui-Q_Eczt7m.js} +7 -3
- package/dist/chunks/{ui-CGdORVzW.js.map → ui-Q_Eczt7m.js.map} +1 -1
- package/dist/chunks/{use-action-BxrHTBZw.js → use-action-BfnN-De2.js} +3 -3
- package/dist/chunks/{use-action-BxrHTBZw.js.map → use-action-BfnN-De2.js.map} +1 -1
- package/dist/chunks/{use-change-BorW2R6C.js → use-change-Cc0X4sF3.js} +6 -4
- package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
- package/dist/chunks/{use-roles-BZnJ9Cq0.js → use-roles-stcv2QFj.js} +13 -56
- package/dist/chunks/use-roles-stcv2QFj.js.map +1 -0
- package/dist/chunks/{use-shell-CPskgi1k.js → use-shell-DMhLa2sh.js} +3 -3
- package/dist/chunks/{use-shell-CPskgi1k.js.map → use-shell-DMhLa2sh.js.map} +1 -1
- package/dist/index.d.ts +23 -55
- package/dist/index.js +12 -31
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +12 -12
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.js +2 -2
- package/dist/pages/audit.js +173 -196
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -2
- package/dist/pages/environment.js +445 -252
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +6 -15
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/oauth-authorize.js +2 -2
- package/dist/pages/project-access.js +11 -11
- package/dist/pages/project-environments.js +359 -28
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +8 -8
- package/dist/pages/project.js +3 -3
- package/dist/pages/projects.js +8 -8
- package/dist/pages/service-account.js +19 -16
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +6 -7
- package/dist/pages/service-accounts.js.map +1 -1
- package/dist/pages/settings.d.ts +1 -6
- package/dist/pages/settings.js +155 -286
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -2
- package/dist/pages/user.js +7 -8
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +6 -7
- package/dist/pages/users.js.map +1 -1
- package/package.json +8 -3
- package/src/components/actions-log.tsx +8 -61
- package/src/components/directory.tsx +10 -9
- package/src/components/grants.tsx +2 -2
- package/src/components/icons.tsx +0 -2
- package/src/components/offboarding.tsx +9 -16
- package/src/components/page.tsx +2 -3
- package/src/components/personal-tokens.tsx +5 -2
- package/src/components/principal-page.tsx +5 -4
- package/src/components/protected.tsx +39 -52
- package/src/components/references.tsx +18 -7
- package/src/components/role-editor.tsx +68 -99
- package/src/components/role-field.tsx +1 -1
- package/src/components/trusted-workloads.tsx +6 -5
- package/src/components/ui.tsx +5 -0
- package/src/lib/audit-proofs.ts +51 -0
- package/src/lib/audit-sentences.ts +490 -529
- package/src/lib/bindings.ts +6 -0
- package/src/lib/changes.ts +3 -1
- package/src/lib/coffre.ts +2 -2
- package/src/lib/queries.ts +19 -168
- package/src/lib/reveal.ts +32 -5
- package/src/lib/roles.ts +10 -36
- package/src/lib/row-reads.ts +2 -2
- package/src/lib/signin-errors.ts +5 -33
- package/src/options.ts +3 -19
- package/src/pages/account.tsx +1 -1
- package/src/pages/audit.tsx +151 -228
- package/src/pages/environment.tsx +373 -247
- package/src/pages/login.tsx +2 -4
- package/src/pages/project-environments.tsx +322 -20
- package/src/pages/service-accounts.tsx +1 -1
- package/src/pages/settings.tsx +49 -134
- package/src/pages/user.tsx +2 -2
- package/src/pages/users.tsx +1 -1
- package/src/parity.ts +11 -20
- package/src/styles/globals.css +107 -273
- package/dist/chunks/actions-log-DupYCEyV.js +0 -1134
- package/dist/chunks/actions-log-DupYCEyV.js.map +0 -1
- package/dist/chunks/directory-DrswWQLT.js.map +0 -1
- package/dist/chunks/environment-actions-8rL9Cw6X.js +0 -576
- package/dist/chunks/environment-actions-8rL9Cw6X.js.map +0 -1
- package/dist/chunks/grants-C0cb2oii.js.map +0 -1
- package/dist/chunks/offboarding-C1jbG_dk.js.map +0 -1
- package/dist/chunks/page-CfhC9Hp1.js.map +0 -1
- package/dist/chunks/personal-tokens-xC9wulhg.js.map +0 -1
- package/dist/chunks/principal-page-CdSeftGD.js.map +0 -1
- package/dist/chunks/queries-D1JuimTu.js.map +0 -1
- package/dist/chunks/references-D5llUGQL.js.map +0 -1
- package/dist/chunks/role-field-CoCv8wse.js.map +0 -1
- package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
- package/dist/chunks/use-change-BorW2R6C.js.map +0 -1
- package/dist/chunks/use-roles-BZnJ9Cq0.js.map +0 -1
- package/src/components/environment-actions.tsx +0 -508
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ageInDays, byFolder, CoffreError, foldersOf, olderThan, planImport, shownMember, type CoffreClient, type ListedReference } from '@coffre/client';
|
|
2
2
|
import { parseDotenv } from '@coffre/core/dotenv';
|
|
3
3
|
import type { Generation } from '@coffre/core/recipe';
|
|
4
|
-
import { useEffect, useReducer, useRef, useState, type ReactNode } from 'react';
|
|
4
|
+
import { useEffect, useId, useReducer, useRef, useState, type ReactNode } from 'react';
|
|
5
5
|
import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
|
|
6
|
-
import { Link } from '@tanstack/react-router';
|
|
6
|
+
import { Link, useNavigate } from '@tanstack/react-router';
|
|
7
7
|
import { useShell } from '../lib/use-shell';
|
|
8
8
|
import { Menu } from '@base-ui/react/menu';
|
|
9
9
|
import { toast } from 'sonner';
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
type SecretDraft,
|
|
36
36
|
} from '../lib/secret-edit-batch';
|
|
37
37
|
import { createCopier } from '../lib/copy-attempts';
|
|
38
|
-
import { revealIsCurrent, type Reveal } from '../lib/reveal';
|
|
38
|
+
import { revealIsCurrent, stampedRead, type Read, type Reveal } from '../lib/reveal';
|
|
39
39
|
import { noReads, revealToggleDisabled, rowReads, valueToEdit } from '../lib/row-reads';
|
|
40
40
|
import { sortKeys, type Sort } from '../lib/secret-order';
|
|
41
41
|
import { inDialog } from '../lib/shortcuts';
|
|
@@ -56,7 +56,6 @@ import {
|
|
|
56
56
|
} from '../components/ui';
|
|
57
57
|
import { Card, ClosedDoor, PageHeader } from '../components/page';
|
|
58
58
|
import { Protection } from '../components/protected';
|
|
59
|
-
import { EnvironmentMenu } from '../components/environment-actions';
|
|
60
59
|
import { SecretReadOnly } from '../components/affordances';
|
|
61
60
|
import { GenerateValue, type GeneratedUse } from '../components/generate-value';
|
|
62
61
|
import { RecipeMark, RegenerateSecret } from '../components/regenerate';
|
|
@@ -90,7 +89,9 @@ import {
|
|
|
90
89
|
Search,
|
|
91
90
|
SlashCircle,
|
|
92
91
|
Terminal,
|
|
92
|
+
Trash,
|
|
93
93
|
Upload,
|
|
94
|
+
X,
|
|
94
95
|
} from '../components/icons';
|
|
95
96
|
import { pageRoute } from '../lib/page-route';
|
|
96
97
|
import type { environment } from '../options';
|
|
@@ -159,6 +160,8 @@ export function EnvironmentPage() {
|
|
|
159
160
|
);
|
|
160
161
|
}
|
|
161
162
|
|
|
163
|
+
type Pending = { key: string; what: string };
|
|
164
|
+
|
|
162
165
|
function EnvironmentLedger({
|
|
163
166
|
project,
|
|
164
167
|
environment,
|
|
@@ -220,12 +223,14 @@ function EnvironmentLedger({
|
|
|
220
223
|
// pending change is in edit mode whether or not it is listed here.
|
|
221
224
|
const [editing, setEditing] = useState<ReadonlySet<string>>(() => new Set());
|
|
222
225
|
const [saveError, setSaveError] = useState<string | null>(null);
|
|
223
|
-
//
|
|
224
|
-
const [
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
// A save that makes keys sensitive, waiting for its confirmation: nobody sees them again, which the row's menu asks too.
|
|
227
|
+
const [hiding, setHiding] = useState<{ keys: string[]; go: () => void } | null>(null);
|
|
228
|
+
// Every key the save writes counts, a key pair's public key included.
|
|
229
|
+
function confirmingSensitive(drafts: readonly SecretDraft[], changes: Record<string, SecretChange>, go: () => void) {
|
|
230
|
+
const keys = madeSensitive(active, drafts, changes);
|
|
231
|
+
if (keys.length === 0) go();
|
|
232
|
+
else setHiding({ keys, go });
|
|
233
|
+
}
|
|
229
234
|
const [query, setQuery] = useState(Route.useSearch().filter ?? '');
|
|
230
235
|
const [sort, setSort] = useState<Sort>({ by: 'key', descending: false });
|
|
231
236
|
// A column's first click sorts it ascending: names A to Z, the oldest values first.
|
|
@@ -285,9 +290,8 @@ function EnvironmentLedger({
|
|
|
285
290
|
(entry) => secretChangeFor(changes, entry.key) !== undefined,
|
|
286
291
|
);
|
|
287
292
|
const hasConflict = hasSecretEditConflict(active, drafts, changes);
|
|
288
|
-
// Every name that will be written. Blank ones hold the save back
|
|
289
|
-
//
|
|
290
|
-
// while malformed ones say why as they are typed.
|
|
293
|
+
// Every name that will be written. Blank ones only hold the save back -- a
|
|
294
|
+
// row you just added is not an error yet -- while malformed ones say why.
|
|
291
295
|
const pendingNames = [
|
|
292
296
|
...drafts.map((row) => row.key.trim()),
|
|
293
297
|
...changedEntries.flatMap((entry) => {
|
|
@@ -320,6 +324,55 @@ function EnvironmentLedger({
|
|
|
320
324
|
});
|
|
321
325
|
}
|
|
322
326
|
|
|
327
|
+
/**
|
|
328
|
+
* One row's own Save: its change alone goes, and any other row's stays
|
|
329
|
+
* pending. A row opened and left as it was just closes.
|
|
330
|
+
*/
|
|
331
|
+
function saveRow(key: string) {
|
|
332
|
+
const change = secretChangeFor(changes, key);
|
|
333
|
+
if (change === undefined) return dropChange(key);
|
|
334
|
+
confirmingSensitive([], { [key]: change }, () => {
|
|
335
|
+
dropChange(key);
|
|
336
|
+
sendAlone({ active, drafts: [], changes: { [key]: change } });
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function saveDraft(draft: SecretDraft) {
|
|
341
|
+
confirmingSensitive([draft], {}, () => {
|
|
342
|
+
setDrafts((rows) => rows.filter((row) => row.id !== draft.id));
|
|
343
|
+
sendAlone({ active, drafts: [draft], changes: {} });
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** Whether one row's change could go alone: named, well named, and clashing with nothing. */
|
|
348
|
+
function readyAlone(drafts: SecretDraft[], changes: Record<string, SecretChange>): boolean {
|
|
349
|
+
const names = [
|
|
350
|
+
...drafts.map((row) => row.key.trim()),
|
|
351
|
+
...Object.values(changes).flatMap((change) => (change.archived ? [] : [change.key.trim()])),
|
|
352
|
+
...companionsOf(active, drafts, changes).map((companion) => companion.key.trim()),
|
|
353
|
+
];
|
|
354
|
+
return (
|
|
355
|
+
(drafts.length > 0 || Object.keys(changes).length > 0) &&
|
|
356
|
+
names.every((name) => name !== '' && secretKeyProblem(name) === null) &&
|
|
357
|
+
!hasSecretEditConflict(active, drafts, changes) &&
|
|
358
|
+
!active.some((entry) => waitsForValue(entry, secretChangeFor(changes, entry.key)))
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function sendAlone(batch: { active: SecretKey[]; drafts: SecretDraft[]; changes: Record<string, SecretChange> }) {
|
|
363
|
+
setSaveError(null);
|
|
364
|
+
save(batch, {
|
|
365
|
+
// What did not go comes back as it was, beside the other pending rows.
|
|
366
|
+
onError: (error) => {
|
|
367
|
+
forgetRefusal(batch);
|
|
368
|
+
const left = error instanceof UnsavedEdits ? error.outcome : batch;
|
|
369
|
+
setDrafts((rows) => [...rows, ...left.drafts]);
|
|
370
|
+
setChanges((current) => ({ ...current, ...left.changes }));
|
|
371
|
+
setSaveError(failureMessage(error));
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
323
376
|
function dropChange(key: string) {
|
|
324
377
|
setChanges((current) => {
|
|
325
378
|
const { [key]: _, ...rest } = current;
|
|
@@ -342,7 +395,6 @@ function EnvironmentLedger({
|
|
|
342
395
|
setChanges({});
|
|
343
396
|
setEditing(new Set());
|
|
344
397
|
setSaveError(null);
|
|
345
|
-
setAttempted(false);
|
|
346
398
|
}
|
|
347
399
|
|
|
348
400
|
/**
|
|
@@ -363,13 +415,8 @@ function EnvironmentLedger({
|
|
|
363
415
|
* bar under the table says why.
|
|
364
416
|
*/
|
|
365
417
|
function saveChanges() {
|
|
366
|
-
if (pendingCount === 0) return;
|
|
367
|
-
setAttempted(true);
|
|
368
418
|
if (!ready) return;
|
|
369
|
-
|
|
370
|
-
const keys = madeSensitive(active, drafts, changes);
|
|
371
|
-
if (keys.length === 0) sendChanges();
|
|
372
|
-
else setHiding(keys);
|
|
419
|
+
confirmingSensitive(drafts, changes, sendChanges);
|
|
373
420
|
}
|
|
374
421
|
|
|
375
422
|
function sendChanges() {
|
|
@@ -378,7 +425,6 @@ function EnvironmentLedger({
|
|
|
378
425
|
setChanges({});
|
|
379
426
|
setEditing(new Set());
|
|
380
427
|
setSaveError(null);
|
|
381
|
-
setAttempted(false);
|
|
382
428
|
save(batch, {
|
|
383
429
|
onError: (error) => {
|
|
384
430
|
forgetRefusal(batch);
|
|
@@ -449,26 +495,33 @@ function EnvironmentLedger({
|
|
|
449
495
|
return () => document.removeEventListener('keydown', onKeyDown);
|
|
450
496
|
}, [pendingCount]);
|
|
451
497
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
498
|
+
const withCompanion = (what: string, companion: Companion | undefined) =>
|
|
499
|
+
companion === undefined ? what : `${what}, with ${companion.key.trim()}`;
|
|
500
|
+
const pending: Pending[] = [
|
|
501
|
+
...drafts.map((draft) => ({
|
|
502
|
+
key: draft.key.trim() || 'unnamed',
|
|
503
|
+
what: withCompanion(existing.has(draft.key.trim()) ? 'new version' : 'added', draft.companion),
|
|
504
|
+
})),
|
|
505
|
+
...changedEntries.map((entry) => {
|
|
506
|
+
const change = secretChangeFor(changes, entry.key)!;
|
|
507
|
+
if (change.archived) return { key: entry.key, what: 'archived' };
|
|
508
|
+
const renamed = change.key.trim() !== entry.key;
|
|
509
|
+
// Who sees it, where the edit changes that: beside a new value, or alone, a mark.
|
|
510
|
+
const level = change.sensitivity === undefined || change.sensitivity === entry.sensitivity ? null : change.sensitivity;
|
|
511
|
+
const written = change.value === null
|
|
512
|
+
? (level === null ? null : `made ${level}`)
|
|
513
|
+
: withCompanion(level === null ? 'new value' : `new value, ${level}`, change.companion);
|
|
514
|
+
if (renamed) return { key: entry.key, what: written === null ? `→ ${change.key.trim()}` : `→ ${change.key.trim()}, ${written}` };
|
|
515
|
+
// In a fork, a value written over the parent's overrides it.
|
|
516
|
+
if (entry.parent !== null && entry.parent.state !== 'overridden') return { key: entry.key, what: withCompanion(`overrides ${entry.parent.from}`, change.companion) };
|
|
517
|
+
return { key: entry.key, what: written ?? 'new value' };
|
|
518
|
+
}),
|
|
519
|
+
];
|
|
465
520
|
|
|
466
521
|
// Two rows that are both still blank "conflict" too, so say nothing until
|
|
467
|
-
// every name is filled in; the blank row speaks for itself
|
|
468
|
-
// pressed, but for one the filter hides, which the bar speaks for.
|
|
469
|
-
const unnamedHidden = changedEntries.some((entry) => secretChangeFor(changes, entry.key)!.key.trim() === '' && !listed.includes(entry));
|
|
522
|
+
// every name is filled in; the blank row speaks for itself.
|
|
470
523
|
const problem = unnamed
|
|
471
|
-
?
|
|
524
|
+
? null
|
|
472
525
|
: hasConflict
|
|
473
526
|
? 'Two pending edits would end up with the same name. Secret names are unique in an environment.'
|
|
474
527
|
: invalid
|
|
@@ -477,23 +530,29 @@ function EnvironmentLedger({
|
|
|
477
530
|
? `${waiting.key} waits for its value: type it again.`
|
|
478
531
|
: null;
|
|
479
532
|
|
|
533
|
+
// Filtering narrows what is listed, never what is saved: a pending edit on
|
|
534
|
+
// a row the filter hides still counts, and still shows in the bar under the table.
|
|
535
|
+
const needle = query.trim().toLowerCase();
|
|
536
|
+
const listed = sortKeys(
|
|
537
|
+
needle === '' ? active : active.filter((entry) => entry.key.toLowerCase().includes(needle)),
|
|
538
|
+
sort,
|
|
539
|
+
);
|
|
540
|
+
const columns = 6;
|
|
541
|
+
|
|
480
542
|
return (
|
|
481
543
|
<>
|
|
482
544
|
<PageHeader
|
|
483
545
|
tile={project}
|
|
484
546
|
title={environment}
|
|
485
|
-
aside={inProject !== undefined && <Protection environment={inProject} />}
|
|
486
|
-
actions={
|
|
487
|
-
<
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
className="btn btn-sm btn-icon"
|
|
495
|
-
/>
|
|
496
|
-
}
|
|
547
|
+
aside={inProject !== undefined && <Protection project={project} environment={inProject} />}
|
|
548
|
+
actions={personal ? (
|
|
549
|
+
<DeletePersonal project={project} environment={environment} of={parents[0]!} />
|
|
550
|
+
) : principal?.type === 'user' && canList && (
|
|
551
|
+
<Link className="btn btn-sm" to="/projects/$project/$environment" params={{ project, environment: `${environment}@me` }}>
|
|
552
|
+
<Key size={14} />
|
|
553
|
+
My own {environment}
|
|
554
|
+
</Link>
|
|
555
|
+
)}
|
|
497
556
|
meta={protecting.state === 'pending' ? (
|
|
498
557
|
<RowPending status={protecting} />
|
|
499
558
|
) : protecting.state === 'failed' ? (
|
|
@@ -652,8 +711,11 @@ function EnvironmentLedger({
|
|
|
652
711
|
onEdit={() => setEditing((current) => new Set(current).add(entry.key))}
|
|
653
712
|
onPatch={(patch) => patchChange(entry, patch)}
|
|
654
713
|
onUndo={() => dropChange(entry.key)}
|
|
714
|
+
onSave={() => saveRow(entry.key)}
|
|
655
715
|
versionOf={versionOf}
|
|
656
|
-
|
|
716
|
+
saveReady={
|
|
717
|
+
change === undefined || readyAlone([], { [entry.key]: change })
|
|
718
|
+
}
|
|
657
719
|
onMarkArchive={() => {
|
|
658
720
|
setEditing((current) => {
|
|
659
721
|
const next = new Set(current);
|
|
@@ -691,18 +753,19 @@ function EnvironmentLedger({
|
|
|
691
753
|
)
|
|
692
754
|
}
|
|
693
755
|
onRemove={() => setDrafts((rows) => rows.filter((row) => row.id !== draft.id))}
|
|
756
|
+
onSave={() => saveDraft(draft)}
|
|
694
757
|
versionOf={versionOf}
|
|
695
|
-
|
|
758
|
+
saveReady={readyAlone([draft], {})}
|
|
696
759
|
/>
|
|
697
760
|
))}
|
|
698
761
|
</tbody>
|
|
699
762
|
</table>
|
|
700
763
|
</div>
|
|
701
764
|
)}
|
|
702
|
-
{
|
|
765
|
+
{pendingCount > 0 && (
|
|
703
766
|
<PendingBar
|
|
704
|
-
|
|
705
|
-
|
|
767
|
+
pending={pending}
|
|
768
|
+
ready={ready}
|
|
706
769
|
error={saveError ?? problem}
|
|
707
770
|
onDiscard={discardAll}
|
|
708
771
|
onSave={saveChanges}
|
|
@@ -713,13 +776,14 @@ function EnvironmentLedger({
|
|
|
713
776
|
<ConfirmDialog
|
|
714
777
|
open={hiding !== null}
|
|
715
778
|
onOpenChange={(open) => !open && setHiding(null)}
|
|
716
|
-
title={hiding?.length === 1 ? <>Make <span className="mono">{hiding[0]}</span> sensitive?</> : `Make ${hiding?.length ?? 0} keys sensitive?`}
|
|
717
|
-
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'}.`}
|
|
779
|
+
title={hiding?.keys.length === 1 ? <>Make <span className="mono">{hiding.keys[0]}</span> sensitive?</> : `Make ${hiding?.keys.length ?? 0} keys sensitive?`}
|
|
780
|
+
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'}.`}
|
|
718
781
|
confirmLabel="Make sensitive"
|
|
719
782
|
destructive={false}
|
|
720
783
|
onConfirm={() => {
|
|
784
|
+
const go = hiding?.go;
|
|
721
785
|
setHiding(null);
|
|
722
|
-
|
|
786
|
+
go?.();
|
|
723
787
|
}}
|
|
724
788
|
/>
|
|
725
789
|
|
|
@@ -803,34 +867,39 @@ function EnvironmentLedger({
|
|
|
803
867
|
}
|
|
804
868
|
|
|
805
869
|
/**
|
|
806
|
-
* The pending edits, at the foot of the table they are made in:
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
* edit opened and left as it was has its Discard too. It sticks to the
|
|
810
|
-
* bottom of the window while the table runs past it, so Save stays in
|
|
811
|
-
* reach of any row.
|
|
870
|
+
* The pending edits, at the foot of the table they are made in: what they
|
|
871
|
+
* are, Discard and Save. It sticks to the bottom of the window while the
|
|
872
|
+
* table runs past it, so Save stays in reach of any row.
|
|
812
873
|
*/
|
|
813
874
|
function PendingBar({
|
|
814
|
-
|
|
815
|
-
|
|
875
|
+
pending,
|
|
876
|
+
ready,
|
|
816
877
|
error,
|
|
817
878
|
onDiscard,
|
|
818
879
|
onSave,
|
|
819
880
|
}: {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
canSave: boolean;
|
|
881
|
+
pending: Pending[];
|
|
882
|
+
ready: boolean;
|
|
823
883
|
/** Why the last save failed, or why this one cannot go yet. */
|
|
824
884
|
error: string | null;
|
|
825
885
|
onDiscard: () => void;
|
|
826
886
|
onSave: () => void;
|
|
827
887
|
}) {
|
|
828
|
-
const
|
|
888
|
+
const count = pending.length;
|
|
829
889
|
return (
|
|
830
890
|
<div className="pending-bar" role="region" aria-label="Unsaved changes">
|
|
831
891
|
<span className="pending-count">
|
|
832
892
|
<span className="dot" aria-hidden />
|
|
833
|
-
{
|
|
893
|
+
{count} unsaved change{count === 1 ? '' : 's'}
|
|
894
|
+
</span>
|
|
895
|
+
<span className="pending-summary">
|
|
896
|
+
{pending.slice(0, 3).map((item, index) => (
|
|
897
|
+
<span key={`${item.key}:${index}`}>
|
|
898
|
+
{index > 0 && ' · '}
|
|
899
|
+
<span className="mono">{item.key}</span> {item.what}
|
|
900
|
+
</span>
|
|
901
|
+
))}
|
|
902
|
+
{count > 3 && ` · and ${count - 3} more`}
|
|
834
903
|
</span>
|
|
835
904
|
<div className="pending-actions">
|
|
836
905
|
<button className="btn btn-sm" onClick={onDiscard}>
|
|
@@ -839,11 +908,11 @@ function PendingBar({
|
|
|
839
908
|
<button
|
|
840
909
|
className="btn btn-sm btn-primary"
|
|
841
910
|
onClick={onSave}
|
|
842
|
-
disabled={!
|
|
911
|
+
disabled={!ready}
|
|
843
912
|
title="Save (⌘ Enter or Ctrl Enter)"
|
|
844
913
|
aria-keyshortcuts="Meta+Enter Control+Enter"
|
|
845
914
|
>
|
|
846
|
-
Save
|
|
915
|
+
Save {count === 1 ? 'change' : `${count} changes`}
|
|
847
916
|
</button>
|
|
848
917
|
</div>
|
|
849
918
|
{error !== null && (
|
|
@@ -993,8 +1062,7 @@ function ValueField({
|
|
|
993
1062
|
autoFocus,
|
|
994
1063
|
onEscape,
|
|
995
1064
|
generate,
|
|
996
|
-
|
|
997
|
-
showable,
|
|
1065
|
+
plain = false,
|
|
998
1066
|
}: {
|
|
999
1067
|
label: string;
|
|
1000
1068
|
value: string;
|
|
@@ -1013,17 +1081,11 @@ function ValueField({
|
|
|
1013
1081
|
companion: Companion | undefined;
|
|
1014
1082
|
onUse: (use: GeneratedUse) => void;
|
|
1015
1083
|
};
|
|
1016
|
-
/**
|
|
1017
|
-
|
|
1018
|
-
* for, naming the control: a plain value, no secret, shows as it is typed.
|
|
1019
|
-
*/
|
|
1020
|
-
level: { name: string; value: Sensitivity; levels: Record<Sensitivity, { label: string; hint: string }>; onChange: (level: Sensitivity) => void };
|
|
1021
|
-
/** Whether a masked value can be shown while it is edited: not a new one's, which is typed fresh. */
|
|
1022
|
-
showable: boolean;
|
|
1084
|
+
/** A plain value, no secret: shown as it is typed. */
|
|
1085
|
+
plain?: boolean;
|
|
1023
1086
|
}) {
|
|
1024
1087
|
const [shown, setShown] = useState(false);
|
|
1025
1088
|
const [generating, setGenerating] = useState(false);
|
|
1026
|
-
const plain = level.value === 'plain';
|
|
1027
1089
|
// A value with a line break is edited in a textarea, and stays in one to
|
|
1028
1090
|
// the end of the edit: taking its last line break out moves no focus.
|
|
1029
1091
|
const [lines, setLines] = useState(() => start.includes('\n') || value.includes('\n'));
|
|
@@ -1051,9 +1113,8 @@ function ValueField({
|
|
|
1051
1113
|
if (event.key === 'Escape' && onEscape !== undefined) onEscape();
|
|
1052
1114
|
},
|
|
1053
1115
|
};
|
|
1054
|
-
// One field to the eye, its controls inside its right end: who sees the value, Generate, and Show.
|
|
1055
1116
|
return (
|
|
1056
|
-
<div className="
|
|
1117
|
+
<div className="input-group has-generate">
|
|
1057
1118
|
{/* A value with line breaks opens one line tall, as tall as the row it
|
|
1058
1119
|
replaces, and grows only by the lines typed or pasted into it. */}
|
|
1059
1120
|
{lines ? (
|
|
@@ -1092,38 +1153,29 @@ function ValueField({
|
|
|
1092
1153
|
}}
|
|
1093
1154
|
/>
|
|
1094
1155
|
)}
|
|
1095
|
-
<
|
|
1096
|
-
<
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1156
|
+
<Tip label="Generate a value">
|
|
1157
|
+
<button
|
|
1158
|
+
type="button"
|
|
1159
|
+
className="btn btn-quiet btn-sm btn-icon input-addon input-addon-generate"
|
|
1160
|
+
aria-label={`Generate a value for ${generate.name.trim() === '' ? 'the new secret' : generate.name.trim()}`}
|
|
1100
1161
|
disabled={disabled}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
className="btn btn-quiet btn-sm btn-icon"
|
|
1119
|
-
aria-label={shown ? 'Mask the value' : 'Show the value'}
|
|
1120
|
-
aria-pressed={shown}
|
|
1121
|
-
onClick={() => setShown((current) => !current)}
|
|
1122
|
-
>
|
|
1123
|
-
{shown ? <EyeOff size={14} /> : <Eye size={14} />}
|
|
1124
|
-
</button>
|
|
1125
|
-
)}
|
|
1126
|
-
</div>
|
|
1162
|
+
onClick={() => setGenerating(true)}
|
|
1163
|
+
>
|
|
1164
|
+
<Generate size={14} />
|
|
1165
|
+
</button>
|
|
1166
|
+
</Tip>
|
|
1167
|
+
{/* A plain value shows as it is: nothing to mask. */}
|
|
1168
|
+
{!plain && (
|
|
1169
|
+
<button
|
|
1170
|
+
type="button"
|
|
1171
|
+
className="btn btn-quiet btn-sm btn-icon input-addon"
|
|
1172
|
+
aria-label={shown ? 'Mask the value' : 'Show the value'}
|
|
1173
|
+
aria-pressed={shown}
|
|
1174
|
+
onClick={() => setShown((current) => !current)}
|
|
1175
|
+
>
|
|
1176
|
+
{shown ? <EyeOff size={14} /> : <Eye size={14} />}
|
|
1177
|
+
</button>
|
|
1178
|
+
)}
|
|
1127
1179
|
<GenerateValue
|
|
1128
1180
|
open={generating}
|
|
1129
1181
|
onOpenChange={setGenerating}
|
|
@@ -1196,8 +1248,9 @@ function SecretRow({
|
|
|
1196
1248
|
onEdit,
|
|
1197
1249
|
onPatch,
|
|
1198
1250
|
onUndo,
|
|
1251
|
+
onSave,
|
|
1199
1252
|
versionOf,
|
|
1200
|
-
|
|
1253
|
+
saveReady,
|
|
1201
1254
|
onMarkArchive,
|
|
1202
1255
|
personal,
|
|
1203
1256
|
}: {
|
|
@@ -1238,12 +1291,12 @@ function SecretRow({
|
|
|
1238
1291
|
onFork: (action: ForkAction) => void;
|
|
1239
1292
|
onEdit: () => void;
|
|
1240
1293
|
onPatch: (patch: Partial<SecretChange>) => void;
|
|
1241
|
-
/** Its edit given up, or its mark to archive taken off. */
|
|
1242
1294
|
onUndo: () => void;
|
|
1295
|
+
/** This row's change alone, saved now. */
|
|
1296
|
+
onSave: () => void;
|
|
1243
1297
|
/** The current version of a key in this environment, for a companion's note. */
|
|
1244
1298
|
versionOf: (key: string) => number | null;
|
|
1245
|
-
|
|
1246
|
-
attempted: boolean;
|
|
1299
|
+
saveReady: boolean;
|
|
1247
1300
|
onMarkArchive: () => void;
|
|
1248
1301
|
/** In your personal config, `dev@me`, whose overrides are your own values. */
|
|
1249
1302
|
personal: boolean;
|
|
@@ -1252,6 +1305,7 @@ function SecretRow({
|
|
|
1252
1305
|
const { reveal, revealing, error, copyError } = reads;
|
|
1253
1306
|
const setReveal = (next: Reveal | null) => dispatch({ type: 'set-reveal', reveal: next });
|
|
1254
1307
|
const coffre = useCoffre();
|
|
1308
|
+
const queryClient = useQueryClient();
|
|
1255
1309
|
const [historyOpen, setHistoryOpen] = useState(false);
|
|
1256
1310
|
const [moving, setMoving] = useState(false);
|
|
1257
1311
|
const [referring, setReferring] = useState(false);
|
|
@@ -1280,8 +1334,8 @@ function SecretRow({
|
|
|
1280
1334
|
const canRead = entry.readable;
|
|
1281
1335
|
// What a reveal shows: its own version, or, as a reference, its source's.
|
|
1282
1336
|
const readVersion = reference === null ? entry.version : reference.version;
|
|
1283
|
-
// And
|
|
1284
|
-
const readFrom =
|
|
1337
|
+
// And the secret it is held in: a reset, an override or a new reference changes it, maybe under the same number.
|
|
1338
|
+
const readFrom = entry.secret;
|
|
1285
1339
|
const holderPath = `${project}/${environment}/${entry.key}`;
|
|
1286
1340
|
// A plain value is no secret: listed as it is, shown inline and copied with no read.
|
|
1287
1341
|
const rowPlain = entry.value !== null;
|
|
@@ -1320,26 +1374,26 @@ function SecretRow({
|
|
|
1320
1374
|
if (!editing) setBase(null);
|
|
1321
1375
|
}, [editing]);
|
|
1322
1376
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1377
|
+
// A value read is stamped with the version it opened, after the listing has caught up with it (`stampedRead`).
|
|
1378
|
+
async function readValue({ show = true } = {}): Promise<Reveal | null> {
|
|
1379
|
+
if (shown !== null) return shown;
|
|
1325
1380
|
dispatch({ type: 'read-started' });
|
|
1326
1381
|
try {
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
return value;
|
|
1382
|
+
const read = await stampedRead({ version: readVersion, from: readFrom }, fetchValue, () =>
|
|
1383
|
+
queryClient.refetchQueries({ queryKey: queryKeys.secrets({ project, environment }) }),
|
|
1384
|
+
);
|
|
1385
|
+
dispatch({ type: 'read-succeeded', reveal: show ? read : null });
|
|
1386
|
+
return read;
|
|
1333
1387
|
} catch (failure) {
|
|
1334
1388
|
dispatch({ type: 'read-failed', message: readFailureMessage(failure) });
|
|
1335
1389
|
return null;
|
|
1336
1390
|
}
|
|
1337
1391
|
}
|
|
1338
1392
|
|
|
1339
|
-
async function fetchValue(): Promise<
|
|
1340
|
-
if (entry.value !== null) return entry.value;
|
|
1341
|
-
const { values } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
|
|
1342
|
-
return values[entry.key];
|
|
1393
|
+
async function fetchValue(): Promise<Read> {
|
|
1394
|
+
if (entry.value !== null) return { value: entry.value, version: readVersion, from: readFrom };
|
|
1395
|
+
const { values, versions, secrets } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
|
|
1396
|
+
return { value: values[entry.key], version: versions[entry.key], from: secrets[entry.key] };
|
|
1343
1397
|
}
|
|
1344
1398
|
|
|
1345
1399
|
function toggleReveal() {
|
|
@@ -1361,7 +1415,7 @@ function SecretRow({
|
|
|
1361
1415
|
const text =
|
|
1362
1416
|
shown !== null
|
|
1363
1417
|
? shown.value
|
|
1364
|
-
: fetchValue().
|
|
1418
|
+
: fetchValue().then(({ value }) => value, (failure: unknown) => {
|
|
1365
1419
|
read.failed = true;
|
|
1366
1420
|
read.failure = failure;
|
|
1367
1421
|
throw failure;
|
|
@@ -1391,9 +1445,9 @@ function SecretRow({
|
|
|
1391
1445
|
async function startEdit({ name = false } = {}) {
|
|
1392
1446
|
setFocusName(name);
|
|
1393
1447
|
setOpening(entry.value === null && canRead);
|
|
1394
|
-
const value = await valueToEdit(entry, () => readValue({ show: false }));
|
|
1448
|
+
const value = await valueToEdit(entry, () => readValue({ show: false }), (listed) => ({ value: listed, version: readVersion, from: readFrom, at: Date.now() }));
|
|
1395
1449
|
setOpening(false);
|
|
1396
|
-
if (value !== null) setBase(
|
|
1450
|
+
if (value !== null) setBase(value);
|
|
1397
1451
|
setReveal(null);
|
|
1398
1452
|
onEdit();
|
|
1399
1453
|
}
|
|
@@ -1425,7 +1479,7 @@ function SecretRow({
|
|
|
1425
1479
|
const renamed = change.key !== entry.key;
|
|
1426
1480
|
// A new value, or a level alone, a mark: either makes a new version.
|
|
1427
1481
|
const valueChanged = change.value !== null || change.sensitivity !== undefined;
|
|
1428
|
-
const keyProblem = editing ?
|
|
1482
|
+
const keyProblem = editing ? secretKeyProblem(change.key.trim()) : null;
|
|
1429
1483
|
const state = leaving
|
|
1430
1484
|
? ' is-leaving'
|
|
1431
1485
|
: editing && (renamed || valueChanged)
|
|
@@ -1441,7 +1495,7 @@ function SecretRow({
|
|
|
1441
1495
|
|
|
1442
1496
|
return (
|
|
1443
1497
|
<>
|
|
1444
|
-
<tr className={`secret-row${state}
|
|
1498
|
+
<tr className={`secret-row${state} ${rowClass(status)}`}>
|
|
1445
1499
|
<td className="n">{number}</td>
|
|
1446
1500
|
<td className="cell-key" data-label="Key">
|
|
1447
1501
|
{/* An inherited key has no row here to rename: overriding it keeps its name. */}
|
|
@@ -1499,8 +1553,8 @@ function SecretRow({
|
|
|
1499
1553
|
</td>
|
|
1500
1554
|
|
|
1501
1555
|
<td data-label="Value">
|
|
1502
|
-
{/* What acts on the value sits beside it: reading, Copy, Reveal and Edit
|
|
1503
|
-
|
|
1556
|
+
{/* What acts on the value sits beside it: reading, Copy, Reveal and Edit;
|
|
1557
|
+
editing or marked for archiving, Save and Cancel, in the same place. */}
|
|
1504
1558
|
<div className="value-cell">
|
|
1505
1559
|
<div className="value-content">
|
|
1506
1560
|
{editing && canWrite ? (
|
|
@@ -1517,6 +1571,7 @@ function SecretRow({
|
|
|
1517
1571
|
: error !== null ? 'New value; the current one could not be read'
|
|
1518
1572
|
: canRead ? 'New value' : 'New value; the current one is hidden from you'
|
|
1519
1573
|
}
|
|
1574
|
+
plain={level === 'plain'}
|
|
1520
1575
|
disabled={disabled}
|
|
1521
1576
|
autoFocus={!focusName}
|
|
1522
1577
|
// A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
|
|
@@ -1532,17 +1587,17 @@ function SecretRow({
|
|
|
1532
1587
|
// A generated value is never plain.
|
|
1533
1588
|
onUse: ({ value, companion, recipe }) => onPatch({ value, companion, recipe, sensitivity: level === 'plain' ? 'secret' : level }),
|
|
1534
1589
|
}}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
}),
|
|
1544
|
-
|
|
1545
|
-
|
|
1590
|
+
/>
|
|
1591
|
+
<SensitivityField
|
|
1592
|
+
name={change.key.trim() === '' ? entry.key : change.key.trim()}
|
|
1593
|
+
value={level}
|
|
1594
|
+
levels={levelsIn(personal)}
|
|
1595
|
+
disabled={disabled}
|
|
1596
|
+
// A value made plain is typed by hand: it drops the recipe of one generated.
|
|
1597
|
+
onChange={(next) => onPatch({
|
|
1598
|
+
...valueEdit(from(), { value: change.value, sensitivity: next }),
|
|
1599
|
+
...(next === 'plain' ? { companion: undefined, recipe: undefined } : {}),
|
|
1600
|
+
})}
|
|
1546
1601
|
/>
|
|
1547
1602
|
{waitsForValue(entry, change) && (
|
|
1548
1603
|
<span className="edit-note">
|
|
@@ -1582,9 +1637,32 @@ function SecretRow({
|
|
|
1582
1637
|
</span>
|
|
1583
1638
|
)}
|
|
1584
1639
|
</div>
|
|
1585
|
-
{status.state !== 'pending' &&
|
|
1640
|
+
{status.state !== 'pending' && (
|
|
1586
1641
|
<div className="acts value-acts">
|
|
1587
|
-
{
|
|
1642
|
+
{editing || leaving ? (
|
|
1643
|
+
<>
|
|
1644
|
+
<Tip label={leaving ? 'Archive now' : 'Save'}>
|
|
1645
|
+
<button
|
|
1646
|
+
className="act act-icon act-accent"
|
|
1647
|
+
onClick={onSave}
|
|
1648
|
+
disabled={disabled || !saveReady}
|
|
1649
|
+
aria-label={`${leaving ? 'Archive' : 'Save'} ${entry.key} now`}
|
|
1650
|
+
>
|
|
1651
|
+
<Check size={15} />
|
|
1652
|
+
</button>
|
|
1653
|
+
</Tip>
|
|
1654
|
+
<Tip label={leaving ? 'Keep' : 'Cancel'}>
|
|
1655
|
+
<button
|
|
1656
|
+
className="act act-icon act-quiet"
|
|
1657
|
+
onClick={onUndo}
|
|
1658
|
+
disabled={disabled}
|
|
1659
|
+
aria-label={leaving ? `Keep ${entry.key}` : `Cancel editing ${entry.key}`}
|
|
1660
|
+
>
|
|
1661
|
+
<X size={15} />
|
|
1662
|
+
</button>
|
|
1663
|
+
</Tip>
|
|
1664
|
+
</>
|
|
1665
|
+
) : removed ? (
|
|
1588
1666
|
canWrite && (
|
|
1589
1667
|
<button type="button" className="btn btn-sm" onClick={() => onFork('restore')} disabled={disabled}>
|
|
1590
1668
|
Restore
|
|
@@ -1662,7 +1740,7 @@ function SecretRow({
|
|
|
1662
1740
|
{status.state === 'pending' ? (
|
|
1663
1741
|
<RowPending status={status} />
|
|
1664
1742
|
) : (
|
|
1665
|
-
!removed && (canList ||
|
|
1743
|
+
!removed && (canList || (canWrite && !editing && !leaving) || (canArchive && !leaving && own && !overridden)) && (
|
|
1666
1744
|
<Menu.Root>
|
|
1667
1745
|
<Menu.Trigger
|
|
1668
1746
|
className="act act-icon act-quiet"
|
|
@@ -1740,15 +1818,22 @@ function SecretRow({
|
|
|
1740
1818
|
{canWrite && !editing && !leaving && markable(entry) && (
|
|
1741
1819
|
<>
|
|
1742
1820
|
<Menu.Separator className="menu-sep" />
|
|
1743
|
-
<
|
|
1821
|
+
<Menu.RadioGroup value={entry.sensitivity} onValueChange={(next: Sensitivity) => chooseLevel(next)}>
|
|
1822
|
+
<Menu.GroupLabel className="menu-label">Who sees it</Menu.GroupLabel>
|
|
1823
|
+
{SENSITIVITIES.map((each) => (
|
|
1824
|
+
<Menu.RadioItem key={each} value={each} className="menu-item menu-item-level" closeOnClick>
|
|
1825
|
+
<span className="menu-item-text">
|
|
1826
|
+
{levelsIn(personal)[each].label}
|
|
1827
|
+
<span className="menu-item-hint">{levelsIn(personal)[each].hint}</span>
|
|
1828
|
+
</span>
|
|
1829
|
+
<Menu.RadioItemIndicator className="menu-check">
|
|
1830
|
+
<Check size={14} />
|
|
1831
|
+
</Menu.RadioItemIndicator>
|
|
1832
|
+
</Menu.RadioItem>
|
|
1833
|
+
))}
|
|
1834
|
+
</Menu.RadioGroup>
|
|
1744
1835
|
</>
|
|
1745
1836
|
)}
|
|
1746
|
-
{leaving && (
|
|
1747
|
-
<Menu.Item className="menu-item" onClick={onUndo}>
|
|
1748
|
-
<RotateBack size={14} />
|
|
1749
|
-
Don't archive
|
|
1750
|
-
</Menu.Item>
|
|
1751
|
-
)}
|
|
1752
1837
|
{/* An override's way out is Reset, which keeps it; archiving there would be the same, by more. */}
|
|
1753
1838
|
{canArchive && !leaving && own && !overridden && (
|
|
1754
1839
|
<>
|
|
@@ -1921,6 +2006,38 @@ function SecretRow({
|
|
|
1921
2006
|
);
|
|
1922
2007
|
}
|
|
1923
2008
|
|
|
2009
|
+
/** Delete your personal config, from its page: its values erased; dev itself untouched. */
|
|
2010
|
+
function DeletePersonal({ project, environment, of }: { project: string; environment: string; of: string }) {
|
|
2011
|
+
const coffre = useCoffre();
|
|
2012
|
+
const navigate = useNavigate();
|
|
2013
|
+
const [open, setOpen] = useState(false);
|
|
2014
|
+
const { error, run } = useAction();
|
|
2015
|
+
return (
|
|
2016
|
+
<>
|
|
2017
|
+
<button type="button" className="btn btn-sm" onClick={() => setOpen(true)}>
|
|
2018
|
+
<Trash size={14} />
|
|
2019
|
+
Delete…
|
|
2020
|
+
</button>
|
|
2021
|
+
{error !== null && <ErrorLine error={error} />}
|
|
2022
|
+
<ConfirmDialog
|
|
2023
|
+
open={open}
|
|
2024
|
+
onOpenChange={setOpen}
|
|
2025
|
+
title={<>Delete your own <span className="mono">{of}</span>?</>}
|
|
2026
|
+
body={`The values you set in ${project}/${environment} are erased for good. ${project}/${of} is untouched, and ${environment} reads it again.`}
|
|
2027
|
+
confirmLabel="Delete"
|
|
2028
|
+
onConfirm={() =>
|
|
2029
|
+
void run(() => coffre.environments.delete(`${project}/${environment}`), {
|
|
2030
|
+
affects: [...affects.secrets({ project, environment }), ...affects.places()],
|
|
2031
|
+
onSuccess: () => {
|
|
2032
|
+
toast.success(`Your own ${of} is deleted`);
|
|
2033
|
+
void navigate({ to: '/projects/$project/$environment', params: { project, environment: of } });
|
|
2034
|
+
},
|
|
2035
|
+
})}
|
|
2036
|
+
/>
|
|
2037
|
+
</>
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
2040
|
+
|
|
1924
2041
|
/**
|
|
1925
2042
|
* `dev@me` while you have no personal dev: what one is, and Make, which
|
|
1926
2043
|
* makes it empty; your first write would make it too. A read of
|
|
@@ -2037,7 +2154,7 @@ function SortHeader({
|
|
|
2037
2154
|
*/
|
|
2038
2155
|
function Written({ entry, rotateAfterDays }: { entry: SecretKey; rotateAfterDays: number | null }) {
|
|
2039
2156
|
const { reference } = entry;
|
|
2040
|
-
const made = reference === null
|
|
2157
|
+
const made = reference?.createdBy == null || reference.createdAt === null
|
|
2041
2158
|
? undefined
|
|
2042
2159
|
: `Reference made by ${shownMember(reference.createdBy).replace(/^user:/, '')} on ${reference.createdAt.slice(0, 10)}`;
|
|
2043
2160
|
if (entry.updatedAt === null) {
|
|
@@ -2053,7 +2170,7 @@ function Written({ entry, rotateAfterDays }: { entry: SecretKey; rotateAfterDays
|
|
|
2053
2170
|
{by.split('@')[0]}
|
|
2054
2171
|
</span>
|
|
2055
2172
|
) : (
|
|
2056
|
-
<span className="written-by cell-muted" title={`Its source's current version. ${made}`}>
|
|
2173
|
+
<span className="written-by cell-muted" title={made === undefined ? "Its source's current version" : `Its source's current version. ${made}`}>
|
|
2057
2174
|
source
|
|
2058
2175
|
</span>
|
|
2059
2176
|
)}
|
|
@@ -2075,17 +2192,18 @@ function Written({ entry, rotateAfterDays }: { entry: SecretKey; rotateAfterDays
|
|
|
2075
2192
|
}
|
|
2076
2193
|
|
|
2077
2194
|
/**
|
|
2078
|
-
* Who sees the value being written,
|
|
2079
|
-
*
|
|
2195
|
+
* Who sees the value being written, loosest first, and beside it what the
|
|
2196
|
+
* level pointed at, or else the one chosen, means. Native radios: the arrow
|
|
2197
|
+
* keys move the choice, and a screen reader hears one group of three.
|
|
2080
2198
|
*/
|
|
2081
|
-
function
|
|
2199
|
+
function SensitivityField({
|
|
2082
2200
|
name,
|
|
2083
2201
|
value,
|
|
2084
2202
|
levels,
|
|
2085
2203
|
disabled,
|
|
2086
2204
|
onChange,
|
|
2087
2205
|
}: {
|
|
2088
|
-
/** The key it is for, naming the
|
|
2206
|
+
/** The key it is for, naming the group. */
|
|
2089
2207
|
name: string;
|
|
2090
2208
|
value: Sensitivity;
|
|
2091
2209
|
/** Each level as it is named here (`levelsIn`). */
|
|
@@ -2093,45 +2211,28 @@ function SensitivityMenu({
|
|
|
2093
2211
|
disabled: boolean;
|
|
2094
2212
|
onChange: (level: Sensitivity) => void;
|
|
2095
2213
|
}) {
|
|
2214
|
+
const id = useId();
|
|
2215
|
+
const [pointed, setPointed] = useState<Sensitivity | null>(null);
|
|
2096
2216
|
return (
|
|
2097
|
-
<
|
|
2098
|
-
<
|
|
2099
|
-
{
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
value: Sensitivity | null;
|
|
2117
|
-
levels: Record<Sensitivity, { label: string; hint: string }>;
|
|
2118
|
-
onChange: (level: Sensitivity) => void;
|
|
2119
|
-
}) {
|
|
2120
|
-
return (
|
|
2121
|
-
<Menu.RadioGroup value={value} onValueChange={(next: Sensitivity) => onChange(next)}>
|
|
2122
|
-
<Menu.GroupLabel className="menu-label">Who sees it</Menu.GroupLabel>
|
|
2123
|
-
{SENSITIVITIES.map((each) => (
|
|
2124
|
-
<Menu.RadioItem key={each} value={each} className="menu-item menu-item-level" closeOnClick>
|
|
2125
|
-
<span className="menu-item-text">
|
|
2126
|
-
{levels[each].label}
|
|
2127
|
-
<span className="menu-item-hint">{levels[each].hint}</span>
|
|
2128
|
-
</span>
|
|
2129
|
-
<Menu.RadioItemIndicator className="menu-check">
|
|
2130
|
-
<Check size={14} />
|
|
2131
|
-
</Menu.RadioItemIndicator>
|
|
2132
|
-
</Menu.RadioItem>
|
|
2133
|
-
))}
|
|
2134
|
-
</Menu.RadioGroup>
|
|
2217
|
+
<div className="edit-note sensitivity-field">
|
|
2218
|
+
<div className="segmented segmented-sm" role="radiogroup" aria-label={`Who sees ${name}`} aria-describedby={`${id}-hint`}>
|
|
2219
|
+
{SENSITIVITIES.map((level) => (
|
|
2220
|
+
<label key={level} onPointerEnter={() => setPointed(level)} onPointerLeave={() => setPointed(null)}>
|
|
2221
|
+
<input
|
|
2222
|
+
type="radio"
|
|
2223
|
+
className="visually-hidden"
|
|
2224
|
+
name={id}
|
|
2225
|
+
value={level}
|
|
2226
|
+
checked={value === level}
|
|
2227
|
+
disabled={disabled}
|
|
2228
|
+
onChange={() => onChange(level)}
|
|
2229
|
+
/>
|
|
2230
|
+
{levels[level].label}
|
|
2231
|
+
</label>
|
|
2232
|
+
))}
|
|
2233
|
+
</div>
|
|
2234
|
+
<span id={`${id}-hint`}>{levels[pointed ?? value].hint}</span>
|
|
2235
|
+
</div>
|
|
2135
2236
|
);
|
|
2136
2237
|
}
|
|
2137
2238
|
|
|
@@ -2140,8 +2241,7 @@ function SensitivityItems({
|
|
|
2140
2241
|
*
|
|
2141
2242
|
* This replaced a separate "Add a secret" form. The form made you look away
|
|
2142
2243
|
* from the list to add to it, and only ever accepted one key at a time; a row
|
|
2143
|
-
* in place accepts as many as you want to queue
|
|
2144
|
-
* bar under the table.
|
|
2244
|
+
* in place accepts as many as you want to queue.
|
|
2145
2245
|
*/
|
|
2146
2246
|
function DraftRow({
|
|
2147
2247
|
draft,
|
|
@@ -2149,8 +2249,9 @@ function DraftRow({
|
|
|
2149
2249
|
disabled,
|
|
2150
2250
|
onChange,
|
|
2151
2251
|
onRemove,
|
|
2252
|
+
onSave,
|
|
2152
2253
|
versionOf,
|
|
2153
|
-
|
|
2254
|
+
saveReady,
|
|
2154
2255
|
personal,
|
|
2155
2256
|
}: {
|
|
2156
2257
|
draft: SecretDraft;
|
|
@@ -2158,19 +2259,21 @@ function DraftRow({
|
|
|
2158
2259
|
disabled: boolean;
|
|
2159
2260
|
onChange: (patch: Partial<SecretDraft>) => void;
|
|
2160
2261
|
onRemove: () => void;
|
|
2262
|
+
/** This new secret alone, saved now. */
|
|
2263
|
+
onSave: () => void;
|
|
2161
2264
|
/** The current version of a key in this environment, for a companion's note. */
|
|
2162
2265
|
versionOf: (key: string) => number | null;
|
|
2163
|
-
|
|
2164
|
-
attempted: boolean;
|
|
2266
|
+
saveReady: boolean;
|
|
2165
2267
|
/** In your personal config, `dev@me`, whose values are your own. */
|
|
2166
2268
|
personal: boolean;
|
|
2167
2269
|
}) {
|
|
2270
|
+
const [touched, setTouched] = useState(false);
|
|
2168
2271
|
const trimmed = draft.key.trim();
|
|
2169
|
-
const keyProblem =
|
|
2272
|
+
const keyProblem = trimmed === '' ? (touched ? 'Give it a name.' : null) : secretKeyProblem(trimmed);
|
|
2170
2273
|
const isNewVersion = trimmed !== '' && existingVersion !== null;
|
|
2171
2274
|
|
|
2172
2275
|
return (
|
|
2173
|
-
<tr className="secret-row is-draft
|
|
2276
|
+
<tr className="secret-row is-draft">
|
|
2174
2277
|
<td className="n" aria-label="New">
|
|
2175
2278
|
+
|
|
2176
2279
|
</td>
|
|
@@ -2188,6 +2291,7 @@ function DraftRow({
|
|
|
2188
2291
|
autoComplete="off"
|
|
2189
2292
|
value={draft.key}
|
|
2190
2293
|
disabled={disabled}
|
|
2294
|
+
onBlur={() => setTouched(true)}
|
|
2191
2295
|
onChange={(event) => onChange({ key: event.target.value })}
|
|
2192
2296
|
onKeyDown={(event) => {
|
|
2193
2297
|
if (event.key === 'Escape') onRemove();
|
|
@@ -2195,39 +2299,67 @@ function DraftRow({
|
|
|
2195
2299
|
/>
|
|
2196
2300
|
{(keyProblem !== null || isNewVersion) && (
|
|
2197
2301
|
<span className={`edit-note${keyProblem !== null ? ' edit-note-error' : ''}`}>
|
|
2198
|
-
{keyProblem ??
|
|
2302
|
+
{keyProblem ??
|
|
2303
|
+
'This name exists here already. Saving adds a new version to it.'}
|
|
2199
2304
|
</span>
|
|
2200
2305
|
)}
|
|
2201
2306
|
</div>
|
|
2202
2307
|
</td>
|
|
2203
2308
|
<td data-label="Value">
|
|
2204
|
-
<div className="
|
|
2205
|
-
<
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2309
|
+
<div className="value-cell">
|
|
2310
|
+
<div className="value-content">
|
|
2311
|
+
<div className="edit-stack">
|
|
2312
|
+
<ValueField
|
|
2313
|
+
label={`Value for ${trimmed === '' ? 'the new secret' : trimmed}`}
|
|
2314
|
+
value={draft.value}
|
|
2315
|
+
plain={draft.sensitivity === 'plain'}
|
|
2316
|
+
placeholder="Value"
|
|
2317
|
+
disabled={disabled}
|
|
2318
|
+
// A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
|
|
2319
|
+
onChange={(value) => onChange({ value, companion: undefined, recipe: undefined })}
|
|
2320
|
+
onEscape={onRemove}
|
|
2321
|
+
generate={{
|
|
2322
|
+
name: draft.key,
|
|
2323
|
+
renamable: true,
|
|
2324
|
+
companion: draft.companion,
|
|
2325
|
+
// A generated value is never plain.
|
|
2326
|
+
onUse: ({ value, name, companion, recipe }) =>
|
|
2327
|
+
onChange({ key: name, value, companion, recipe, sensitivity: draft.sensitivity === 'plain' ? 'secret' : draft.sensitivity }),
|
|
2328
|
+
}}
|
|
2329
|
+
/>
|
|
2330
|
+
<SensitivityField
|
|
2331
|
+
name={trimmed === '' ? 'the new secret' : trimmed}
|
|
2332
|
+
value={draft.sensitivity}
|
|
2333
|
+
levels={levelsIn(personal)}
|
|
2334
|
+
disabled={disabled}
|
|
2335
|
+
// A value made plain is typed by hand: it drops the recipe of one generated.
|
|
2336
|
+
onChange={(sensitivity) => onChange(sensitivity === 'plain' ? { sensitivity, companion: undefined, recipe: undefined } : { sensitivity })}
|
|
2337
|
+
/>
|
|
2338
|
+
<CompanionNote companion={draft.companion} versionOf={versionOf} />
|
|
2339
|
+
</div>
|
|
2340
|
+
</div>
|
|
2341
|
+
<div className="acts value-acts">
|
|
2342
|
+
<Tip label="Save">
|
|
2343
|
+
<button
|
|
2344
|
+
className="act act-icon act-accent"
|
|
2345
|
+
onClick={onSave}
|
|
2346
|
+
disabled={disabled || !saveReady}
|
|
2347
|
+
aria-label={trimmed === '' ? 'Save this new secret now' : `Save ${trimmed} now`}
|
|
2348
|
+
>
|
|
2349
|
+
<Check size={15} />
|
|
2350
|
+
</button>
|
|
2351
|
+
</Tip>
|
|
2352
|
+
<Tip label="Cancel">
|
|
2353
|
+
<button
|
|
2354
|
+
className="act act-icon act-quiet"
|
|
2355
|
+
onClick={onRemove}
|
|
2356
|
+
disabled={disabled}
|
|
2357
|
+
aria-label={trimmed === '' ? 'Remove this new secret' : `Remove new secret ${trimmed}`}
|
|
2358
|
+
>
|
|
2359
|
+
<X size={15} />
|
|
2360
|
+
</button>
|
|
2361
|
+
</Tip>
|
|
2362
|
+
</div>
|
|
2231
2363
|
</div>
|
|
2232
2364
|
</td>
|
|
2233
2365
|
<td className="col-version" data-label="Version">
|
|
@@ -2249,12 +2381,6 @@ function DraftRow({
|
|
|
2249
2381
|
);
|
|
2250
2382
|
}
|
|
2251
2383
|
|
|
2252
|
-
/** 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. */
|
|
2253
|
-
function nameProblem(name: string, attempted: boolean): string | null {
|
|
2254
|
-
if (name === '') return attempted ? 'Give it a name.' : null;
|
|
2255
|
-
return secretKeyProblem(name);
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
2384
|
function ArchivedRow({
|
|
2259
2385
|
number,
|
|
2260
2386
|
project,
|