@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.
- package/dist/chunks/{audit-sentence-JgJEwQEC.js → actions-log-DupYCEyV.js} +186 -21
- package/dist/chunks/actions-log-DupYCEyV.js.map +1 -0
- package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-CGUQlFMx.js} +5 -5
- package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-CGUQlFMx.js.map} +1 -1
- package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-CswZ-meh.js} +5 -5
- package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-CswZ-meh.js.map} +1 -1
- package/dist/chunks/{directory-BM8yoiJN.js → directory-DrswWQLT.js} +15 -15
- package/dist/chunks/directory-DrswWQLT.js.map +1 -0
- package/dist/chunks/environment-actions-8rL9Cw6X.js +576 -0
- package/dist/chunks/environment-actions-8rL9Cw6X.js.map +1 -0
- package/dist/chunks/{folders-D3A1NGpt.js → folders-A6sbR_PG.js} +3 -3
- package/dist/chunks/{folders-D3A1NGpt.js.map → folders-A6sbR_PG.js.map} +1 -1
- package/dist/chunks/{grants-CjVmOgb2.js → grants-C0cb2oii.js} +8 -8
- package/dist/chunks/grants-C0cb2oii.js.map +1 -0
- package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-B3SEv1gq.js} +3 -3
- package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-B3SEv1gq.js.map} +1 -1
- package/dist/chunks/{offboarding-DbozhPym.js → offboarding-C1jbG_dk.js} +72 -67
- package/dist/chunks/offboarding-C1jbG_dk.js.map +1 -0
- package/dist/chunks/{page-JTORvh-N.js → page-CfhC9Hp1.js} +11 -6
- package/dist/chunks/page-CfhC9Hp1.js.map +1 -0
- package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-xC9wulhg.js} +5 -5
- package/dist/chunks/{personal-tokens-zWZOzLIC.js.map → personal-tokens-xC9wulhg.js.map} +1 -1
- package/dist/chunks/{principal-DFBswTBr.js → principal-CI17XK13.js} +2 -2
- package/dist/chunks/{principal-DFBswTBr.js.map → principal-CI17XK13.js.map} +1 -1
- package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-CdSeftGD.js} +17 -127
- package/dist/chunks/principal-page-CdSeftGD.js.map +1 -0
- package/dist/chunks/{project-page-BjwEoXfU.js → project-page-CHxjBE97.js} +3 -3
- package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-CHxjBE97.js.map} +1 -1
- package/dist/chunks/{queries-2jdgTwfZ.js → queries-D1JuimTu.js} +82 -26
- package/dist/chunks/queries-D1JuimTu.js.map +1 -0
- package/dist/chunks/{references-CRT2BsOS.js → references-D5llUGQL.js} +5 -5
- package/dist/chunks/{references-CRT2BsOS.js.map → references-D5llUGQL.js.map} +1 -1
- package/dist/chunks/{role-field-DswIpPqY.js → role-field-CoCv8wse.js} +5 -5
- package/dist/chunks/role-field-CoCv8wse.js.map +1 -0
- package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYH7kZHl.js} +3 -3
- package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYH7kZHl.js.map} +1 -1
- package/dist/chunks/{theme-Ck45wzWB.js → theme-rF44Wbmm.js} +3 -3
- package/dist/chunks/{theme-Ck45wzWB.js.map → theme-rF44Wbmm.js.map} +1 -1
- package/dist/chunks/{ui-D-blFWfx.js → ui-CGdORVzW.js} +2 -2
- package/dist/chunks/{ui-D-blFWfx.js.map → ui-CGdORVzW.js.map} +1 -1
- package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BxrHTBZw.js} +3 -3
- package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BxrHTBZw.js.map} +1 -1
- package/dist/chunks/{use-change-BC4xo02c.js → use-change-BorW2R6C.js} +4 -4
- package/dist/chunks/{use-change-BC4xo02c.js.map → use-change-BorW2R6C.js.map} +1 -1
- package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-BZnJ9Cq0.js} +56 -13
- package/dist/chunks/use-roles-BZnJ9Cq0.js.map +1 -0
- package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-CPskgi1k.js} +3 -3
- package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-CPskgi1k.js.map} +1 -1
- package/dist/index.d.ts +46 -2
- package/dist/index.js +30 -11
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +11 -11
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.js +2 -2
- package/dist/pages/audit.js +55 -21
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -2
- package/dist/pages/environment.js +228 -389
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +3 -3
- package/dist/pages/oauth-authorize.js +2 -2
- package/dist/pages/project-access.js +11 -11
- package/dist/pages/project-environments.js +28 -359
- 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 +11 -10
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +7 -6
- package/dist/pages/service-accounts.js.map +1 -1
- package/dist/pages/settings.d.ts +6 -1
- package/dist/pages/settings.js +284 -164
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -2
- package/dist/pages/user.js +7 -6
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +7 -6
- package/dist/pages/users.js.map +1 -1
- package/package.json +3 -3
- package/src/components/actions-log.tsx +61 -8
- package/src/components/directory.tsx +5 -5
- package/src/components/environment-actions.tsx +508 -0
- package/src/components/grants.tsx +2 -2
- package/src/components/icons.tsx +2 -0
- package/src/components/offboarding.tsx +7 -0
- package/src/components/page.tsx +3 -2
- package/src/components/principal-page.tsx +1 -1
- package/src/components/protected.tsx +52 -39
- package/src/components/role-editor.tsx +99 -68
- package/src/components/role-field.tsx +1 -1
- package/src/lib/audit-sentences.ts +21 -18
- package/src/lib/queries.ts +85 -21
- package/src/lib/roles.ts +36 -10
- package/src/options.ts +19 -3
- package/src/pages/account.tsx +1 -1
- package/src/pages/audit.tsx +56 -16
- package/src/pages/environment.tsx +227 -352
- package/src/pages/project-environments.tsx +20 -322
- package/src/pages/service-accounts.tsx +1 -1
- package/src/pages/settings.tsx +129 -48
- package/src/pages/users.tsx +1 -1
- package/src/parity.ts +18 -11
- package/src/styles/globals.css +271 -89
- package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
- package/dist/chunks/directory-BM8yoiJN.js.map +0 -1
- package/dist/chunks/grants-CjVmOgb2.js.map +0 -1
- package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
- package/dist/chunks/page-JTORvh-N.js.map +0 -1
- package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
- package/dist/chunks/protected-y7KVhtHd.js +0 -77
- package/dist/chunks/protected-y7KVhtHd.js.map +0 -1
- package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
- package/dist/chunks/role-field-DswIpPqY.js.map +0 -1
- package/dist/chunks/use-roles-DswiNxBk.js.map +0 -1
|
@@ -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,
|
|
4
|
+
import { useEffect, useReducer, useRef, useState, type ReactNode } from 'react';
|
|
5
5
|
import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
|
|
6
|
-
import { Link
|
|
6
|
+
import { Link } 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';
|
|
@@ -56,6 +56,7 @@ 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';
|
|
59
60
|
import { SecretReadOnly } from '../components/affordances';
|
|
60
61
|
import { GenerateValue, type GeneratedUse } from '../components/generate-value';
|
|
61
62
|
import { RecipeMark, RegenerateSecret } from '../components/regenerate';
|
|
@@ -89,9 +90,7 @@ import {
|
|
|
89
90
|
Search,
|
|
90
91
|
SlashCircle,
|
|
91
92
|
Terminal,
|
|
92
|
-
Trash,
|
|
93
93
|
Upload,
|
|
94
|
-
X,
|
|
95
94
|
} from '../components/icons';
|
|
96
95
|
import { pageRoute } from '../lib/page-route';
|
|
97
96
|
import type { environment } from '../options';
|
|
@@ -160,8 +159,6 @@ export function EnvironmentPage() {
|
|
|
160
159
|
);
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
type Pending = { key: string; what: string };
|
|
164
|
-
|
|
165
162
|
function EnvironmentLedger({
|
|
166
163
|
project,
|
|
167
164
|
environment,
|
|
@@ -223,14 +220,12 @@ function EnvironmentLedger({
|
|
|
223
220
|
// pending change is in edit mode whether or not it is listed here.
|
|
224
221
|
const [editing, setEditing] = useState<ReadonlySet<string>>(() => new Set());
|
|
225
222
|
const [saveError, setSaveError] = useState<string | null>(null);
|
|
226
|
-
//
|
|
227
|
-
const [
|
|
228
|
-
//
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
else setHiding({ keys, go });
|
|
233
|
-
}
|
|
223
|
+
// Whether Save was pressed since the edits began: a blank name is an error only then.
|
|
224
|
+
const [attempted, setAttempted] = useState(false);
|
|
225
|
+
// Ended with the last open row, however it closed: the next row added starts quiet.
|
|
226
|
+
if (attempted && drafts.length === 0 && Object.keys(changes).length === 0 && editing.size === 0) setAttempted(false);
|
|
227
|
+
// The keys a save makes sensitive, waiting for its confirmation: nobody sees them again, which the row's menu asks too.
|
|
228
|
+
const [hiding, setHiding] = useState<string[] | null>(null);
|
|
234
229
|
const [query, setQuery] = useState(Route.useSearch().filter ?? '');
|
|
235
230
|
const [sort, setSort] = useState<Sort>({ by: 'key', descending: false });
|
|
236
231
|
// A column's first click sorts it ascending: names A to Z, the oldest values first.
|
|
@@ -290,8 +285,9 @@ function EnvironmentLedger({
|
|
|
290
285
|
(entry) => secretChangeFor(changes, entry.key) !== undefined,
|
|
291
286
|
);
|
|
292
287
|
const hasConflict = hasSecretEditConflict(active, drafts, changes);
|
|
293
|
-
// Every name that will be written. Blank ones
|
|
294
|
-
// row you just added is not an error yet --
|
|
288
|
+
// Every name that will be written. Blank ones hold the save back, and say
|
|
289
|
+
// so once Save is pressed -- a row you just added is not an error yet --
|
|
290
|
+
// while malformed ones say why as they are typed.
|
|
295
291
|
const pendingNames = [
|
|
296
292
|
...drafts.map((row) => row.key.trim()),
|
|
297
293
|
...changedEntries.flatMap((entry) => {
|
|
@@ -324,55 +320,6 @@ function EnvironmentLedger({
|
|
|
324
320
|
});
|
|
325
321
|
}
|
|
326
322
|
|
|
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
|
-
|
|
376
323
|
function dropChange(key: string) {
|
|
377
324
|
setChanges((current) => {
|
|
378
325
|
const { [key]: _, ...rest } = current;
|
|
@@ -395,6 +342,7 @@ function EnvironmentLedger({
|
|
|
395
342
|
setChanges({});
|
|
396
343
|
setEditing(new Set());
|
|
397
344
|
setSaveError(null);
|
|
345
|
+
setAttempted(false);
|
|
398
346
|
}
|
|
399
347
|
|
|
400
348
|
/**
|
|
@@ -415,8 +363,13 @@ function EnvironmentLedger({
|
|
|
415
363
|
* bar under the table says why.
|
|
416
364
|
*/
|
|
417
365
|
function saveChanges() {
|
|
366
|
+
if (pendingCount === 0) return;
|
|
367
|
+
setAttempted(true);
|
|
418
368
|
if (!ready) return;
|
|
419
|
-
|
|
369
|
+
// Every key the save writes counts, a key pair's public key included.
|
|
370
|
+
const keys = madeSensitive(active, drafts, changes);
|
|
371
|
+
if (keys.length === 0) sendChanges();
|
|
372
|
+
else setHiding(keys);
|
|
420
373
|
}
|
|
421
374
|
|
|
422
375
|
function sendChanges() {
|
|
@@ -425,6 +378,7 @@ function EnvironmentLedger({
|
|
|
425
378
|
setChanges({});
|
|
426
379
|
setEditing(new Set());
|
|
427
380
|
setSaveError(null);
|
|
381
|
+
setAttempted(false);
|
|
428
382
|
save(batch, {
|
|
429
383
|
onError: (error) => {
|
|
430
384
|
forgetRefusal(batch);
|
|
@@ -495,33 +449,26 @@ function EnvironmentLedger({
|
|
|
495
449
|
return () => document.removeEventListener('keydown', onKeyDown);
|
|
496
450
|
}, [pendingCount]);
|
|
497
451
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
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
|
-
];
|
|
452
|
+
// What the pending edits do, counted: a new secret, or a new version of one by its name, a change to one, its archiving.
|
|
453
|
+
const tally = { added: 0, updated: 0, archived: 0 };
|
|
454
|
+
for (const draft of drafts) tally[existing.has(draft.key.trim()) ? 'updated' : 'added']++;
|
|
455
|
+
for (const entry of changedEntries) tally[secretChangeFor(changes, entry.key)!.archived ? 'archived' : 'updated']++;
|
|
456
|
+
|
|
457
|
+
// Filtering narrows what is listed, never what is saved: a pending edit on
|
|
458
|
+
// a row the filter hides still counts, and still shows in the bar under the table.
|
|
459
|
+
const needle = query.trim().toLowerCase();
|
|
460
|
+
const listed = sortKeys(
|
|
461
|
+
needle === '' ? active : active.filter((entry) => entry.key.toLowerCase().includes(needle)),
|
|
462
|
+
sort,
|
|
463
|
+
);
|
|
464
|
+
const columns = 6;
|
|
520
465
|
|
|
521
466
|
// Two rows that are both still blank "conflict" too, so say nothing until
|
|
522
|
-
// every name is filled in; the blank row speaks for itself
|
|
467
|
+
// every name is filled in; the blank row speaks for itself, once Save is
|
|
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));
|
|
523
470
|
const problem = unnamed
|
|
524
|
-
? null
|
|
471
|
+
? (attempted && unnamedHidden ? 'A secret the filter hides needs a name.' : null)
|
|
525
472
|
: hasConflict
|
|
526
473
|
? 'Two pending edits would end up with the same name. Secret names are unique in an environment.'
|
|
527
474
|
: invalid
|
|
@@ -530,29 +477,23 @@ function EnvironmentLedger({
|
|
|
530
477
|
? `${waiting.key} waits for its value: type it again.`
|
|
531
478
|
: null;
|
|
532
479
|
|
|
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
|
-
|
|
542
480
|
return (
|
|
543
481
|
<>
|
|
544
482
|
<PageHeader
|
|
545
483
|
tile={project}
|
|
546
484
|
title={environment}
|
|
547
|
-
aside={inProject !== undefined && <Protection
|
|
548
|
-
actions={
|
|
549
|
-
<
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
485
|
+
aside={inProject !== undefined && <Protection environment={inProject} />}
|
|
486
|
+
actions={
|
|
487
|
+
<EnvironmentMenu
|
|
488
|
+
project={project}
|
|
489
|
+
environment={environment}
|
|
490
|
+
inProject={inProject}
|
|
491
|
+
ownConfig={principal?.type === 'user' && canList && !personal}
|
|
492
|
+
busy={protecting.state === 'pending'}
|
|
493
|
+
follow
|
|
494
|
+
className="btn btn-sm btn-icon"
|
|
495
|
+
/>
|
|
496
|
+
}
|
|
556
497
|
meta={protecting.state === 'pending' ? (
|
|
557
498
|
<RowPending status={protecting} />
|
|
558
499
|
) : protecting.state === 'failed' ? (
|
|
@@ -711,11 +652,8 @@ function EnvironmentLedger({
|
|
|
711
652
|
onEdit={() => setEditing((current) => new Set(current).add(entry.key))}
|
|
712
653
|
onPatch={(patch) => patchChange(entry, patch)}
|
|
713
654
|
onUndo={() => dropChange(entry.key)}
|
|
714
|
-
onSave={() => saveRow(entry.key)}
|
|
715
655
|
versionOf={versionOf}
|
|
716
|
-
|
|
717
|
-
change === undefined || readyAlone([], { [entry.key]: change })
|
|
718
|
-
}
|
|
656
|
+
attempted={attempted}
|
|
719
657
|
onMarkArchive={() => {
|
|
720
658
|
setEditing((current) => {
|
|
721
659
|
const next = new Set(current);
|
|
@@ -753,19 +691,18 @@ function EnvironmentLedger({
|
|
|
753
691
|
)
|
|
754
692
|
}
|
|
755
693
|
onRemove={() => setDrafts((rows) => rows.filter((row) => row.id !== draft.id))}
|
|
756
|
-
onSave={() => saveDraft(draft)}
|
|
757
694
|
versionOf={versionOf}
|
|
758
|
-
|
|
695
|
+
attempted={attempted}
|
|
759
696
|
/>
|
|
760
697
|
))}
|
|
761
698
|
</tbody>
|
|
762
699
|
</table>
|
|
763
700
|
</div>
|
|
764
701
|
)}
|
|
765
|
-
{pendingCount > 0 && (
|
|
702
|
+
{(pendingCount > 0 || editing.size > 0) && (
|
|
766
703
|
<PendingBar
|
|
767
|
-
|
|
768
|
-
|
|
704
|
+
tally={tally}
|
|
705
|
+
canSave={pendingCount > 0}
|
|
769
706
|
error={saveError ?? problem}
|
|
770
707
|
onDiscard={discardAll}
|
|
771
708
|
onSave={saveChanges}
|
|
@@ -776,14 +713,13 @@ function EnvironmentLedger({
|
|
|
776
713
|
<ConfirmDialog
|
|
777
714
|
open={hiding !== null}
|
|
778
715
|
onOpenChange={(open) => !open && setHiding(null)}
|
|
779
|
-
title={hiding?.
|
|
780
|
-
body={`${hiding !== null && hiding.
|
|
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'}.`}
|
|
781
718
|
confirmLabel="Make sensitive"
|
|
782
719
|
destructive={false}
|
|
783
720
|
onConfirm={() => {
|
|
784
|
-
const go = hiding?.go;
|
|
785
721
|
setHiding(null);
|
|
786
|
-
|
|
722
|
+
sendChanges();
|
|
787
723
|
}}
|
|
788
724
|
/>
|
|
789
725
|
|
|
@@ -867,39 +803,34 @@ function EnvironmentLedger({
|
|
|
867
803
|
}
|
|
868
804
|
|
|
869
805
|
/**
|
|
870
|
-
* The pending edits, at the foot of the table they are made in:
|
|
871
|
-
*
|
|
872
|
-
* table
|
|
806
|
+
* The pending edits, at the foot of the table they are made in: how many
|
|
807
|
+
* secrets they add, update and archive, Discard and Save, which go for the
|
|
808
|
+
* whole table at once. It shows while any row is open for editing, so an
|
|
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.
|
|
873
812
|
*/
|
|
874
813
|
function PendingBar({
|
|
875
|
-
|
|
876
|
-
|
|
814
|
+
tally,
|
|
815
|
+
canSave,
|
|
877
816
|
error,
|
|
878
817
|
onDiscard,
|
|
879
818
|
onSave,
|
|
880
819
|
}: {
|
|
881
|
-
|
|
882
|
-
|
|
820
|
+
tally: { added: number; updated: number; archived: number };
|
|
821
|
+
/** Whether there is anything to save: a row opened and left as it was is not. */
|
|
822
|
+
canSave: boolean;
|
|
883
823
|
/** Why the last save failed, or why this one cannot go yet. */
|
|
884
824
|
error: string | null;
|
|
885
825
|
onDiscard: () => void;
|
|
886
826
|
onSave: () => void;
|
|
887
827
|
}) {
|
|
888
|
-
const
|
|
828
|
+
const parts = (['added', 'updated', 'archived'] as const).filter((what) => tally[what] > 0).map((what) => `${tally[what]} ${what}`);
|
|
889
829
|
return (
|
|
890
830
|
<div className="pending-bar" role="region" aria-label="Unsaved changes">
|
|
891
831
|
<span className="pending-count">
|
|
892
832
|
<span className="dot" aria-hidden />
|
|
893
|
-
{
|
|
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`}
|
|
833
|
+
{parts.length === 0 ? 'No changes yet' : parts.join(', ')}
|
|
903
834
|
</span>
|
|
904
835
|
<div className="pending-actions">
|
|
905
836
|
<button className="btn btn-sm" onClick={onDiscard}>
|
|
@@ -908,11 +839,11 @@ function PendingBar({
|
|
|
908
839
|
<button
|
|
909
840
|
className="btn btn-sm btn-primary"
|
|
910
841
|
onClick={onSave}
|
|
911
|
-
disabled={!
|
|
842
|
+
disabled={!canSave}
|
|
912
843
|
title="Save (⌘ Enter or Ctrl Enter)"
|
|
913
844
|
aria-keyshortcuts="Meta+Enter Control+Enter"
|
|
914
845
|
>
|
|
915
|
-
Save
|
|
846
|
+
Save
|
|
916
847
|
</button>
|
|
917
848
|
</div>
|
|
918
849
|
{error !== null && (
|
|
@@ -1062,7 +993,8 @@ function ValueField({
|
|
|
1062
993
|
autoFocus,
|
|
1063
994
|
onEscape,
|
|
1064
995
|
generate,
|
|
1065
|
-
|
|
996
|
+
level,
|
|
997
|
+
showable,
|
|
1066
998
|
}: {
|
|
1067
999
|
label: string;
|
|
1068
1000
|
value: string;
|
|
@@ -1081,11 +1013,17 @@ function ValueField({
|
|
|
1081
1013
|
companion: Companion | undefined;
|
|
1082
1014
|
onUse: (use: GeneratedUse) => void;
|
|
1083
1015
|
};
|
|
1084
|
-
/**
|
|
1085
|
-
|
|
1016
|
+
/**
|
|
1017
|
+
* Who sees the value once saved, chosen in the field, and the key it is
|
|
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;
|
|
1086
1023
|
}) {
|
|
1087
1024
|
const [shown, setShown] = useState(false);
|
|
1088
1025
|
const [generating, setGenerating] = useState(false);
|
|
1026
|
+
const plain = level.value === 'plain';
|
|
1089
1027
|
// A value with a line break is edited in a textarea, and stays in one to
|
|
1090
1028
|
// the end of the edit: taking its last line break out moves no focus.
|
|
1091
1029
|
const [lines, setLines] = useState(() => start.includes('\n') || value.includes('\n'));
|
|
@@ -1113,8 +1051,9 @@ function ValueField({
|
|
|
1113
1051
|
if (event.key === 'Escape' && onEscape !== undefined) onEscape();
|
|
1114
1052
|
},
|
|
1115
1053
|
};
|
|
1054
|
+
// One field to the eye, its controls inside its right end: who sees the value, Generate, and Show.
|
|
1116
1055
|
return (
|
|
1117
|
-
<div className="
|
|
1056
|
+
<div className="value-field">
|
|
1118
1057
|
{/* A value with line breaks opens one line tall, as tall as the row it
|
|
1119
1058
|
replaces, and grows only by the lines typed or pasted into it. */}
|
|
1120
1059
|
{lines ? (
|
|
@@ -1153,29 +1092,38 @@ function ValueField({
|
|
|
1153
1092
|
}}
|
|
1154
1093
|
/>
|
|
1155
1094
|
)}
|
|
1156
|
-
<
|
|
1157
|
-
<
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1095
|
+
<div className="value-field-controls">
|
|
1096
|
+
<SensitivityMenu
|
|
1097
|
+
name={level.name}
|
|
1098
|
+
value={level.value}
|
|
1099
|
+
levels={level.levels}
|
|
1161
1100
|
disabled={disabled}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1101
|
+
onChange={level.onChange}
|
|
1102
|
+
/>
|
|
1103
|
+
<Tip label="Generate a value">
|
|
1104
|
+
<button
|
|
1105
|
+
type="button"
|
|
1106
|
+
className="btn btn-quiet btn-sm btn-icon"
|
|
1107
|
+
aria-label={`Generate a value for ${generate.name.trim() === '' ? 'the new secret' : generate.name.trim()}`}
|
|
1108
|
+
disabled={disabled}
|
|
1109
|
+
onClick={() => setGenerating(true)}
|
|
1110
|
+
>
|
|
1111
|
+
<Generate size={14} />
|
|
1112
|
+
</button>
|
|
1113
|
+
</Tip>
|
|
1114
|
+
{/* A plain value shows as it is: nothing to mask. */}
|
|
1115
|
+
{showable && !plain && (
|
|
1116
|
+
<button
|
|
1117
|
+
type="button"
|
|
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>
|
|
1179
1127
|
<GenerateValue
|
|
1180
1128
|
open={generating}
|
|
1181
1129
|
onOpenChange={setGenerating}
|
|
@@ -1248,9 +1196,8 @@ function SecretRow({
|
|
|
1248
1196
|
onEdit,
|
|
1249
1197
|
onPatch,
|
|
1250
1198
|
onUndo,
|
|
1251
|
-
onSave,
|
|
1252
1199
|
versionOf,
|
|
1253
|
-
|
|
1200
|
+
attempted,
|
|
1254
1201
|
onMarkArchive,
|
|
1255
1202
|
personal,
|
|
1256
1203
|
}: {
|
|
@@ -1291,12 +1238,12 @@ function SecretRow({
|
|
|
1291
1238
|
onFork: (action: ForkAction) => void;
|
|
1292
1239
|
onEdit: () => void;
|
|
1293
1240
|
onPatch: (patch: Partial<SecretChange>) => void;
|
|
1241
|
+
/** Its edit given up, or its mark to archive taken off. */
|
|
1294
1242
|
onUndo: () => void;
|
|
1295
|
-
/** This row's change alone, saved now. */
|
|
1296
|
-
onSave: () => void;
|
|
1297
1243
|
/** The current version of a key in this environment, for a companion's note. */
|
|
1298
1244
|
versionOf: (key: string) => number | null;
|
|
1299
|
-
|
|
1245
|
+
/** Whether a save was asked for: a blank name says so only then. */
|
|
1246
|
+
attempted: boolean;
|
|
1300
1247
|
onMarkArchive: () => void;
|
|
1301
1248
|
/** In your personal config, `dev@me`, whose overrides are your own values. */
|
|
1302
1249
|
personal: boolean;
|
|
@@ -1478,7 +1425,7 @@ function SecretRow({
|
|
|
1478
1425
|
const renamed = change.key !== entry.key;
|
|
1479
1426
|
// A new value, or a level alone, a mark: either makes a new version.
|
|
1480
1427
|
const valueChanged = change.value !== null || change.sensitivity !== undefined;
|
|
1481
|
-
const keyProblem = editing ?
|
|
1428
|
+
const keyProblem = editing ? nameProblem(change.key.trim(), attempted) : null;
|
|
1482
1429
|
const state = leaving
|
|
1483
1430
|
? ' is-leaving'
|
|
1484
1431
|
: editing && (renamed || valueChanged)
|
|
@@ -1494,7 +1441,7 @@ function SecretRow({
|
|
|
1494
1441
|
|
|
1495
1442
|
return (
|
|
1496
1443
|
<>
|
|
1497
|
-
<tr className={`secret-row${state} ${rowClass(status)}`}>
|
|
1444
|
+
<tr className={`secret-row${state}${editing ? ' is-editing' : ''} ${rowClass(status)}`}>
|
|
1498
1445
|
<td className="n">{number}</td>
|
|
1499
1446
|
<td className="cell-key" data-label="Key">
|
|
1500
1447
|
{/* An inherited key has no row here to rename: overriding it keeps its name. */}
|
|
@@ -1552,8 +1499,8 @@ function SecretRow({
|
|
|
1552
1499
|
</td>
|
|
1553
1500
|
|
|
1554
1501
|
<td data-label="Value">
|
|
1555
|
-
{/* What acts on the value sits beside it: reading, Copy, Reveal and Edit
|
|
1556
|
-
|
|
1502
|
+
{/* What acts on the value sits beside it: reading, Copy, Reveal and Edit.
|
|
1503
|
+
An edit, or a mark to archive, is saved or discarded with the whole table, from the bar under it. */}
|
|
1557
1504
|
<div className="value-cell">
|
|
1558
1505
|
<div className="value-content">
|
|
1559
1506
|
{editing && canWrite ? (
|
|
@@ -1570,7 +1517,6 @@ function SecretRow({
|
|
|
1570
1517
|
: error !== null ? 'New value; the current one could not be read'
|
|
1571
1518
|
: canRead ? 'New value' : 'New value; the current one is hidden from you'
|
|
1572
1519
|
}
|
|
1573
|
-
plain={level === 'plain'}
|
|
1574
1520
|
disabled={disabled}
|
|
1575
1521
|
autoFocus={!focusName}
|
|
1576
1522
|
// A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
|
|
@@ -1586,17 +1532,17 @@ function SecretRow({
|
|
|
1586
1532
|
// A generated value is never plain.
|
|
1587
1533
|
onUse: ({ value, companion, recipe }) => onPatch({ value, companion, recipe, sensitivity: level === 'plain' ? 'secret' : level }),
|
|
1588
1534
|
}}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1535
|
+
level={{
|
|
1536
|
+
name: change.key.trim() === '' ? entry.key : change.key.trim(),
|
|
1537
|
+
value: level,
|
|
1538
|
+
levels: levelsIn(personal),
|
|
1539
|
+
// A value made plain is typed by hand: it drops the recipe of one generated.
|
|
1540
|
+
onChange: (next) => onPatch({
|
|
1541
|
+
...valueEdit(from(), { value: change.value, sensitivity: next }),
|
|
1542
|
+
...(next === 'plain' ? { companion: undefined, recipe: undefined } : {}),
|
|
1543
|
+
}),
|
|
1544
|
+
}}
|
|
1545
|
+
showable
|
|
1600
1546
|
/>
|
|
1601
1547
|
{waitsForValue(entry, change) && (
|
|
1602
1548
|
<span className="edit-note">
|
|
@@ -1636,32 +1582,9 @@ function SecretRow({
|
|
|
1636
1582
|
</span>
|
|
1637
1583
|
)}
|
|
1638
1584
|
</div>
|
|
1639
|
-
{status.state !== 'pending' && (
|
|
1585
|
+
{status.state !== 'pending' && !editing && !leaving && (
|
|
1640
1586
|
<div className="acts value-acts">
|
|
1641
|
-
{
|
|
1642
|
-
<>
|
|
1643
|
-
<Tip label={leaving ? 'Archive now' : 'Save'}>
|
|
1644
|
-
<button
|
|
1645
|
-
className="act act-icon act-accent"
|
|
1646
|
-
onClick={onSave}
|
|
1647
|
-
disabled={disabled || !saveReady}
|
|
1648
|
-
aria-label={`${leaving ? 'Archive' : 'Save'} ${entry.key} now`}
|
|
1649
|
-
>
|
|
1650
|
-
<Check size={15} />
|
|
1651
|
-
</button>
|
|
1652
|
-
</Tip>
|
|
1653
|
-
<Tip label={leaving ? 'Keep' : 'Cancel'}>
|
|
1654
|
-
<button
|
|
1655
|
-
className="act act-icon act-quiet"
|
|
1656
|
-
onClick={onUndo}
|
|
1657
|
-
disabled={disabled}
|
|
1658
|
-
aria-label={leaving ? `Keep ${entry.key}` : `Cancel editing ${entry.key}`}
|
|
1659
|
-
>
|
|
1660
|
-
<X size={15} />
|
|
1661
|
-
</button>
|
|
1662
|
-
</Tip>
|
|
1663
|
-
</>
|
|
1664
|
-
) : removed ? (
|
|
1587
|
+
{removed ? (
|
|
1665
1588
|
canWrite && (
|
|
1666
1589
|
<button type="button" className="btn btn-sm" onClick={() => onFork('restore')} disabled={disabled}>
|
|
1667
1590
|
Restore
|
|
@@ -1739,7 +1662,7 @@ function SecretRow({
|
|
|
1739
1662
|
{status.state === 'pending' ? (
|
|
1740
1663
|
<RowPending status={status} />
|
|
1741
1664
|
) : (
|
|
1742
|
-
!removed && (canList || (canWrite && !editing && !leaving) || (canArchive && !leaving && own && !overridden)) && (
|
|
1665
|
+
!removed && (canList || leaving || (canWrite && !editing && !leaving) || (canArchive && !leaving && own && !overridden)) && (
|
|
1743
1666
|
<Menu.Root>
|
|
1744
1667
|
<Menu.Trigger
|
|
1745
1668
|
className="act act-icon act-quiet"
|
|
@@ -1817,22 +1740,15 @@ function SecretRow({
|
|
|
1817
1740
|
{canWrite && !editing && !leaving && markable(entry) && (
|
|
1818
1741
|
<>
|
|
1819
1742
|
<Menu.Separator className="menu-sep" />
|
|
1820
|
-
<
|
|
1821
|
-
<Menu.GroupLabel className="menu-label">Who sees it</Menu.GroupLabel>
|
|
1822
|
-
{SENSITIVITIES.map((each) => (
|
|
1823
|
-
<Menu.RadioItem key={each} value={each} className="menu-item menu-item-level" closeOnClick>
|
|
1824
|
-
<span className="menu-item-text">
|
|
1825
|
-
{levelsIn(personal)[each].label}
|
|
1826
|
-
<span className="menu-item-hint">{levelsIn(personal)[each].hint}</span>
|
|
1827
|
-
</span>
|
|
1828
|
-
<Menu.RadioItemIndicator className="menu-check">
|
|
1829
|
-
<Check size={14} />
|
|
1830
|
-
</Menu.RadioItemIndicator>
|
|
1831
|
-
</Menu.RadioItem>
|
|
1832
|
-
))}
|
|
1833
|
-
</Menu.RadioGroup>
|
|
1743
|
+
<SensitivityItems value={entry.sensitivity} levels={levelsIn(personal)} onChange={chooseLevel} />
|
|
1834
1744
|
</>
|
|
1835
1745
|
)}
|
|
1746
|
+
{leaving && (
|
|
1747
|
+
<Menu.Item className="menu-item" onClick={onUndo}>
|
|
1748
|
+
<RotateBack size={14} />
|
|
1749
|
+
Don't archive
|
|
1750
|
+
</Menu.Item>
|
|
1751
|
+
)}
|
|
1836
1752
|
{/* An override's way out is Reset, which keeps it; archiving there would be the same, by more. */}
|
|
1837
1753
|
{canArchive && !leaving && own && !overridden && (
|
|
1838
1754
|
<>
|
|
@@ -2005,38 +1921,6 @@ function SecretRow({
|
|
|
2005
1921
|
);
|
|
2006
1922
|
}
|
|
2007
1923
|
|
|
2008
|
-
/** Delete your personal config, from its page: its values erased; dev itself untouched. */
|
|
2009
|
-
function DeletePersonal({ project, environment, of }: { project: string; environment: string; of: string }) {
|
|
2010
|
-
const coffre = useCoffre();
|
|
2011
|
-
const navigate = useNavigate();
|
|
2012
|
-
const [open, setOpen] = useState(false);
|
|
2013
|
-
const { error, run } = useAction();
|
|
2014
|
-
return (
|
|
2015
|
-
<>
|
|
2016
|
-
<button type="button" className="btn btn-sm" onClick={() => setOpen(true)}>
|
|
2017
|
-
<Trash size={14} />
|
|
2018
|
-
Delete…
|
|
2019
|
-
</button>
|
|
2020
|
-
{error !== null && <ErrorLine error={error} />}
|
|
2021
|
-
<ConfirmDialog
|
|
2022
|
-
open={open}
|
|
2023
|
-
onOpenChange={setOpen}
|
|
2024
|
-
title={<>Delete your own <span className="mono">{of}</span>?</>}
|
|
2025
|
-
body={`The values you set in ${project}/${environment} are erased for good. ${project}/${of} is untouched, and ${environment} reads it again.`}
|
|
2026
|
-
confirmLabel="Delete"
|
|
2027
|
-
onConfirm={() =>
|
|
2028
|
-
void run(() => coffre.environments.delete(`${project}/${environment}`), {
|
|
2029
|
-
affects: [...affects.secrets({ project, environment }), ...affects.places()],
|
|
2030
|
-
onSuccess: () => {
|
|
2031
|
-
toast.success(`Your own ${of} is deleted`);
|
|
2032
|
-
void navigate({ to: '/projects/$project/$environment', params: { project, environment: of } });
|
|
2033
|
-
},
|
|
2034
|
-
})}
|
|
2035
|
-
/>
|
|
2036
|
-
</>
|
|
2037
|
-
);
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
1924
|
/**
|
|
2041
1925
|
* `dev@me` while you have no personal dev: what one is, and Make, which
|
|
2042
1926
|
* makes it empty; your first write would make it too. A read of
|
|
@@ -2191,18 +2075,17 @@ function Written({ entry, rotateAfterDays }: { entry: SecretKey; rotateAfterDays
|
|
|
2191
2075
|
}
|
|
2192
2076
|
|
|
2193
2077
|
/**
|
|
2194
|
-
* Who sees the value being written,
|
|
2195
|
-
*
|
|
2196
|
-
* keys move the choice, and a screen reader hears one group of three.
|
|
2078
|
+
* Who sees the value being written, as a menu inside its field: the
|
|
2079
|
+
* trigger names the level chosen, and each choice says what it means.
|
|
2197
2080
|
*/
|
|
2198
|
-
function
|
|
2081
|
+
function SensitivityMenu({
|
|
2199
2082
|
name,
|
|
2200
2083
|
value,
|
|
2201
2084
|
levels,
|
|
2202
2085
|
disabled,
|
|
2203
2086
|
onChange,
|
|
2204
2087
|
}: {
|
|
2205
|
-
/** The key it is for, naming the
|
|
2088
|
+
/** The key it is for, naming the control. */
|
|
2206
2089
|
name: string;
|
|
2207
2090
|
value: Sensitivity;
|
|
2208
2091
|
/** Each level as it is named here (`levelsIn`). */
|
|
@@ -2210,28 +2093,45 @@ function SensitivityField({
|
|
|
2210
2093
|
disabled: boolean;
|
|
2211
2094
|
onChange: (level: Sensitivity) => void;
|
|
2212
2095
|
}) {
|
|
2213
|
-
const id = useId();
|
|
2214
|
-
const [pointed, setPointed] = useState<Sensitivity | null>(null);
|
|
2215
2096
|
return (
|
|
2216
|
-
<
|
|
2217
|
-
<
|
|
2218
|
-
{
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2097
|
+
<Menu.Root>
|
|
2098
|
+
<Menu.Trigger className="value-level" aria-label={`Who sees ${name}: ${levels[value].label}`} disabled={disabled}>
|
|
2099
|
+
{value === 'sensitive' && <Lock size={11} aria-hidden />}
|
|
2100
|
+
{levels[value].label}
|
|
2101
|
+
<ChevronDown size={12} aria-hidden />
|
|
2102
|
+
</Menu.Trigger>
|
|
2103
|
+
<MenuPopup align="end">
|
|
2104
|
+
<SensitivityItems value={value} levels={levels} onChange={onChange} />
|
|
2105
|
+
</MenuPopup>
|
|
2106
|
+
</Menu.Root>
|
|
2107
|
+
);
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
/** The levels as a menu's radio group, loosest first, each with what it means. */
|
|
2111
|
+
function SensitivityItems({
|
|
2112
|
+
value,
|
|
2113
|
+
levels,
|
|
2114
|
+
onChange,
|
|
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>
|
|
2235
2135
|
);
|
|
2236
2136
|
}
|
|
2237
2137
|
|
|
@@ -2240,7 +2140,8 @@ function SensitivityField({
|
|
|
2240
2140
|
*
|
|
2241
2141
|
* This replaced a separate "Add a secret" form. The form made you look away
|
|
2242
2142
|
* from the list to add to it, and only ever accepted one key at a time; a row
|
|
2243
|
-
* in place accepts as many as you want to queue
|
|
2143
|
+
* in place accepts as many as you want to queue, saved together from the
|
|
2144
|
+
* bar under the table.
|
|
2244
2145
|
*/
|
|
2245
2146
|
function DraftRow({
|
|
2246
2147
|
draft,
|
|
@@ -2248,9 +2149,8 @@ function DraftRow({
|
|
|
2248
2149
|
disabled,
|
|
2249
2150
|
onChange,
|
|
2250
2151
|
onRemove,
|
|
2251
|
-
onSave,
|
|
2252
2152
|
versionOf,
|
|
2253
|
-
|
|
2153
|
+
attempted,
|
|
2254
2154
|
personal,
|
|
2255
2155
|
}: {
|
|
2256
2156
|
draft: SecretDraft;
|
|
@@ -2258,21 +2158,19 @@ function DraftRow({
|
|
|
2258
2158
|
disabled: boolean;
|
|
2259
2159
|
onChange: (patch: Partial<SecretDraft>) => void;
|
|
2260
2160
|
onRemove: () => void;
|
|
2261
|
-
/** This new secret alone, saved now. */
|
|
2262
|
-
onSave: () => void;
|
|
2263
2161
|
/** The current version of a key in this environment, for a companion's note. */
|
|
2264
2162
|
versionOf: (key: string) => number | null;
|
|
2265
|
-
|
|
2163
|
+
/** Whether a save was asked for: a blank name says so only then. */
|
|
2164
|
+
attempted: boolean;
|
|
2266
2165
|
/** In your personal config, `dev@me`, whose values are your own. */
|
|
2267
2166
|
personal: boolean;
|
|
2268
2167
|
}) {
|
|
2269
|
-
const [touched, setTouched] = useState(false);
|
|
2270
2168
|
const trimmed = draft.key.trim();
|
|
2271
|
-
const keyProblem = trimmed
|
|
2169
|
+
const keyProblem = nameProblem(trimmed, attempted);
|
|
2272
2170
|
const isNewVersion = trimmed !== '' && existingVersion !== null;
|
|
2273
2171
|
|
|
2274
2172
|
return (
|
|
2275
|
-
<tr className="secret-row is-draft">
|
|
2173
|
+
<tr className="secret-row is-draft is-editing">
|
|
2276
2174
|
<td className="n" aria-label="New">
|
|
2277
2175
|
+
|
|
2278
2176
|
</td>
|
|
@@ -2290,7 +2188,6 @@ function DraftRow({
|
|
|
2290
2188
|
autoComplete="off"
|
|
2291
2189
|
value={draft.key}
|
|
2292
2190
|
disabled={disabled}
|
|
2293
|
-
onBlur={() => setTouched(true)}
|
|
2294
2191
|
onChange={(event) => onChange({ key: event.target.value })}
|
|
2295
2192
|
onKeyDown={(event) => {
|
|
2296
2193
|
if (event.key === 'Escape') onRemove();
|
|
@@ -2298,67 +2195,39 @@ function DraftRow({
|
|
|
2298
2195
|
/>
|
|
2299
2196
|
{(keyProblem !== null || isNewVersion) && (
|
|
2300
2197
|
<span className={`edit-note${keyProblem !== null ? ' edit-note-error' : ''}`}>
|
|
2301
|
-
{keyProblem ??
|
|
2302
|
-
'This name exists here already. Saving adds a new version to it.'}
|
|
2198
|
+
{keyProblem ?? 'Exists here already: saving adds a version.'}
|
|
2303
2199
|
</span>
|
|
2304
2200
|
)}
|
|
2305
2201
|
</div>
|
|
2306
2202
|
</td>
|
|
2307
2203
|
<td data-label="Value">
|
|
2308
|
-
<div className="
|
|
2309
|
-
<
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
onChange={(sensitivity) => onChange(sensitivity === 'plain' ? { sensitivity, companion: undefined, recipe: undefined } : { sensitivity })}
|
|
2336
|
-
/>
|
|
2337
|
-
<CompanionNote companion={draft.companion} versionOf={versionOf} />
|
|
2338
|
-
</div>
|
|
2339
|
-
</div>
|
|
2340
|
-
<div className="acts value-acts">
|
|
2341
|
-
<Tip label="Save">
|
|
2342
|
-
<button
|
|
2343
|
-
className="act act-icon act-accent"
|
|
2344
|
-
onClick={onSave}
|
|
2345
|
-
disabled={disabled || !saveReady}
|
|
2346
|
-
aria-label={trimmed === '' ? 'Save this new secret now' : `Save ${trimmed} now`}
|
|
2347
|
-
>
|
|
2348
|
-
<Check size={15} />
|
|
2349
|
-
</button>
|
|
2350
|
-
</Tip>
|
|
2351
|
-
<Tip label="Cancel">
|
|
2352
|
-
<button
|
|
2353
|
-
className="act act-icon act-quiet"
|
|
2354
|
-
onClick={onRemove}
|
|
2355
|
-
disabled={disabled}
|
|
2356
|
-
aria-label={trimmed === '' ? 'Remove this new secret' : `Remove new secret ${trimmed}`}
|
|
2357
|
-
>
|
|
2358
|
-
<X size={15} />
|
|
2359
|
-
</button>
|
|
2360
|
-
</Tip>
|
|
2361
|
-
</div>
|
|
2204
|
+
<div className="edit-stack">
|
|
2205
|
+
<ValueField
|
|
2206
|
+
label={`Value for ${trimmed === '' ? 'the new secret' : trimmed}`}
|
|
2207
|
+
value={draft.value}
|
|
2208
|
+
placeholder="Value"
|
|
2209
|
+
disabled={disabled}
|
|
2210
|
+
// A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
|
|
2211
|
+
onChange={(value) => onChange({ value, companion: undefined, recipe: undefined })}
|
|
2212
|
+
onEscape={onRemove}
|
|
2213
|
+
generate={{
|
|
2214
|
+
name: draft.key,
|
|
2215
|
+
renamable: true,
|
|
2216
|
+
companion: draft.companion,
|
|
2217
|
+
// A generated value is never plain.
|
|
2218
|
+
onUse: ({ value, name, companion, recipe }) =>
|
|
2219
|
+
onChange({ key: name, value, companion, recipe, sensitivity: draft.sensitivity === 'plain' ? 'secret' : draft.sensitivity }),
|
|
2220
|
+
}}
|
|
2221
|
+
level={{
|
|
2222
|
+
name: trimmed === '' ? 'the new secret' : trimmed,
|
|
2223
|
+
value: draft.sensitivity,
|
|
2224
|
+
levels: levelsIn(personal),
|
|
2225
|
+
// A value made plain is typed by hand: it drops the recipe of one generated.
|
|
2226
|
+
onChange: (sensitivity) => onChange(sensitivity === 'plain' ? { sensitivity, companion: undefined, recipe: undefined } : { sensitivity }),
|
|
2227
|
+
}}
|
|
2228
|
+
showable={false}
|
|
2229
|
+
/>
|
|
2230
|
+
<CompanionNote companion={draft.companion} versionOf={versionOf} />
|
|
2362
2231
|
</div>
|
|
2363
2232
|
</td>
|
|
2364
2233
|
<td className="col-version" data-label="Version">
|
|
@@ -2380,6 +2249,12 @@ function DraftRow({
|
|
|
2380
2249
|
);
|
|
2381
2250
|
}
|
|
2382
2251
|
|
|
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
|
+
|
|
2383
2258
|
function ArchivedRow({
|
|
2384
2259
|
number,
|
|
2385
2260
|
project,
|