@coffre/ui 0.6.2 → 0.7.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-BVv_9_nq.js → audit-sentence-C1_gRxWW.js} +90 -25
- package/dist/chunks/audit-sentence-C1_gRxWW.js.map +1 -0
- package/dist/chunks/{connected-apps-rBF9XUob.js → connected-apps-Bn5rEoV2.js} +2 -2
- package/dist/chunks/{connected-apps-rBF9XUob.js.map → connected-apps-Bn5rEoV2.js.map} +1 -1
- package/dist/chunks/{delete-place-CkGezx5R.js → delete-place-CQCDHkne.js} +3 -3
- package/dist/chunks/{delete-place-CkGezx5R.js.map → delete-place-CQCDHkne.js.map} +1 -1
- package/dist/chunks/{directory-SRN01yP6.js → directory-BQNOdze_.js} +6 -5
- package/dist/chunks/{directory-SRN01yP6.js.map → directory-BQNOdze_.js.map} +1 -1
- package/dist/chunks/{grants-1E1vqkM0.js → grants-CJIBrkod.js} +3 -3
- package/dist/chunks/{grants-1E1vqkM0.js.map → grants-CJIBrkod.js.map} +1 -1
- package/dist/chunks/{offboarding-Bt7KSixm.js → offboarding-CrgwaetA.js} +3 -3
- package/dist/chunks/offboarding-CrgwaetA.js.map +1 -0
- package/dist/chunks/personal-tokens-B8rkT-DI.js +138 -0
- package/dist/chunks/personal-tokens-B8rkT-DI.js.map +1 -0
- package/dist/chunks/{principal-page-Cbx2l6XL.js → principal-page-DDmmV1KQ.js} +25 -12
- package/dist/chunks/principal-page-DDmmV1KQ.js.map +1 -0
- package/dist/chunks/{project-page-DKo2AFYg.js → project-page-BI--vjt3.js} +2 -2
- package/dist/chunks/{project-page-DKo2AFYg.js.map → project-page-BI--vjt3.js.map} +1 -1
- package/dist/chunks/{queries-BvSw1xBN.js → queries-epz4MIuW.js} +19 -5
- package/dist/chunks/queries-epz4MIuW.js.map +1 -0
- package/dist/chunks/{references-DCoSPtvw.js → references-DImfw0cz.js} +3 -3
- package/dist/chunks/{references-DCoSPtvw.js.map → references-DImfw0cz.js.map} +1 -1
- package/dist/chunks/{role-field-D98CvNEg.js → role-field-C1KhNaIR.js} +2 -2
- package/dist/chunks/{role-field-D98CvNEg.js.map → role-field-C1KhNaIR.js.map} +1 -1
- package/dist/chunks/{use-action-Bv7yQ0DW.js → use-action-BB-RcHo1.js} +2 -2
- package/dist/chunks/{use-action-Bv7yQ0DW.js.map → use-action-BB-RcHo1.js.map} +1 -1
- package/dist/chunks/{use-change-DIQTGXER.js → use-change-CQyDpCqw.js} +268 -17
- package/dist/chunks/use-change-CQyDpCqw.js.map +1 -0
- package/dist/chunks/{use-shell-DhFoHjDS.js → use-shell-C_NmvCt_.js} +2 -2
- package/dist/chunks/{use-shell-DhFoHjDS.js.map → use-shell-C_NmvCt_.js.map} +1 -1
- package/dist/index.d.ts +33 -0
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/pages/account.d.ts +1 -1
- package/dist/pages/account.js +26 -9
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/audit.js +52 -32
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/environment.js +520 -192
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +1 -1
- package/dist/pages/project-access.js +8 -8
- package/dist/pages/project-access.js.map +1 -1
- package/dist/pages/project-environments.js +106 -19
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +6 -6
- package/dist/pages/project.js +1 -1
- package/dist/pages/projects.js +4 -4
- package/dist/pages/service-account.js +278 -29
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +4 -4
- package/dist/pages/settings.js +4 -4
- package/dist/pages/unregistered.js +1 -1
- package/dist/pages/user.js +5 -5
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/actions-log.tsx +2 -1
- package/src/components/directory.tsx +1 -0
- package/src/components/generate-value.tsx +15 -7
- package/src/components/offboarding.tsx +1 -1
- package/src/components/personal-tokens.tsx +131 -0
- package/src/components/principal-page.tsx +20 -3
- package/src/components/regenerate.tsx +72 -0
- package/src/components/service-tokens.tsx +3 -3
- package/src/components/trusted-workloads.tsx +177 -8
- package/src/lib/audit-sentences.ts +100 -12
- package/src/lib/bindings.ts +41 -3
- package/src/lib/changes.ts +155 -20
- package/src/lib/generate.ts +3 -146
- package/src/lib/queries.ts +15 -4
- package/src/lib/recipes.ts +63 -0
- package/src/lib/reveal.ts +7 -1
- package/src/lib/secret-edit-batch.ts +64 -5
- package/src/options.ts +5 -1
- package/src/pages/account.tsx +27 -5
- package/src/pages/audit.tsx +23 -7
- package/src/pages/environment.tsx +357 -39
- package/src/pages/project-access.tsx +1 -1
- package/src/pages/project-environments.tsx +85 -12
- package/src/parity.ts +18 -2
- package/src/styles/globals.css +56 -3
- package/dist/chunks/audit-sentence-BVv_9_nq.js.map +0 -1
- package/dist/chunks/offboarding-Bt7KSixm.js.map +0 -1
- package/dist/chunks/principal-page-Cbx2l6XL.js.map +0 -1
- package/dist/chunks/queries-BvSw1xBN.js.map +0 -1
- package/dist/chunks/use-change-DIQTGXER.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
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
|
+
import type { Generation } from '@coffre/core/recipe';
|
|
3
4
|
import { useEffect, useReducer, useRef, useState, type ReactNode } from 'react';
|
|
4
5
|
import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
|
|
5
|
-
import { Link } from '@tanstack/react-router';
|
|
6
|
+
import { Link, useNavigate } from '@tanstack/react-router';
|
|
6
7
|
import { useShell } from '../lib/use-shell';
|
|
7
8
|
import { Menu } from '@base-ui/react/menu';
|
|
8
9
|
import { toast } from 'sonner';
|
|
9
10
|
import { failureMessage, useCoffre } from '../lib/coffre';
|
|
10
|
-
import { archiveSecret, moveSecret, restoreSecret, saveSecrets, UnsavedEdits, type SaveSecretsVars } from '../lib/changes';
|
|
11
|
+
import { archiveSecret, forkKey, moveSecret, regenerateSecret, restoreSecret, saveSecrets, UnsavedEdits, type ForkAction, type SaveSecretsVars } from '../lib/changes';
|
|
11
12
|
import { changeKey, type ItemStatus } from '../lib/optimistic';
|
|
12
13
|
import { affects, keys as queryKeys, queries } from '../lib/queries';
|
|
13
14
|
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
@@ -52,6 +53,8 @@ import {
|
|
|
52
53
|
import { Card, ClosedDoor, PageHeader } from '../components/page';
|
|
53
54
|
import { SecretReadOnly } from '../components/affordances';
|
|
54
55
|
import { GenerateValue, type GeneratedUse } from '../components/generate-value';
|
|
56
|
+
import { RecipeMark, RegenerateSecret } from '../components/regenerate';
|
|
57
|
+
import { liveGeneration, regeneratedKeys, regenerateWaits } from '../lib/recipes';
|
|
55
58
|
import { MaskedInput, MaskedTextarea } from '../components/masked';
|
|
56
59
|
import { FolderMenu, FolderRow, MoveToFolder } from '../components/folders';
|
|
57
60
|
import { MissingKeys } from '../components/missing';
|
|
@@ -81,6 +84,7 @@ import {
|
|
|
81
84
|
Search,
|
|
82
85
|
SlashCircle,
|
|
83
86
|
Terminal,
|
|
87
|
+
Trash,
|
|
84
88
|
Upload,
|
|
85
89
|
X,
|
|
86
90
|
} from '../components/icons';
|
|
@@ -130,6 +134,9 @@ export function EnvironmentPage() {
|
|
|
130
134
|
);
|
|
131
135
|
}
|
|
132
136
|
|
|
137
|
+
// `dev@me` while you have none: what one is, and making it, rather than dev's own keys under your name.
|
|
138
|
+
if (result.personal?.fallback === true) return <NoPersonalConfig project={project} of={result.personal.of} />;
|
|
139
|
+
|
|
133
140
|
// Keyed by location: pending edits belong to the environment they were
|
|
134
141
|
// started in. The route component is reused across params, so without the
|
|
135
142
|
// key they would follow you into the next environment and be written there.
|
|
@@ -140,6 +147,8 @@ export function EnvironmentPage() {
|
|
|
140
147
|
environment={environment}
|
|
141
148
|
permissions={result.permissions}
|
|
142
149
|
keys={result.keys}
|
|
150
|
+
parents={result.parents ?? []}
|
|
151
|
+
personal={result.personal != null}
|
|
143
152
|
rotateAfterDays={result.rotateAfterDays}
|
|
144
153
|
/>
|
|
145
154
|
);
|
|
@@ -152,12 +161,18 @@ function EnvironmentLedger({
|
|
|
152
161
|
environment,
|
|
153
162
|
permissions,
|
|
154
163
|
keys,
|
|
164
|
+
parents,
|
|
165
|
+
personal,
|
|
155
166
|
rotateAfterDays,
|
|
156
167
|
}: {
|
|
157
168
|
project: string;
|
|
158
169
|
environment: string;
|
|
159
170
|
permissions: Permission[];
|
|
160
171
|
keys: SecretKey[];
|
|
172
|
+
/** The environments it inherits from, nearest first: a fork's (docs/design/forking.md). */
|
|
173
|
+
parents: string[];
|
|
174
|
+
/** Your personal config, `dev@me`: its values yours alone. */
|
|
175
|
+
personal: boolean;
|
|
161
176
|
/** Days a value may go unchanged before it is flagged for rotation; null for no flag. */
|
|
162
177
|
rotateAfterDays: number | null;
|
|
163
178
|
}) {
|
|
@@ -168,6 +183,14 @@ function EnvironmentLedger({
|
|
|
168
183
|
const restore = useChange(restoreSecret(coffre, { project, environment }));
|
|
169
184
|
const archive = useChange(archiveSecret(coffre, { project, environment }));
|
|
170
185
|
const move = useChange(moveSecret(coffre, { project, environment }));
|
|
186
|
+
const regenerate = useChange(regenerateSecret(coffre, { project, environment }, principal?.id ?? null));
|
|
187
|
+
// A fork's keys, against its parent's: each action shows at once, with its opposite as Undo.
|
|
188
|
+
const forkChanges = {
|
|
189
|
+
remove: useChange(forkKey(coffre, { project, environment }, 'remove')),
|
|
190
|
+
restore: useChange(forkKey(coffre, { project, environment }, 'restore')),
|
|
191
|
+
reset: useChange(forkKey(coffre, { project, environment }, 'reset')),
|
|
192
|
+
override: useChange(forkKey(coffre, { project, environment }, 'override')),
|
|
193
|
+
};
|
|
171
194
|
// The references that read this environment's secrets from elsewhere, and the environments you read.
|
|
172
195
|
const { data: references } = useQuery(queries.references(coffre, `${project}/${environment}`));
|
|
173
196
|
const lentBy = new Map<string, ListedReference[]>();
|
|
@@ -176,8 +199,9 @@ function EnvironmentLedger({
|
|
|
176
199
|
if (sourceProject !== project || sourceEnvironment !== environment) continue;
|
|
177
200
|
lentBy.set(key, [...(lentBy.get(key) ?? []), reference]);
|
|
178
201
|
}
|
|
202
|
+
// A personal config is no reference's source: its values are its owner's alone.
|
|
179
203
|
const readable = useShell().projects.flatMap((each) => each.environments
|
|
180
|
-
.filter(isActiveAccessibleEnvironment)
|
|
204
|
+
.filter((one) => isActiveAccessibleEnvironment(one) && !one.personal)
|
|
181
205
|
.map((one) => `${each.slug}/${one.slug}`));
|
|
182
206
|
const { status, dismiss } = useChangeStatus(queryKeys.secrets({ project, environment }));
|
|
183
207
|
const [drafts, setDrafts] = useState<SecretDraft[]>([]);
|
|
@@ -200,15 +224,17 @@ function EnvironmentLedger({
|
|
|
200
224
|
// Listed by folder: those in none first, then each folder by name.
|
|
201
225
|
const active = byFolder(keys.filter((entry) => !entry.archived)).flatMap(([, entries]) => entries);
|
|
202
226
|
const folders = foldersOf(active);
|
|
227
|
+
// In a fork, an inherited key is filed where its parent files it: only the keys held here are filed here.
|
|
228
|
+
const heldHere = (entry: SecretKey) => entry.parent === null || entry.parent.state === 'overridden';
|
|
203
229
|
// What can be filed now: not a secret whose save is on its way, which may
|
|
204
230
|
// not exist yet, nor one with an edit pending, as its menu offers no move
|
|
205
231
|
// while it is edited.
|
|
206
|
-
const settled = active.filter((entry) => status(entry.key).state !== 'pending' && secretChangeFor(changes, entry.key) === undefined);
|
|
232
|
+
const settled = active.filter((entry) => heldHere(entry) && status(entry.key).state !== 'pending' && secretChangeFor(changes, entry.key) === undefined);
|
|
207
233
|
// Renaming or removing a folder: everything in it at once, the keys staying where they are.
|
|
208
234
|
const refile = useAction();
|
|
209
235
|
const place = `${project}/${environment}`;
|
|
210
236
|
const folderMenu = (folder: string, count: number) =>
|
|
211
|
-
canWrite && (
|
|
237
|
+
canWrite && count > 0 && (
|
|
212
238
|
<FolderMenu
|
|
213
239
|
folder={folder}
|
|
214
240
|
count={count}
|
|
@@ -229,6 +255,13 @@ function EnvironmentLedger({
|
|
|
229
255
|
const archived = keys.filter((entry) => entry.archived);
|
|
230
256
|
const existing = new Set(keys.map((entry) => entry.key));
|
|
231
257
|
const versionOf = (key: string) => keys.find((entry) => entry.key === key.trim())?.version ?? null;
|
|
258
|
+
/** The listed version id of each key, those with one: what a regenerate replaces. */
|
|
259
|
+
const versionIdOf = (name: string) => active.find((entry) => entry.key === name)?.versionId ?? null;
|
|
260
|
+
const versionsOf = (names: readonly string[]) =>
|
|
261
|
+
Object.fromEntries(names.flatMap((name) => {
|
|
262
|
+
const version = versionIdOf(name);
|
|
263
|
+
return version === null ? [] : [[name, version] as const];
|
|
264
|
+
}));
|
|
232
265
|
|
|
233
266
|
const changedEntries = active.filter(
|
|
234
267
|
(entry) => secretChangeFor(changes, entry.key) !== undefined,
|
|
@@ -387,6 +420,31 @@ function EnvironmentLedger({
|
|
|
387
420
|
);
|
|
388
421
|
}
|
|
389
422
|
|
|
423
|
+
/**
|
|
424
|
+
* In a fork, a key against its parent's: removed, restored, reset to the
|
|
425
|
+
* parent's value or overriding it again. Each is undone by its opposite,
|
|
426
|
+
* so it gets an Undo rather than a confirmation dialog in front of it.
|
|
427
|
+
*/
|
|
428
|
+
function forkAction(entry: SecretKey, action: ForkAction) {
|
|
429
|
+
const from = entry.parent?.from ?? parents[0] ?? 'its parent';
|
|
430
|
+
const undo: Record<ForkAction, ForkAction> = { remove: 'restore', restore: 'remove', reset: 'override', override: 'reset' };
|
|
431
|
+
const said: Record<ForkAction, string> = {
|
|
432
|
+
remove: `${entry.key} removed: ${environment} does without ${from}'s`,
|
|
433
|
+
restore: `${entry.key} inherited from ${from} again`,
|
|
434
|
+
reset: `${entry.key} reads ${from}'s value again; its own is kept`,
|
|
435
|
+
override: `${entry.key} overrides ${from} again`,
|
|
436
|
+
};
|
|
437
|
+
forkChanges[action](
|
|
438
|
+
{ key: entry.key },
|
|
439
|
+
{
|
|
440
|
+
onSuccess: () =>
|
|
441
|
+
toast.success(said[action], {
|
|
442
|
+
action: { label: 'Undo', onClick: () => forkChanges[undo[action]]({ key: entry.key }) },
|
|
443
|
+
}),
|
|
444
|
+
},
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
|
|
390
448
|
// Cmd/Ctrl+Enter saves from anywhere on the page while edits are pending,
|
|
391
449
|
// but for an open dialog, such as Generate's.
|
|
392
450
|
const saveRef = useRef(saveChanges);
|
|
@@ -418,6 +476,8 @@ function EnvironmentLedger({
|
|
|
418
476
|
return { key: entry.key, what: withCompanion(`→ ${change.key.trim()}, new value`, change.companion) };
|
|
419
477
|
}
|
|
420
478
|
if (renamed) return { key: entry.key, what: `→ ${change.key.trim()}` };
|
|
479
|
+
// In a fork, a value written over the parent's overrides it.
|
|
480
|
+
if (entry.parent !== null && entry.parent.state !== 'overridden') return { key: entry.key, what: withCompanion(`overrides ${entry.parent.from}`, change.companion) };
|
|
421
481
|
return { key: entry.key, what: withCompanion('new value', change.companion) };
|
|
422
482
|
}),
|
|
423
483
|
];
|
|
@@ -443,7 +503,36 @@ function EnvironmentLedger({
|
|
|
443
503
|
|
|
444
504
|
return (
|
|
445
505
|
<>
|
|
446
|
-
<PageHeader
|
|
506
|
+
<PageHeader
|
|
507
|
+
tile={project}
|
|
508
|
+
title={environment}
|
|
509
|
+
actions={personal ? (
|
|
510
|
+
<DeletePersonal project={project} environment={environment} of={parents[0]!} />
|
|
511
|
+
) : principal?.type === 'user' && canReveal && (
|
|
512
|
+
<Link className="btn btn-sm" to="/projects/$project/$environment" params={{ project, environment: `${environment}@me` }}>
|
|
513
|
+
<Key size={14} />
|
|
514
|
+
My own {environment}
|
|
515
|
+
</Link>
|
|
516
|
+
)}
|
|
517
|
+
description={personal ? (
|
|
518
|
+
<span className="inherits">
|
|
519
|
+
Your own{' '}
|
|
520
|
+
<Link className="mono" to="/projects/$project/$environment" params={{ project, environment: parents[0]! }}>
|
|
521
|
+
{project}/{parents[0]}
|
|
522
|
+
</Link>
|
|
523
|
+
: what you set here, only you read, while you read {parents[0]}; the rest is {parents[0]}'s, as it changes.
|
|
524
|
+
</span>
|
|
525
|
+
) : parents.length > 0 && (
|
|
526
|
+
<span className="inherits">
|
|
527
|
+
Inherits from{' '}
|
|
528
|
+
<Link className="mono" to="/projects/$project/$environment" params={{ project, environment: parents[0]! }}>
|
|
529
|
+
{project}/{parents[0]}
|
|
530
|
+
</Link>
|
|
531
|
+
{parents.length > 1 && <>, which inherits from {parents.slice(1).map((parent) => `${project}/${parent}`).join(', then ')}</>}
|
|
532
|
+
: its keys, as they change, but for those set or removed here.
|
|
533
|
+
</span>
|
|
534
|
+
)}
|
|
535
|
+
/>
|
|
447
536
|
|
|
448
537
|
{(active.length > 0 || drafts.length > 0) && (
|
|
449
538
|
<div className="toolbar">
|
|
@@ -524,7 +613,7 @@ function EnvironmentLedger({
|
|
|
524
613
|
</thead>
|
|
525
614
|
<tbody>
|
|
526
615
|
{byFolder(listed).flatMap(([folder, entries]) => [
|
|
527
|
-
...(folder === null ? [] : [<FolderRow key={`folder:${folder}`} folder={folder} count={entries.length} columns={columns} actions={folderMenu(folder, entries.length)} />]),
|
|
616
|
+
...(folder === null ? [] : [<FolderRow key={`folder:${folder}`} folder={folder} count={entries.length} columns={columns} actions={folderMenu(folder, entries.filter(heldHere).length)} />]),
|
|
528
617
|
...entries.map((entry) => {
|
|
529
618
|
const change = secretChangeFor(changes, entry.key);
|
|
530
619
|
const state = status(entry.key);
|
|
@@ -535,6 +624,23 @@ function EnvironmentLedger({
|
|
|
535
624
|
project={project}
|
|
536
625
|
environment={environment}
|
|
537
626
|
entry={entry}
|
|
627
|
+
generated={liveGeneration(entry, active)}
|
|
628
|
+
// Being edited, written by a new row or its companion, or with a save on its way:
|
|
629
|
+
// a key pair's Regenerate waits for both halves.
|
|
630
|
+
busy={(key) =>
|
|
631
|
+
status(key).state === 'pending' ||
|
|
632
|
+
editing.has(key) ||
|
|
633
|
+
secretChangeFor(changes, key) !== undefined ||
|
|
634
|
+
drafts.some((draft) => draft.key.trim() === key || draft.companion?.key.trim() === key) ||
|
|
635
|
+
// Written here and not yet read back: no version to say it replaces.
|
|
636
|
+
versionIdOf(key) === null
|
|
637
|
+
}
|
|
638
|
+
onRegenerate={(generated) =>
|
|
639
|
+
regenerate(
|
|
640
|
+
{ key: entry.key, generated, versions: versionsOf(regeneratedKeys(entry.key, generated)) },
|
|
641
|
+
{ onSuccess: () => toast.success(`Regenerated ${regeneratedKeys(entry.key, generated).join(' and ')}`) },
|
|
642
|
+
)
|
|
643
|
+
}
|
|
538
644
|
rotateAfterDays={rotateAfterDays}
|
|
539
645
|
change={change ?? { key: entry.key, value: null, archived: false }}
|
|
540
646
|
editing={
|
|
@@ -547,12 +653,14 @@ function EnvironmentLedger({
|
|
|
547
653
|
folders={folders}
|
|
548
654
|
onMove={(folder) => move({ key: entry.key, folder })}
|
|
549
655
|
lent={lentBy.get(entry.key) ?? []}
|
|
550
|
-
|
|
656
|
+
// A personal config holds values only: no reference.
|
|
657
|
+
environments={personal ? [] : readable}
|
|
551
658
|
status={state}
|
|
552
659
|
// Not while its save is on its way.
|
|
553
660
|
disabled={state.state === 'pending'}
|
|
554
661
|
onDismiss={dismiss}
|
|
555
662
|
columns={columns}
|
|
663
|
+
onFork={(action) => forkAction(entry, action)}
|
|
556
664
|
onEdit={() => setEditing((current) => new Set(current).add(entry.key))}
|
|
557
665
|
onPatch={(patch) => patchChange(entry, patch)}
|
|
558
666
|
onUndo={() => dropChange(entry.key)}
|
|
@@ -1049,6 +1157,9 @@ function SecretRow({
|
|
|
1049
1157
|
project,
|
|
1050
1158
|
environment,
|
|
1051
1159
|
entry,
|
|
1160
|
+
generated,
|
|
1161
|
+
busy,
|
|
1162
|
+
onRegenerate,
|
|
1052
1163
|
rotateAfterDays,
|
|
1053
1164
|
change,
|
|
1054
1165
|
editing,
|
|
@@ -1063,6 +1174,7 @@ function SecretRow({
|
|
|
1063
1174
|
disabled,
|
|
1064
1175
|
onDismiss,
|
|
1065
1176
|
columns,
|
|
1177
|
+
onFork,
|
|
1066
1178
|
onEdit,
|
|
1067
1179
|
onPatch,
|
|
1068
1180
|
onUndo,
|
|
@@ -1075,6 +1187,12 @@ function SecretRow({
|
|
|
1075
1187
|
project: string;
|
|
1076
1188
|
environment: string;
|
|
1077
1189
|
entry: SecretKey;
|
|
1190
|
+
/** Its recipe, as the page may regenerate it by: a key pair's while both halves are listed alike (`liveGeneration`). */
|
|
1191
|
+
generated: Generation | null;
|
|
1192
|
+
/** Whether a key in this environment is being edited, or has a save on its way. */
|
|
1193
|
+
busy: (key: string) => boolean;
|
|
1194
|
+
/** Regenerate it by its recipe, a tracked save of every key it writes. */
|
|
1195
|
+
onRegenerate: (generated: Generation) => void;
|
|
1078
1196
|
rotateAfterDays: number | null;
|
|
1079
1197
|
change: SecretChange;
|
|
1080
1198
|
editing: boolean;
|
|
@@ -1094,6 +1212,8 @@ function SecretRow({
|
|
|
1094
1212
|
/** Forget a refused change once its row has said so. */
|
|
1095
1213
|
onDismiss: (mutationId: number) => void;
|
|
1096
1214
|
columns: number;
|
|
1215
|
+
/** In a fork, the key against its parent's: removed, restored, reset or overriding it again. */
|
|
1216
|
+
onFork: (action: ForkAction) => void;
|
|
1097
1217
|
onEdit: () => void;
|
|
1098
1218
|
onPatch: (patch: Partial<SecretChange>) => void;
|
|
1099
1219
|
onUndo: () => void;
|
|
@@ -1112,15 +1232,27 @@ function SecretRow({
|
|
|
1112
1232
|
const [moving, setMoving] = useState(false);
|
|
1113
1233
|
const [referring, setReferring] = useState(false);
|
|
1114
1234
|
const [breaking, setBreaking] = useState<string | null>(null);
|
|
1235
|
+
const [regenerating, setRegenerating] = useState(false);
|
|
1115
1236
|
const [lentOpen, setLentOpen] = useState(false);
|
|
1116
1237
|
// Archiving a key others read through references waits until they are broken (D41).
|
|
1117
1238
|
const [archiveBlocked, setArchiveBlocked] = useState(false);
|
|
1118
1239
|
const blockers = archiveBlockers(`${project}/${environment}/${entry.key}`, lent);
|
|
1119
1240
|
// Making or breaking a reference: its refusal shows under the row, as a reveal's does.
|
|
1120
1241
|
const { run: act, error: actError } = useAction();
|
|
1121
|
-
const { reference } = entry;
|
|
1242
|
+
const { reference, parent } = entry;
|
|
1243
|
+
// In a fork (docs/design/forking.md): a key it inherits has no row of its
|
|
1244
|
+
// own, one it overrides has, and one it removed is not served.
|
|
1245
|
+
const inherited = parent?.state === 'inherited';
|
|
1246
|
+
const removed = parent?.state === 'removed';
|
|
1247
|
+
const overridden = parent?.state === 'overridden';
|
|
1248
|
+
const own = !inherited && !removed;
|
|
1249
|
+
// Inherited from a parent you do not read: its name is yours to know, its value is not.
|
|
1250
|
+
const parentHidden = inherited && entry.version === null && reference === null;
|
|
1251
|
+
const canRead = canReveal && !removed && !parentHidden;
|
|
1122
1252
|
// What a reveal shows: its own version, or, as a reference, its source's.
|
|
1123
1253
|
const readVersion = reference === null ? entry.version : reference.version;
|
|
1254
|
+
// And where that version is held: a reset, an override or a new reference changes it under the same number.
|
|
1255
|
+
const readFrom = `${inherited ? parent!.from : '.'}:${reference?.source ?? ''}`;
|
|
1124
1256
|
const holderPath = `${project}/${environment}/${entry.key}`;
|
|
1125
1257
|
// The current value, loaded on request as the starting point for an edit.
|
|
1126
1258
|
// It is not a change until it is edited: saving it untouched would append a
|
|
@@ -1131,10 +1263,10 @@ function SecretRow({
|
|
|
1131
1263
|
// different version -- saved here, rolled back, or written by someone else
|
|
1132
1264
|
// and picked up on refresh -- the old plaintext is not the value any more,
|
|
1133
1265
|
// and must not stay on screen pretending to be.
|
|
1134
|
-
const shown = revealIsCurrent(reveal, readVersion) ? reveal : null;
|
|
1266
|
+
const shown = revealIsCurrent(reveal, readVersion, readFrom) ? reveal : null;
|
|
1135
1267
|
useEffect(() => {
|
|
1136
|
-
if (reveal !== null && !revealIsCurrent(reveal, readVersion)) setReveal(null);
|
|
1137
|
-
}, [reveal, readVersion]);
|
|
1268
|
+
if (reveal !== null && !revealIsCurrent(reveal, readVersion, readFrom)) setReveal(null);
|
|
1269
|
+
}, [reveal, readVersion, readFrom]);
|
|
1138
1270
|
|
|
1139
1271
|
useEffect(() => {
|
|
1140
1272
|
if (reveal === null) return;
|
|
@@ -1144,7 +1276,7 @@ function SecretRow({
|
|
|
1144
1276
|
|
|
1145
1277
|
const secondsLeft = useSecondsLeft(shown);
|
|
1146
1278
|
|
|
1147
|
-
const editBase = editing && revealIsCurrent(base, readVersion) ? base : null;
|
|
1279
|
+
const editBase = editing && revealIsCurrent(base, readVersion, readFrom) ? base : null;
|
|
1148
1280
|
useEffect(() => {
|
|
1149
1281
|
if (!editing) setBase(null);
|
|
1150
1282
|
}, [editing]);
|
|
@@ -1156,7 +1288,7 @@ function SecretRow({
|
|
|
1156
1288
|
const value = await fetchValue();
|
|
1157
1289
|
dispatch({
|
|
1158
1290
|
type: 'read-succeeded',
|
|
1159
|
-
reveal: show ? { value, version: readVersion, at: Date.now() } : null,
|
|
1291
|
+
reveal: show ? { value, version: readVersion, from: readFrom, at: Date.now() } : null,
|
|
1160
1292
|
});
|
|
1161
1293
|
return value;
|
|
1162
1294
|
} catch (failure) {
|
|
@@ -1216,12 +1348,12 @@ function SecretRow({
|
|
|
1216
1348
|
const [focusName, setFocusName] = useState(false);
|
|
1217
1349
|
async function startEdit({ name = false } = {}) {
|
|
1218
1350
|
setFocusName(name);
|
|
1219
|
-
if (
|
|
1351
|
+
if (canRead) {
|
|
1220
1352
|
setOpening(true);
|
|
1221
1353
|
const value = await readValue({ show: false });
|
|
1222
1354
|
setOpening(false);
|
|
1223
1355
|
if (value === null) return;
|
|
1224
|
-
setBase({ value, version: readVersion, at: Date.now() });
|
|
1356
|
+
setBase({ value, version: readVersion, from: readFrom, at: Date.now() });
|
|
1225
1357
|
}
|
|
1226
1358
|
setReveal(null);
|
|
1227
1359
|
onEdit();
|
|
@@ -1237,7 +1369,11 @@ function SecretRow({
|
|
|
1237
1369
|
? ' is-changed'
|
|
1238
1370
|
: shown !== null
|
|
1239
1371
|
? ' is-revealed'
|
|
1240
|
-
:
|
|
1372
|
+
: removed
|
|
1373
|
+
? ' is-removed'
|
|
1374
|
+
: inherited
|
|
1375
|
+
? ' is-inherited'
|
|
1376
|
+
: '';
|
|
1241
1377
|
const version = entry.version ?? 0;
|
|
1242
1378
|
|
|
1243
1379
|
return (
|
|
@@ -1245,7 +1381,8 @@ function SecretRow({
|
|
|
1245
1381
|
<tr className={`secret-row${state} ${rowClass(status)}`}>
|
|
1246
1382
|
<td className="n">{number}</td>
|
|
1247
1383
|
<td className="cell-key" data-label="Key">
|
|
1248
|
-
{
|
|
1384
|
+
{/* An inherited key has no row here to rename: overriding it keeps its name. */}
|
|
1385
|
+
{editing && canWrite && own ? (
|
|
1249
1386
|
<div className="edit-stack">
|
|
1250
1387
|
<input
|
|
1251
1388
|
className="input input-mono"
|
|
@@ -1274,7 +1411,9 @@ function SecretRow({
|
|
|
1274
1411
|
) : (
|
|
1275
1412
|
<div className="key-cell">
|
|
1276
1413
|
<span>{breakAfterUnderscores(entry.key)}</span>
|
|
1414
|
+
{generated !== null && <RecipeMark generated={generated} />}
|
|
1277
1415
|
{leaving && <span className="tag tag-red">Will be archived</span>}
|
|
1416
|
+
{parent !== null && <Standing project={project} secretKey={entry.key} parent={parent} />}
|
|
1278
1417
|
{lent.length > 0 && (
|
|
1279
1418
|
<button
|
|
1280
1419
|
type="button"
|
|
@@ -1303,9 +1442,9 @@ function SecretRow({
|
|
|
1303
1442
|
placeholder={canReveal ? 'Value' : 'New value; the current one is hidden from you'}
|
|
1304
1443
|
disabled={disabled}
|
|
1305
1444
|
autoFocus={!focusName}
|
|
1306
|
-
// A value typed over a generated private key no longer matches its public key.
|
|
1445
|
+
// A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
|
|
1307
1446
|
onChange={(value) =>
|
|
1308
|
-
onPatch({ value: value === (editBase?.value ?? '') ? null : value, companion: undefined })
|
|
1447
|
+
onPatch({ value: value === (editBase?.value ?? '') ? null : value, companion: undefined, recipe: undefined })
|
|
1309
1448
|
}
|
|
1310
1449
|
onEscape={onUndo}
|
|
1311
1450
|
generate={{
|
|
@@ -1313,10 +1452,13 @@ function SecretRow({
|
|
|
1313
1452
|
name: change.key,
|
|
1314
1453
|
renamable: false,
|
|
1315
1454
|
companion: change.companion,
|
|
1316
|
-
onUse: ({ value, companion }) => onPatch({ value, companion }),
|
|
1455
|
+
onUse: ({ value, companion, recipe }) => onPatch({ value, companion, recipe }),
|
|
1317
1456
|
}}
|
|
1318
1457
|
/>
|
|
1319
1458
|
<CompanionNote companion={change.companion} versionOf={versionOf} />
|
|
1459
|
+
{!overridden && parent !== null && (
|
|
1460
|
+
<span className="edit-note">Saved here, over {parent.from}'s value</span>
|
|
1461
|
+
)}
|
|
1320
1462
|
{reference !== null && reference.state === 'live' && (
|
|
1321
1463
|
<span className="edit-note">
|
|
1322
1464
|
Saving a value stops following <span className="mono">{reference.source}</span>
|
|
@@ -1334,6 +1476,8 @@ function SecretRow({
|
|
|
1334
1476
|
</span>
|
|
1335
1477
|
<span className="revealed-meter" aria-hidden />
|
|
1336
1478
|
</div>
|
|
1479
|
+
) : removed ? (
|
|
1480
|
+
<span className="cell-muted">Not served here</span>
|
|
1337
1481
|
) : reference !== null ? (
|
|
1338
1482
|
<ReferenceValue reference={reference} />
|
|
1339
1483
|
) : (
|
|
@@ -1367,13 +1511,20 @@ function SecretRow({
|
|
|
1367
1511
|
</button>
|
|
1368
1512
|
</Tip>
|
|
1369
1513
|
</>
|
|
1514
|
+
) : removed ? (
|
|
1515
|
+
canWrite && (
|
|
1516
|
+
<button type="button" className="btn btn-sm" onClick={() => onFork('restore')} disabled={disabled}>
|
|
1517
|
+
Restore
|
|
1518
|
+
</button>
|
|
1519
|
+
)
|
|
1370
1520
|
) : (
|
|
1371
1521
|
<>
|
|
1372
1522
|
{/* Copy sits left of Reveal, hidden or shown, so Hide stays where
|
|
1373
1523
|
Reveal was clicked. Hidden, it copies without showing the value;
|
|
1374
1524
|
as for Reveal, it takes secret.read, and a reference copies the
|
|
1375
|
-
value it reads through
|
|
1376
|
-
|
|
1525
|
+
value it reads through; an inherited key, its parent's, which
|
|
1526
|
+
takes read there too. */}
|
|
1527
|
+
<SecretReadOnly canReveal={canRead}>
|
|
1377
1528
|
<CopyButton variant="act" copier={copier} onCopy={copyValue} label={`Copy ${entry.key}`} />
|
|
1378
1529
|
<Tip label={shown === null ? 'Reveal' : 'Hide'}>
|
|
1379
1530
|
<button
|
|
@@ -1393,12 +1544,12 @@ function SecretRow({
|
|
|
1393
1544
|
</Tip>
|
|
1394
1545
|
</SecretReadOnly>
|
|
1395
1546
|
{canWrite && (
|
|
1396
|
-
<Tip label=
|
|
1547
|
+
<Tip label={inherited ? `Override ${parent!.from}'s` : 'Edit'}>
|
|
1397
1548
|
<button
|
|
1398
1549
|
className="act act-icon"
|
|
1399
1550
|
onClick={() => void startEdit()}
|
|
1400
1551
|
disabled={disabled || revealing}
|
|
1401
|
-
aria-label={`Edit ${entry.key}`}
|
|
1552
|
+
aria-label={inherited ? `Override ${entry.key}` : `Edit ${entry.key}`}
|
|
1402
1553
|
>
|
|
1403
1554
|
{opening ? <Spinner size={13} /> : <Pencil size={14} />}
|
|
1404
1555
|
</button>
|
|
@@ -1412,26 +1563,33 @@ function SecretRow({
|
|
|
1412
1563
|
</td>
|
|
1413
1564
|
|
|
1414
1565
|
<td className="col-version" data-label="Version">
|
|
1415
|
-
{editing && valueChanged ? (
|
|
1566
|
+
{editing && valueChanged && !overridden && parent !== null ? (
|
|
1567
|
+
<span className="version-shift">
|
|
1568
|
+
<b>own</b>
|
|
1569
|
+
</span>
|
|
1570
|
+
) : editing && valueChanged ? (
|
|
1416
1571
|
<span className="version-shift">
|
|
1417
1572
|
v{version} → <b>v{version + 1}</b>
|
|
1418
1573
|
</span>
|
|
1419
1574
|
) : (
|
|
1420
|
-
<span
|
|
1575
|
+
<span
|
|
1576
|
+
className="version-shift"
|
|
1577
|
+
title={inherited ? `${parent!.from}'s version` : reference === null ? undefined : "The source's version"}
|
|
1578
|
+
>
|
|
1421
1579
|
{readVersion === null ? '—' : `v${readVersion}`}
|
|
1422
1580
|
</span>
|
|
1423
1581
|
)}
|
|
1424
1582
|
</td>
|
|
1425
1583
|
|
|
1426
1584
|
<td className="col-written" data-label="Last written">
|
|
1427
|
-
<Written entry={entry} rotateAfterDays={rotateAfterDays} />
|
|
1585
|
+
{!removed && <Written entry={entry} rotateAfterDays={rotateAfterDays} />}
|
|
1428
1586
|
</td>
|
|
1429
1587
|
|
|
1430
1588
|
<td className="col-actions">
|
|
1431
1589
|
{status.state === 'pending' ? (
|
|
1432
1590
|
<RowPending status={status} />
|
|
1433
1591
|
) : (
|
|
1434
|
-
(canReveal || (canWrite && !editing && !leaving) || (canArchive && !leaving)) && (
|
|
1592
|
+
!removed && (canReveal || (canWrite && !editing && !leaving) || (canArchive && !leaving && own && !overridden)) && (
|
|
1435
1593
|
<Menu.Root>
|
|
1436
1594
|
<Menu.Trigger
|
|
1437
1595
|
className="act act-icon act-quiet"
|
|
@@ -1441,37 +1599,72 @@ function SecretRow({
|
|
|
1441
1599
|
<MoreHorizontal size={16} />
|
|
1442
1600
|
</Menu.Trigger>
|
|
1443
1601
|
<MenuPopup align="end">
|
|
1444
|
-
<SecretReadOnly canReveal={canReveal}>
|
|
1602
|
+
<SecretReadOnly canReveal={canReveal && own}>
|
|
1445
1603
|
<Menu.Item className="menu-item" onClick={() => setHistoryOpen((open) => !open)}>
|
|
1446
1604
|
<History size={14} />
|
|
1447
1605
|
{historyOpen ? 'Hide history' : 'Version history'}
|
|
1448
1606
|
</Menu.Item>
|
|
1449
1607
|
</SecretReadOnly>
|
|
1450
|
-
{canWrite && !editing &&
|
|
1608
|
+
{canWrite && !editing && inherited && (
|
|
1609
|
+
<>
|
|
1610
|
+
<Menu.Item className="menu-item" onClick={() => void startEdit()}>
|
|
1611
|
+
<Pencil size={14} />
|
|
1612
|
+
Override…
|
|
1613
|
+
</Menu.Item>
|
|
1614
|
+
{parent!.reset && (
|
|
1615
|
+
<Menu.Item className="menu-item" onClick={() => onFork('override')}>
|
|
1616
|
+
<RotateBack size={14} />
|
|
1617
|
+
Use its own value again
|
|
1618
|
+
</Menu.Item>
|
|
1619
|
+
)}
|
|
1620
|
+
<Menu.Item className="menu-item" onClick={() => onFork('remove')}>
|
|
1621
|
+
<SlashCircle size={14} />
|
|
1622
|
+
Remove from {environment}
|
|
1623
|
+
</Menu.Item>
|
|
1624
|
+
</>
|
|
1625
|
+
)}
|
|
1626
|
+
{canWrite && !editing && !leaving && overridden && (
|
|
1627
|
+
<Menu.Item className="menu-item" onClick={() => onFork('reset')}>
|
|
1628
|
+
<RotateBack size={14} />
|
|
1629
|
+
Reset to {parent!.from}
|
|
1630
|
+
</Menu.Item>
|
|
1631
|
+
)}
|
|
1632
|
+
{canWrite && !editing && !leaving && own && (
|
|
1451
1633
|
<Menu.Item className="menu-item" onClick={() => void startEdit({ name: true })}>
|
|
1452
1634
|
<Pencil size={14} />
|
|
1453
1635
|
Rename
|
|
1454
1636
|
</Menu.Item>
|
|
1455
1637
|
)}
|
|
1456
|
-
{canWrite && !editing && !leaving && (
|
|
1638
|
+
{canWrite && !editing && !leaving && generated !== null && (
|
|
1639
|
+
<Menu.Item
|
|
1640
|
+
className="menu-item"
|
|
1641
|
+
disabled={regenerateWaits(entry.key, generated, busy)}
|
|
1642
|
+
onClick={() => setRegenerating(true)}
|
|
1643
|
+
>
|
|
1644
|
+
<Generate size={14} />
|
|
1645
|
+
Regenerate…
|
|
1646
|
+
</Menu.Item>
|
|
1647
|
+
)}
|
|
1648
|
+
{canWrite && !editing && !leaving && own && (
|
|
1457
1649
|
<Menu.Item className="menu-item" onClick={() => setMoving(true)}>
|
|
1458
1650
|
<Folder size={14} />
|
|
1459
1651
|
Move to folder…
|
|
1460
1652
|
</Menu.Item>
|
|
1461
1653
|
)}
|
|
1462
|
-
{canWrite && !editing && !leaving && (
|
|
1654
|
+
{canWrite && !editing && !leaving && own && environments.length > 0 && (
|
|
1463
1655
|
<Menu.Item className="menu-item" onClick={() => setReferring(true)}>
|
|
1464
1656
|
<ArrowRight size={14} />
|
|
1465
1657
|
{reference === null ? 'Make a reference…' : 'Point elsewhere…'}
|
|
1466
1658
|
</Menu.Item>
|
|
1467
1659
|
)}
|
|
1468
|
-
{canWrite && !editing && !leaving && reference !== null && reference.state === 'live' && (
|
|
1660
|
+
{canWrite && !editing && !leaving && own && reference !== null && reference.state === 'live' && (
|
|
1469
1661
|
<Menu.Item className="menu-item" onClick={() => setBreaking(holderPath)}>
|
|
1470
1662
|
<SlashCircle size={14} />
|
|
1471
1663
|
Break reference…
|
|
1472
1664
|
</Menu.Item>
|
|
1473
1665
|
)}
|
|
1474
|
-
{
|
|
1666
|
+
{/* An override's way out is Reset, which keeps it; archiving there would be the same, by more. */}
|
|
1667
|
+
{canArchive && !leaving && own && !overridden && (
|
|
1475
1668
|
<>
|
|
1476
1669
|
{(canReveal || canWrite) && <Menu.Separator className="menu-sep" />}
|
|
1477
1670
|
<Menu.Item
|
|
@@ -1510,6 +1703,20 @@ function SecretRow({
|
|
|
1510
1703
|
/>
|
|
1511
1704
|
)}
|
|
1512
1705
|
|
|
1706
|
+
{canWrite && generated !== null && (
|
|
1707
|
+
<RegenerateSecret
|
|
1708
|
+
open={regenerating}
|
|
1709
|
+
onOpenChange={setRegenerating}
|
|
1710
|
+
place={`${project}/${environment}`}
|
|
1711
|
+
entry={entry}
|
|
1712
|
+
generated={generated}
|
|
1713
|
+
onConfirm={() => {
|
|
1714
|
+
setReveal(null);
|
|
1715
|
+
onRegenerate(generated);
|
|
1716
|
+
}}
|
|
1717
|
+
/>
|
|
1718
|
+
)}
|
|
1719
|
+
|
|
1513
1720
|
<ConfirmDialog
|
|
1514
1721
|
open={archiveBlocked}
|
|
1515
1722
|
onOpenChange={setArchiveBlocked}
|
|
@@ -1598,6 +1805,110 @@ function SecretRow({
|
|
|
1598
1805
|
);
|
|
1599
1806
|
}
|
|
1600
1807
|
|
|
1808
|
+
/** Delete your personal config, from its page: its values erased; dev itself untouched. */
|
|
1809
|
+
function DeletePersonal({ project, environment, of }: { project: string; environment: string; of: string }) {
|
|
1810
|
+
const coffre = useCoffre();
|
|
1811
|
+
const navigate = useNavigate();
|
|
1812
|
+
const [open, setOpen] = useState(false);
|
|
1813
|
+
const { error, run } = useAction();
|
|
1814
|
+
return (
|
|
1815
|
+
<>
|
|
1816
|
+
<button type="button" className="btn btn-sm" onClick={() => setOpen(true)}>
|
|
1817
|
+
<Trash size={14} />
|
|
1818
|
+
Delete…
|
|
1819
|
+
</button>
|
|
1820
|
+
{error !== null && <ErrorLine error={error} />}
|
|
1821
|
+
<ConfirmDialog
|
|
1822
|
+
open={open}
|
|
1823
|
+
onOpenChange={setOpen}
|
|
1824
|
+
title={<>Delete your own <span className="mono">{of}</span>?</>}
|
|
1825
|
+
body={`The values you set in ${project}/${environment} are erased for good. ${project}/${of} is untouched, and ${environment} reads it again.`}
|
|
1826
|
+
confirmLabel="Delete"
|
|
1827
|
+
onConfirm={() =>
|
|
1828
|
+
void run(() => coffre.environments.delete(`${project}/${environment}`), {
|
|
1829
|
+
affects: [...affects.secrets({ project, environment }), ...affects.places()],
|
|
1830
|
+
onSuccess: () => {
|
|
1831
|
+
toast.success(`Your own ${of} is deleted`);
|
|
1832
|
+
void navigate({ to: '/projects/$project/$environment', params: { project, environment: of } });
|
|
1833
|
+
},
|
|
1834
|
+
})}
|
|
1835
|
+
/>
|
|
1836
|
+
</>
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* `dev@me` while you have no personal dev: what one is, and Make, which
|
|
1842
|
+
* makes it empty; your first write would make it too. A read of
|
|
1843
|
+
* `market/dev@me` meanwhile is dev's, so scripts can name it either way.
|
|
1844
|
+
*/
|
|
1845
|
+
function NoPersonalConfig({ project, of }: { project: string; of: string }) {
|
|
1846
|
+
const coffre = useCoffre();
|
|
1847
|
+
const { pending, error, run } = useAction();
|
|
1848
|
+
return (
|
|
1849
|
+
<>
|
|
1850
|
+
<PageHeader tile={project} title={`${of}@me`} />
|
|
1851
|
+
<Card labelledBy="no-personal-config" title={`You have no personal ${of} yet`}>
|
|
1852
|
+
<div className="card-row">
|
|
1853
|
+
<div>
|
|
1854
|
+
<p className="card-row-desc">
|
|
1855
|
+
A personal config is your own <span className="mono">{project}/{of}</span>: it reads {of}'s keys as they change,
|
|
1856
|
+
and the values you set or remove there are yours alone. No one else reads them, an Owner included, and you read
|
|
1857
|
+
them only while you read {of}. Until you make one, <span className="mono">{project}/{of}@me</span> reads {of} itself,
|
|
1858
|
+
so a script can name it either way.
|
|
1859
|
+
</p>
|
|
1860
|
+
{error !== null && <ErrorLine error={error} />}
|
|
1861
|
+
</div>
|
|
1862
|
+
<button
|
|
1863
|
+
type="button"
|
|
1864
|
+
className="btn btn-primary"
|
|
1865
|
+
disabled={pending}
|
|
1866
|
+
onClick={() => void run(() => coffre.environments.create(`${project}/${of}@me`), {
|
|
1867
|
+
affects: [...affects.secrets({ project, environment: `${of}@me` }), ...affects.places()],
|
|
1868
|
+
onSuccess: () => toast.success(`Your own ${of} is made: what you set there is yours alone`),
|
|
1869
|
+
})}
|
|
1870
|
+
>
|
|
1871
|
+
{pending ? <Spinner size={13} /> : <Plus size={14} />}
|
|
1872
|
+
Make my own {of}
|
|
1873
|
+
</button>
|
|
1874
|
+
</div>
|
|
1875
|
+
</Card>
|
|
1876
|
+
</>
|
|
1877
|
+
);
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* Where a fork's key stands to its parent's (docs/design/forking.md):
|
|
1882
|
+
* inherited from it, overriding it, perhaps since it changed, or removed.
|
|
1883
|
+
* The parent links to its own row of the key.
|
|
1884
|
+
*/
|
|
1885
|
+
function Standing({ project, secretKey, parent }: { project: string; secretKey: string; parent: NonNullable<SecretKey['parent']> }) {
|
|
1886
|
+
const from = (
|
|
1887
|
+
<Link className="tag-link" to="/projects/$project/$environment" params={{ project, environment: parent.from }} search={{ filter: secretKey }}>
|
|
1888
|
+
{parent.from}
|
|
1889
|
+
</Link>
|
|
1890
|
+
);
|
|
1891
|
+
switch (parent.state) {
|
|
1892
|
+
case 'inherited':
|
|
1893
|
+
return <span className="tag tag-outline">from {from}</span>;
|
|
1894
|
+
case 'removed':
|
|
1895
|
+
return <span className="tag tag-outline">removed · {from} {parent.held ? 'has it' : 'dropped it'}</span>;
|
|
1896
|
+
case 'overridden':
|
|
1897
|
+
return (
|
|
1898
|
+
<>
|
|
1899
|
+
<span className="tag tag-outline">overrides {from}</span>
|
|
1900
|
+
{parent.changed && (
|
|
1901
|
+
<Tip label={`${parent.from} has written a newer value since this one: check the override still holds`}>
|
|
1902
|
+
<span className="tag tag-amber" tabIndex={0}>
|
|
1903
|
+
{parent.from} changed since
|
|
1904
|
+
</span>
|
|
1905
|
+
</Tip>
|
|
1906
|
+
)}
|
|
1907
|
+
</>
|
|
1908
|
+
);
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1601
1912
|
/**
|
|
1602
1913
|
* A column header that orders the table: its first click ascending, the
|
|
1603
1914
|
* next descending. Below the width where rows stack, the sortable headers
|
|
@@ -1753,14 +2064,14 @@ function DraftRow({
|
|
|
1753
2064
|
value={draft.value}
|
|
1754
2065
|
placeholder="Value"
|
|
1755
2066
|
disabled={disabled}
|
|
1756
|
-
// A value typed over a generated private key no longer matches its public key.
|
|
1757
|
-
onChange={(value) => onChange({ value, companion: undefined })}
|
|
2067
|
+
// A value typed over a generated one has no recipe, and a private key's no longer matches its public key.
|
|
2068
|
+
onChange={(value) => onChange({ value, companion: undefined, recipe: undefined })}
|
|
1758
2069
|
onEscape={onRemove}
|
|
1759
2070
|
generate={{
|
|
1760
2071
|
name: draft.key,
|
|
1761
2072
|
renamable: true,
|
|
1762
2073
|
companion: draft.companion,
|
|
1763
|
-
onUse: ({ value, name, companion }) => onChange({ key: name, value, companion }),
|
|
2074
|
+
onUse: ({ value, name, companion, recipe }) => onChange({ key: name, value, companion, recipe }),
|
|
1764
2075
|
}}
|
|
1765
2076
|
/>
|
|
1766
2077
|
<CompanionNote companion={draft.companion} versionOf={versionOf} />
|
|
@@ -2002,7 +2313,14 @@ function VersionHistory({
|
|
|
2002
2313
|
<td className="nowrap">
|
|
2003
2314
|
<Timestamp iso={version.createdAt} />
|
|
2004
2315
|
</td>
|
|
2005
|
-
<td>
|
|
2316
|
+
<td>
|
|
2317
|
+
{version.createdBy}
|
|
2318
|
+
{version.recipe !== null && (
|
|
2319
|
+
<span className="cell-muted">
|
|
2320
|
+
{' '}· generated, <span className="mono">{version.recipe}</span>
|
|
2321
|
+
</span>
|
|
2322
|
+
)}
|
|
2323
|
+
</td>
|
|
2006
2324
|
<td className="cell-mono cell-muted nowrap">{version.kek}</td>
|
|
2007
2325
|
<td className="col-actions">
|
|
2008
2326
|
{canWrite && !version.current && (
|