@coffre/ui 0.1.10 → 0.1.12
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/client/_coffre/assets/account-CyJDFhek.js +2 -0
- package/dist/client/_coffre/assets/account-DHSs5h2f.js +1 -0
- package/dist/client/_coffre/assets/affordances-BQD5B421.js +1 -0
- package/dist/client/_coffre/assets/audit-Bcyp_dU1.js +2 -0
- package/dist/client/_coffre/assets/audit-rMy9mU9Q.js +1 -0
- package/dist/client/_coffre/assets/auth.device-DuvaComb.js +1 -0
- package/dist/client/_coffre/assets/auth.device-yBt_sLZW.js +2 -0
- package/dist/client/_coffre/assets/directory-C4BMGC7-.js +1 -0
- package/dist/client/_coffre/assets/dist-BNkBTkxj.js +1 -0
- package/dist/client/_coffre/assets/globals-BJkzu6T5.css +1 -0
- package/dist/client/_coffre/assets/grants-CyDW25eX.js +1 -0
- package/dist/client/_coffre/assets/icons-BRl8DlXW.js +1 -0
- package/dist/client/_coffre/assets/index-CA1mtrIx.js +12 -0
- package/dist/client/_coffre/assets/link-CqlAJWBd.js +1 -0
- package/dist/client/_coffre/assets/login-B73b6bsJ.js +1 -0
- package/dist/client/_coffre/assets/login-BO1KAGPU.js +2 -0
- package/dist/client/_coffre/assets/offboarding--5vSKNHv.js +1 -0
- package/dist/client/_coffre/assets/page-Dngv8FMr.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-DBha3tys.js +1 -0
- package/dist/client/_coffre/assets/principal-page-C4qDD-d8.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-eBKxOZ0_.js +2 -0
- package/dist/client/_coffre/assets/projects._project._environment-or_AX6o5.js +3 -0
- package/dist/client/_coffre/assets/projects._project.index-DHdXfEh-.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-iynQgenH.js +1 -0
- package/dist/client/_coffre/assets/projects.index-CGW8mRil.js +1 -0
- package/dist/client/_coffre/assets/row-state-BlarvG7E.js +1 -0
- package/dist/client/_coffre/assets/settings-D-7RJIDf.js +1 -0
- package/dist/client/_coffre/assets/suspense-q_eJaZ18.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-0u7midqA.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-C53NqScg.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-DBZTLnbi.js +1 -0
- package/dist/client/_coffre/assets/ui-BPWFJNz7.js +46 -0
- package/dist/client/_coffre/assets/unregistered-CLhgtwUt.js +1 -0
- package/dist/client/_coffre/assets/use-action-LULgF26O.js +1 -0
- package/dist/client/_coffre/assets/use-change-Bd6NZJj9.js +1 -0
- package/dist/client/_coffre/assets/use-shell-Dx92Huhb.js +1 -0
- package/dist/client/_coffre/assets/useQuery-BIIZz1CB.js +1 -0
- package/dist/client/_coffre/assets/useSuspenseQuery-tP9HFZ8w.js +1 -0
- package/dist/client/_coffre/assets/users._user-BXtaL8Ee.js +2 -0
- package/dist/client/_coffre/assets/users._user-CNYVkXaY.js +1 -0
- package/dist/client/_coffre/assets/users.index-Cs9tibIv.js +1 -0
- package/dist/server/.vite/manifest.json +342 -246
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-T9tMsCwo.js +162 -0
- package/dist/server/_coffre/assets/{account-CUQYGCYh.js → account-BUhhOS5-.js} +150 -117
- package/dist/server/_coffre/assets/{account-DMlUoBxQ.js → account-B_h55GCs.js} +10 -24
- package/dist/server/_coffre/assets/{affordances-BNaXjMOb.js → affordances-CKANXDTG.js} +2 -22
- package/dist/server/_coffre/assets/{async-local-storage-C0cwgkEr.js → async-local-storage-C10uQtMM.js} +3 -2
- package/dist/server/_coffre/assets/{audit-CCdSLmvK.js → audit-B8Ck358-.js} +46 -16
- package/dist/server/_coffre/assets/audit-DFsXfeAQ.js +31 -0
- package/dist/server/_coffre/assets/{auth.device-BoFM1jcf.js → auth.device-BXf_JjT7.js} +5 -5
- package/dist/server/_coffre/assets/{auth.device-C05u5ROO.js → auth.device-cqjWACvB.js} +7 -5
- package/dist/server/_coffre/assets/{directory-GsnYkse0.js → directory-C9SfNgpM.js} +87 -112
- package/dist/server/_coffre/assets/{use-action-DwEmf58L.js → dist-CnnV3t2g.js} +3 -48
- package/dist/server/_coffre/assets/globals-BJkzu6T5.css +1 -0
- package/dist/server/_coffre/assets/grants--315KmXu.js +158 -0
- package/dist/server/_coffre/assets/{page-BdnhpwvH.js → icons-CWsTEfpn.js} +125 -436
- package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +480 -0
- package/dist/server/_coffre/assets/link-42ZWdjzZ.js +422 -0
- package/dist/server/_coffre/assets/{login-DUtCQju5.js → login-CQSkYW_D.js} +7 -5
- package/dist/server/_coffre/assets/{login-B2njIq_o.js → login-LBpXXfsQ.js} +2 -2
- package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +56 -0
- package/dist/server/_coffre/assets/{offboarding-8yMa7ViM.js → offboarding-CykelNis.js} +11 -79
- package/dist/server/_coffre/assets/page-BGeDoQO5.js +3531 -0
- package/dist/server/_coffre/assets/{principal-page-B8zPcS2b.js → principal-page-CRdoAQOq.js} +51 -42
- package/dist/server/_coffre/assets/{projects._project._environment-DdIOc7wx.js → projects._project._environment-BXU1Mee5.js} +4 -11
- package/dist/server/_coffre/assets/{projects._project._environment-BZ5Z80V8.js → projects._project._environment-BrDqn8kW.js} +129 -748
- package/dist/server/_coffre/assets/{projects._project.index-CuEAUwGn.js → projects._project.index-CAxBU4tY.js} +134 -96
- package/dist/server/_coffre/assets/{projects._project.index-DvbcU1kh.js → projects._project.index-CYyUVTCl.js} +5 -4
- package/dist/server/_coffre/assets/{projects.index-5HI0wOuG.js → projects.index-D6ZoDE_0.js} +57 -55
- package/dist/server/_coffre/assets/{react-dom-qCTiwGGR.js → react-dom-bBoJXlK2.js} +417 -51
- package/dist/server/_coffre/assets/{router-CQDoql8s.js → router-Bu2qtyqw.js} +376 -92
- package/dist/server/_coffre/assets/row-state-CAItu3n_.js +117 -0
- package/dist/server/_coffre/assets/{settings-BVz78wjP.js → settings-ByeF6hBa.js} +8 -6
- package/dist/server/_coffre/assets/suspense-beD01bb8.js +602 -0
- package/dist/server/_coffre/assets/tokens._token-CM01QPCq.js +10 -0
- package/dist/server/_coffre/assets/{tokens._token-CWs3Mtki.js → tokens._token-D2E4P3Qc.js} +97 -79
- package/dist/server/_coffre/assets/{tokens.index-Ck0LN7aC.js → tokens.index-Cmrgn3mU.js} +9 -6
- package/dist/server/_coffre/assets/{ui-D_slKpSF.js → ui-DvlGkmaH.js} +7 -836
- package/dist/server/_coffre/assets/{unregistered-Z17da4Rc.js → unregistered-DSArejP9.js} +5 -3
- package/dist/server/_coffre/assets/use-action-C2wz34kq.js +47 -0
- package/dist/server/_coffre/assets/use-change-CJpGSNIq.js +1212 -0
- package/dist/server/_coffre/assets/use-shell-C3iYcyP1.js +462 -0
- package/dist/server/_coffre/assets/useQuery-ChxaQ4Cb.js +8 -0
- package/dist/server/_coffre/assets/{useStore-DWGPqzXR.js → useRouter-CaUSUNsw.js} +1 -420
- package/dist/server/_coffre/assets/useSuspenseQuery-BjAmlGZl.js +117 -0
- package/dist/server/_coffre/assets/users._user-BVeR9fZP.js +10 -0
- package/dist/server/_coffre/assets/{users._user-CMwj-VI9.js → users._user-Cih2Etf4.js} +4 -5
- package/dist/server/_coffre/assets/{users.index-fWHv6A30.js → users.index-Bo2_a95G.js} +9 -6
- package/dist/server/index.js +6 -5
- package/package.json +5 -3
- package/src/components/directory.tsx +75 -104
- package/src/components/grants.tsx +60 -112
- package/src/components/icons.tsx +0 -34
- package/src/components/offboarding.tsx +1 -52
- package/src/components/principal-page.tsx +54 -67
- package/src/components/principal-picker.tsx +7 -16
- package/src/components/row-state.tsx +95 -0
- package/src/components/service-tokens.tsx +75 -64
- package/src/components/shell.tsx +1 -1
- package/src/lib/announce.ts +36 -0
- package/src/lib/changes.ts +498 -0
- package/src/lib/coffre.ts +1 -1
- package/src/lib/optimistic.ts +233 -0
- package/src/lib/queries.ts +385 -0
- package/src/lib/use-action.ts +20 -15
- package/src/lib/use-change.ts +42 -0
- package/src/lib/use-shell.ts +17 -0
- package/src/router.tsx +17 -9
- package/src/routes/__root.tsx +8 -38
- package/src/routes/account.tsx +163 -154
- package/src/routes/audit.tsx +51 -72
- package/src/routes/auth.device.tsx +4 -2
- package/src/routes/login.tsx +3 -2
- package/src/routes/projects.$project.$environment.tsx +223 -238
- package/src/routes/projects.$project.index.tsx +136 -118
- package/src/routes/projects.index.tsx +117 -145
- package/src/routes/settings.tsx +7 -7
- package/src/routes/tokens.$token.tsx +14 -17
- package/src/routes/tokens.index.tsx +8 -4
- package/src/routes/unregistered.tsx +3 -2
- package/src/routes/users.$user.tsx +4 -4
- package/src/routes/users.index.tsx +8 -4
- package/src/shared/models.ts +1 -5
- package/src/styles/globals.css +80 -50
- package/dist/client/_coffre/assets/account-B48wuSF8.js +0 -1
- package/dist/client/_coffre/assets/account-BkNyIDT7.js +0 -2
- package/dist/client/_coffre/assets/affordances-CmoY-8Xf.js +0 -1
- package/dist/client/_coffre/assets/audit-BvwKYb-5.js +0 -2
- package/dist/client/_coffre/assets/audit-D02H-zxS.js +0 -1
- package/dist/client/_coffre/assets/auth.device-BP5FY0K1.js +0 -1
- package/dist/client/_coffre/assets/auth.device-DYOONgFF.js +0 -2
- package/dist/client/_coffre/assets/coffre-BBp7cKVa.js +0 -1
- package/dist/client/_coffre/assets/directory-Bu0EIxqI.js +0 -1
- package/dist/client/_coffre/assets/globals-Bh2x1gBM.css +0 -1
- package/dist/client/_coffre/assets/grants-DavcwofW.js +0 -1
- package/dist/client/_coffre/assets/index-CDPlq5rM.js +0 -12
- package/dist/client/_coffre/assets/login-C-wTm_t1.js +0 -2
- package/dist/client/_coffre/assets/login-CLLv1om9.js +0 -1
- package/dist/client/_coffre/assets/offboarding-DWsE2FSa.js +0 -1
- package/dist/client/_coffre/assets/page-DbSS7pYH.js +0 -1
- package/dist/client/_coffre/assets/preload-helper-DduCCcmc.js +0 -46
- package/dist/client/_coffre/assets/principal-page-Bp_iwuSd.js +0 -1
- package/dist/client/_coffre/assets/projects._project._environment-BMeX_B8l.js +0 -2
- package/dist/client/_coffre/assets/projects._project._environment-CT0A-hIU.js +0 -3
- package/dist/client/_coffre/assets/projects._project.index-C_xYOGLT.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-Chcf-cUd.js +0 -1
- package/dist/client/_coffre/assets/projects.index-CfOtb1X5.js +0 -2
- package/dist/client/_coffre/assets/projects.index-DSjOhLDh.js +0 -1
- package/dist/client/_coffre/assets/settings-BC9cUJNK.js +0 -1
- package/dist/client/_coffre/assets/settings-Bkj_E21y.js +0 -2
- package/dist/client/_coffre/assets/tokens._token-BA0KqvaW.js +0 -1
- package/dist/client/_coffre/assets/tokens._token-Dh9jLOkm.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-BgAMWkHT.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-CHueIAv1.js +0 -1
- package/dist/client/_coffre/assets/unregistered-D5go1AfR.js +0 -1
- package/dist/client/_coffre/assets/use-action-l__xZDYY.js +0 -1
- package/dist/client/_coffre/assets/users._user-Dwqa0gv5.js +0 -1
- package/dist/client/_coffre/assets/users._user-xJAb3T6Y.js +0 -2
- package/dist/client/_coffre/assets/users.index-BJoF-L37.js +0 -2
- package/dist/client/_coffre/assets/users.index-YUjtbTGy.js +0 -1
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-BKg2AlPu.js +0 -133
- package/dist/server/_coffre/assets/audit-CThXn2v7.js +0 -74
- package/dist/server/_coffre/assets/coffre-C2ANsTAz.js +0 -281
- package/dist/server/_coffre/assets/globals-Bh2x1gBM.css +0 -1
- package/dist/server/_coffre/assets/grants-B6k4Fu9z.js +0 -243
- package/dist/server/_coffre/assets/projects.index-uiomWX_l.js +0 -54
- package/dist/server/_coffre/assets/settings-4oRyDizv.js +0 -18
- package/dist/server/_coffre/assets/tokens._token-CF_deAwq.js +0 -18
- package/dist/server/_coffre/assets/tokens.index-DF_07KEe.js +0 -10
- package/dist/server/_coffre/assets/users._user-DUzwkSKT.js +0 -10
- package/dist/server/_coffre/assets/users.index-BbuweTwH.js +0 -10
- package/src/components/syncs.tsx +0 -581
|
@@ -4,13 +4,19 @@ import {
|
|
|
4
4
|
useEffect,
|
|
5
5
|
useRef,
|
|
6
6
|
useState,
|
|
7
|
-
type ComponentProps,
|
|
8
7
|
type InputHTMLAttributes,
|
|
9
8
|
} from 'react';
|
|
10
|
-
import {
|
|
9
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
10
|
+
import { createFileRoute, Link } from '@tanstack/react-router';
|
|
11
|
+
import { useShell } from '../lib/use-shell';
|
|
11
12
|
import { DropdownMenu } from 'radix-ui';
|
|
12
13
|
import { toast } from 'sonner';
|
|
13
|
-
import { failureMessage,
|
|
14
|
+
import { failureMessage, useCoffre } from '../lib/coffre';
|
|
15
|
+
import { archiveSecret, restoreSecret, saveSecrets, UnsavedEdits } from '../lib/changes';
|
|
16
|
+
import type { ItemStatus } from '../lib/optimistic';
|
|
17
|
+
import { affects, keys as queryKeys, queries } from '../lib/queries';
|
|
18
|
+
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
19
|
+
import { RowFailure, RowPending, rowClass } from '../components/row-state';
|
|
14
20
|
import { useAction } from '../lib/use-action';
|
|
15
21
|
import type {
|
|
16
22
|
ImportPlanEntry,
|
|
@@ -21,7 +27,6 @@ import type {
|
|
|
21
27
|
} from '../shared/models';
|
|
22
28
|
import { canRevealSecrets } from '../lib/capabilities';
|
|
23
29
|
import {
|
|
24
|
-
applySecretEditBatch,
|
|
25
30
|
hasSecretEditConflict,
|
|
26
31
|
secretChangeFor,
|
|
27
32
|
type SecretChange,
|
|
@@ -43,7 +48,6 @@ import {
|
|
|
43
48
|
} from '../components/ui';
|
|
44
49
|
import { Card, ClosedDoor, PageHeader } from '../components/page';
|
|
45
50
|
import { SecretReadOnly } from '../components/affordances';
|
|
46
|
-
import { Syncs } from '../components/syncs';
|
|
47
51
|
import {
|
|
48
52
|
AlertCircle,
|
|
49
53
|
Archive,
|
|
@@ -78,20 +82,14 @@ export const Route = createFileRoute('/projects/$project/$environment')({
|
|
|
78
82
|
validateSearch: (search: Record<string, unknown>): { filter?: string } => ({
|
|
79
83
|
filter: typeof search.filter === 'string' && search.filter !== '' ? search.filter : undefined,
|
|
80
84
|
}),
|
|
81
|
-
loader:
|
|
82
|
-
|
|
83
|
-
const [keys, syncs] = await Promise.all([
|
|
84
|
-
uiResult(() => client.secrets.list(path)),
|
|
85
|
-
uiResult(() => client.syncs.list(path)),
|
|
86
|
-
]);
|
|
87
|
-
return { keys, syncs };
|
|
88
|
-
},
|
|
85
|
+
loader: ({ context: { client, queryClient }, params }) =>
|
|
86
|
+
queryClient.fetchQuery(queries.secrets(client, params)),
|
|
89
87
|
component: EnvironmentPage,
|
|
90
88
|
});
|
|
91
89
|
|
|
92
90
|
function EnvironmentPage() {
|
|
93
|
-
const { keys: result, syncs } = Route.useLoaderData();
|
|
94
91
|
const { project, environment } = Route.useParams();
|
|
92
|
+
const { data: result } = useSuspenseQuery(queries.secrets(useCoffre(), { project, environment }));
|
|
95
93
|
|
|
96
94
|
if (!result.ok) {
|
|
97
95
|
return (
|
|
@@ -124,7 +122,6 @@ function EnvironmentPage() {
|
|
|
124
122
|
environment={environment}
|
|
125
123
|
permissions={result.permissions}
|
|
126
124
|
keys={result.keys}
|
|
127
|
-
syncs={syncs}
|
|
128
125
|
/>
|
|
129
126
|
);
|
|
130
127
|
}
|
|
@@ -136,23 +133,23 @@ function EnvironmentLedger({
|
|
|
136
133
|
environment,
|
|
137
134
|
permissions,
|
|
138
135
|
keys,
|
|
139
|
-
syncs,
|
|
140
136
|
}: {
|
|
141
137
|
project: string;
|
|
142
138
|
environment: string;
|
|
143
139
|
permissions: Permission[];
|
|
144
140
|
keys: SecretKey[];
|
|
145
|
-
syncs: ComponentProps<typeof Syncs>['result'];
|
|
146
141
|
}) {
|
|
147
|
-
const router = useRouter();
|
|
148
142
|
const coffre = useCoffre();
|
|
149
|
-
const
|
|
143
|
+
const { principal } = useShell();
|
|
144
|
+
const save = useChange(saveSecrets(coffre, { project, environment }, principal?.id ?? null));
|
|
145
|
+
const restore = useChange(restoreSecret(coffre, { project, environment }));
|
|
146
|
+
const archive = useChange(archiveSecret(coffre, { project, environment }));
|
|
147
|
+
const { status, dismiss } = useChangeStatus(queryKeys.secrets({ project, environment }));
|
|
150
148
|
const [drafts, setDrafts] = useState<SecretDraft[]>([]);
|
|
151
149
|
const [changes, setChanges] = useState<Record<string, SecretChange>>({});
|
|
152
150
|
// Rows opened for editing that may not have changed yet. A row with a
|
|
153
151
|
// pending change is in edit mode whether or not it is listed here.
|
|
154
152
|
const [editing, setEditing] = useState<ReadonlySet<string>>(() => new Set());
|
|
155
|
-
const [saving, setSaving] = useState(false);
|
|
156
153
|
const [saveError, setSaveError] = useState<string | null>(null);
|
|
157
154
|
const [query, setQuery] = useState(Route.useSearch().filter ?? '');
|
|
158
155
|
const nextDraftId = useRef(0);
|
|
@@ -223,68 +220,53 @@ function EnvironmentLedger({
|
|
|
223
220
|
setChanges({});
|
|
224
221
|
setEditing(new Set());
|
|
225
222
|
setSaveError(null);
|
|
223
|
+
// A refused save, given up: its rows stop saying so.
|
|
224
|
+
for (const entry of keys) {
|
|
225
|
+
const state = status(entry.key);
|
|
226
|
+
if (state.state === 'failed') dismiss(state.mutationId);
|
|
227
|
+
}
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
/**
|
|
229
|
-
* Write every pending edit: renames one by one, then the
|
|
230
|
-
* that lands whole or not at all
|
|
231
|
-
*
|
|
231
|
+
* Write every pending edit (`saveSecrets`): renames one by one, then the
|
|
232
|
+
* rest as one patch that lands whole or not at all. The edits show in the
|
|
233
|
+
* list at once, each row marked as saving; whatever did not land comes
|
|
234
|
+
* back as pending, so pressing save again retries exactly that, and the
|
|
235
|
+
* save bar says why.
|
|
232
236
|
*/
|
|
233
|
-
|
|
234
|
-
if (!ready
|
|
235
|
-
|
|
237
|
+
function saveChanges() {
|
|
238
|
+
if (!ready) return;
|
|
239
|
+
const batch = { active, drafts, changes };
|
|
240
|
+
setDrafts([]);
|
|
241
|
+
setChanges({});
|
|
242
|
+
setEditing(new Set());
|
|
236
243
|
setSaveError(null);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
try {
|
|
244
|
-
await coffre.secrets.rename(`${place}/${key}`, nextKey);
|
|
245
|
-
} catch (error) {
|
|
246
|
-
// A refused rename names the key it stopped at.
|
|
247
|
-
throw new Refusal(`${key}: ${failureMessage(error)}`);
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
write: async (patch) => {
|
|
251
|
-
try {
|
|
252
|
-
await coffre.secrets.set(place, patch);
|
|
253
|
-
} catch (error) {
|
|
254
|
-
throw new Refusal(failureMessage(error));
|
|
255
|
-
}
|
|
256
|
-
},
|
|
244
|
+
save(batch, {
|
|
245
|
+
onError: (error) => {
|
|
246
|
+
const left = error instanceof UnsavedEdits ? error.outcome : batch;
|
|
247
|
+
setDrafts(left.drafts);
|
|
248
|
+
setChanges(left.changes);
|
|
249
|
+
setSaveError(failureMessage(error));
|
|
257
250
|
},
|
|
258
251
|
});
|
|
252
|
+
}
|
|
259
253
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
toast.success(`Saved ${pendingCount} change${pendingCount === 1 ? '' : 's'}`);
|
|
277
|
-
} else {
|
|
278
|
-
const message =
|
|
279
|
-
outcome.error instanceof Error ? outcome.error.message : 'The request could not be sent.';
|
|
280
|
-
// Only renames can have landed before a failure: the patch is all or nothing.
|
|
281
|
-
setSaveError(
|
|
282
|
-
outcome.applied === 0
|
|
283
|
-
? message
|
|
284
|
-
: `${message} The renames before it were saved; nothing else was, and the rest is ready to retry.`,
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
setSaving(false);
|
|
254
|
+
/**
|
|
255
|
+
* Bring an archived secret back: in the list at once, as saving. Restoring
|
|
256
|
+
* is fully reversible, so it gets an undo rather than a confirmation
|
|
257
|
+
* dialog in front of it. Asked here, not by its row, which leaves the
|
|
258
|
+
* Archived list as soon as it is restored.
|
|
259
|
+
*/
|
|
260
|
+
function restoreSecretKey(key: string) {
|
|
261
|
+
restore(
|
|
262
|
+
{ key },
|
|
263
|
+
{
|
|
264
|
+
onSuccess: () =>
|
|
265
|
+
toast.success(`${key} restored`, {
|
|
266
|
+
action: { label: 'Undo', onClick: () => archive({ key }) },
|
|
267
|
+
}),
|
|
268
|
+
},
|
|
269
|
+
);
|
|
288
270
|
}
|
|
289
271
|
|
|
290
272
|
// Cmd/Ctrl+Enter saves from anywhere on the page while edits are pending.
|
|
@@ -295,7 +277,7 @@ function EnvironmentLedger({
|
|
|
295
277
|
function onKeyDown(event: KeyboardEvent) {
|
|
296
278
|
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
|
|
297
279
|
event.preventDefault();
|
|
298
|
-
|
|
280
|
+
saveRef.current();
|
|
299
281
|
}
|
|
300
282
|
}
|
|
301
283
|
document.addEventListener('keydown', onKeyDown);
|
|
@@ -346,7 +328,7 @@ function EnvironmentLedger({
|
|
|
346
328
|
<>
|
|
347
329
|
{canWrite && canReveal && <ImportEnv project={project} environment={environment} />}
|
|
348
330
|
{canWrite && (
|
|
349
|
-
<button className="btn btn-primary" onClick={addDraft}
|
|
331
|
+
<button className="btn btn-primary" onClick={addDraft}>
|
|
350
332
|
<Plus size={14} />
|
|
351
333
|
New secret
|
|
352
334
|
</button>
|
|
@@ -449,7 +431,7 @@ function EnvironmentLedger({
|
|
|
449
431
|
existingVersion={
|
|
450
432
|
keys.find((entry) => entry.key === draft.key.trim())?.version ?? null
|
|
451
433
|
}
|
|
452
|
-
disabled={
|
|
434
|
+
disabled={false}
|
|
453
435
|
onChange={(patch) =>
|
|
454
436
|
setDrafts((rows) =>
|
|
455
437
|
rows.map((row) => (row.id === draft.id ? { ...row, ...patch } : row)),
|
|
@@ -461,6 +443,7 @@ function EnvironmentLedger({
|
|
|
461
443
|
|
|
462
444
|
{listed.map((entry) => {
|
|
463
445
|
const change = secretChangeFor(changes, entry.key);
|
|
446
|
+
const state = status(entry.key);
|
|
464
447
|
return (
|
|
465
448
|
<SecretRow
|
|
466
449
|
key={entry.key}
|
|
@@ -476,7 +459,9 @@ function EnvironmentLedger({
|
|
|
476
459
|
canWrite={canWrite}
|
|
477
460
|
canArchive={canArchive}
|
|
478
461
|
canReveal={canReveal}
|
|
479
|
-
|
|
462
|
+
status={state}
|
|
463
|
+
// Not while its save is on its way.
|
|
464
|
+
disabled={state.state === 'pending'}
|
|
480
465
|
columns={columns}
|
|
481
466
|
onEdit={() => setEditing((current) => new Set(current).add(entry.key))}
|
|
482
467
|
onPatch={(patch) => patchChange(entry, patch)}
|
|
@@ -509,13 +494,6 @@ function EnvironmentLedger({
|
|
|
509
494
|
)}
|
|
510
495
|
</section>
|
|
511
496
|
|
|
512
|
-
<Syncs
|
|
513
|
-
project={project}
|
|
514
|
-
environment={environment}
|
|
515
|
-
result={syncs}
|
|
516
|
-
canRun={canWrite || permissions.includes('environment.manage')}
|
|
517
|
-
/>
|
|
518
|
-
|
|
519
497
|
{archived.length > 0 && (
|
|
520
498
|
<Card
|
|
521
499
|
labelledBy="archived-secrets"
|
|
@@ -565,6 +543,9 @@ function EnvironmentLedger({
|
|
|
565
543
|
entry={entry}
|
|
566
544
|
canArchive={canArchive}
|
|
567
545
|
canReveal={canReveal}
|
|
546
|
+
status={status(entry.key)}
|
|
547
|
+
onRestore={() => restoreSecretKey(entry.key)}
|
|
548
|
+
onDismiss={dismiss}
|
|
568
549
|
/>
|
|
569
550
|
))}
|
|
570
551
|
</tbody>
|
|
@@ -590,17 +571,16 @@ function EnvironmentLedger({
|
|
|
590
571
|
{pending.length > 3 && ` · and ${pending.length - 3} more`}
|
|
591
572
|
</span>
|
|
592
573
|
<div className="savebar-actions">
|
|
593
|
-
<button className="btn btn-sm" onClick={discardAll}
|
|
574
|
+
<button className="btn btn-sm" onClick={discardAll}>
|
|
594
575
|
Discard
|
|
595
576
|
</button>
|
|
596
577
|
<button
|
|
597
578
|
className="btn btn-sm btn-primary"
|
|
598
|
-
onClick={
|
|
599
|
-
disabled={
|
|
579
|
+
onClick={saveChanges}
|
|
580
|
+
disabled={!ready}
|
|
600
581
|
title="Save (⌘ Enter or Ctrl Enter)"
|
|
601
582
|
aria-keyshortcuts="Meta+Enter Control+Enter"
|
|
602
583
|
>
|
|
603
|
-
{saving && <Spinner size={13} />}
|
|
604
584
|
Save {pendingCount === 1 ? 'change' : `${pendingCount} changes`}
|
|
605
585
|
</button>
|
|
606
586
|
</div>
|
|
@@ -619,7 +599,7 @@ function EnvironmentLedger({
|
|
|
619
599
|
|
|
620
600
|
/** The display name sits beside the slug; it comes from the shell's project tree. */
|
|
621
601
|
function EnvironmentName({ project, environment }: { project: string; environment: string }) {
|
|
622
|
-
const { projects } =
|
|
602
|
+
const { projects } = useShell();
|
|
623
603
|
const name = projects
|
|
624
604
|
.find((entry) => entry.slug === project)
|
|
625
605
|
?.environments.find((entry) => entry.slug === environment)?.name;
|
|
@@ -729,6 +709,7 @@ function SecretRow({
|
|
|
729
709
|
canWrite,
|
|
730
710
|
canArchive,
|
|
731
711
|
canReveal,
|
|
712
|
+
status,
|
|
732
713
|
disabled,
|
|
733
714
|
columns,
|
|
734
715
|
onEdit,
|
|
@@ -745,6 +726,8 @@ function SecretRow({
|
|
|
745
726
|
canWrite: boolean;
|
|
746
727
|
canArchive: boolean;
|
|
747
728
|
canReveal: boolean;
|
|
729
|
+
/** A save of this row on its way, or refused. */
|
|
730
|
+
status: ItemStatus;
|
|
748
731
|
disabled: boolean;
|
|
749
732
|
columns: number;
|
|
750
733
|
onEdit: () => void;
|
|
@@ -825,7 +808,7 @@ function SecretRow({
|
|
|
825
808
|
|
|
826
809
|
return (
|
|
827
810
|
<>
|
|
828
|
-
<tr className={`secret-row${state}`}>
|
|
811
|
+
<tr className={`secret-row${state} ${rowClass(status)}`}>
|
|
829
812
|
<td className="n">{number}</td>
|
|
830
813
|
<td className="cell-key" data-label="Key">
|
|
831
814
|
{editing && canWrite ? (
|
|
@@ -934,117 +917,121 @@ function SecretRow({
|
|
|
934
917
|
</td>
|
|
935
918
|
|
|
936
919
|
<td className="col-actions">
|
|
937
|
-
|
|
938
|
-
{
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
disabled={revealing}
|
|
972
|
-
aria-label={`${shown === null ? 'Reveal' : 'Hide'} ${entry.key}`}
|
|
973
|
-
>
|
|
974
|
-
{revealing ? (
|
|
975
|
-
<Spinner size={13} />
|
|
976
|
-
) : shown === null ? (
|
|
977
|
-
<Eye size={15} />
|
|
978
|
-
) : (
|
|
979
|
-
<EyeOff size={15} />
|
|
980
|
-
)}
|
|
981
|
-
</button>
|
|
982
|
-
</Tip>
|
|
983
|
-
</SecretReadOnly>
|
|
984
|
-
{canWrite && (
|
|
985
|
-
<Tip label="Edit">
|
|
986
|
-
<button
|
|
987
|
-
className="act act-icon"
|
|
988
|
-
onClick={() => {
|
|
989
|
-
// A value already revealed is already on the record, so
|
|
990
|
-
// it becomes the starting point instead of being thrown
|
|
991
|
-
// away and read again.
|
|
992
|
-
if (shown !== null) setBase(shown);
|
|
993
|
-
setReveal(null);
|
|
994
|
-
onEdit();
|
|
995
|
-
}}
|
|
996
|
-
disabled={disabled}
|
|
997
|
-
aria-label={`Edit ${entry.key}`}
|
|
998
|
-
>
|
|
999
|
-
<Pencil size={14} />
|
|
1000
|
-
</button>
|
|
1001
|
-
</Tip>
|
|
1002
|
-
)}
|
|
1003
|
-
{(canReveal || canArchive) && (
|
|
1004
|
-
<DropdownMenu.Root>
|
|
1005
|
-
<DropdownMenu.Trigger asChild>
|
|
920
|
+
{status.state === 'pending' ? (
|
|
921
|
+
<RowPending status={status} />
|
|
922
|
+
) : (
|
|
923
|
+
<div className="acts">
|
|
924
|
+
{leaving ? (
|
|
925
|
+
<Tip label="Keep">
|
|
926
|
+
<button
|
|
927
|
+
className="act act-icon act-quiet"
|
|
928
|
+
onClick={onUndo}
|
|
929
|
+
disabled={disabled}
|
|
930
|
+
aria-label={`Keep ${entry.key}`}
|
|
931
|
+
>
|
|
932
|
+
<RotateBack size={14} />
|
|
933
|
+
</button>
|
|
934
|
+
</Tip>
|
|
935
|
+
) : editing ? (
|
|
936
|
+
<Tip label={renamed || valueChanged ? 'Undo changes' : 'Cancel'}>
|
|
937
|
+
<button
|
|
938
|
+
className="act act-icon act-quiet"
|
|
939
|
+
onClick={onUndo}
|
|
940
|
+
disabled={disabled}
|
|
941
|
+
aria-label={`${renamed || valueChanged ? 'Undo changes to' : 'Stop editing'} ${entry.key}`}
|
|
942
|
+
>
|
|
943
|
+
{renamed || valueChanged ? <RotateBack size={14} /> : <X size={15} />}
|
|
944
|
+
</button>
|
|
945
|
+
</Tip>
|
|
946
|
+
) : (
|
|
947
|
+
<>
|
|
948
|
+
{/* Copy comes in to the left, so Hide stays where Reveal was clicked. */}
|
|
949
|
+
{shown !== null && (
|
|
950
|
+
<CopyButton variant="act" value={shown.value} label={`Copy ${entry.key}`} />
|
|
951
|
+
)}
|
|
952
|
+
<SecretReadOnly canReveal={canReveal}>
|
|
953
|
+
<Tip label={shown === null ? 'Reveal' : 'Hide'}>
|
|
1006
954
|
<button
|
|
1007
|
-
className="act act-icon act-
|
|
1008
|
-
|
|
955
|
+
className="act act-icon act-accent"
|
|
956
|
+
onClick={toggleReveal}
|
|
957
|
+
disabled={revealing}
|
|
958
|
+
aria-label={`${shown === null ? 'Reveal' : 'Hide'} ${entry.key}`}
|
|
959
|
+
>
|
|
960
|
+
{revealing ? (
|
|
961
|
+
<Spinner size={13} />
|
|
962
|
+
) : shown === null ? (
|
|
963
|
+
<Eye size={15} />
|
|
964
|
+
) : (
|
|
965
|
+
<EyeOff size={15} />
|
|
966
|
+
)}
|
|
967
|
+
</button>
|
|
968
|
+
</Tip>
|
|
969
|
+
</SecretReadOnly>
|
|
970
|
+
{canWrite && (
|
|
971
|
+
<Tip label="Edit">
|
|
972
|
+
<button
|
|
973
|
+
className="act act-icon"
|
|
974
|
+
onClick={() => {
|
|
975
|
+
// A value already revealed is already on the record, so
|
|
976
|
+
// it becomes the starting point instead of being thrown
|
|
977
|
+
// away and read again.
|
|
978
|
+
if (shown !== null) setBase(shown);
|
|
979
|
+
setReveal(null);
|
|
980
|
+
onEdit();
|
|
981
|
+
}}
|
|
1009
982
|
disabled={disabled}
|
|
983
|
+
aria-label={`Edit ${entry.key}`}
|
|
1010
984
|
>
|
|
1011
|
-
<
|
|
985
|
+
<Pencil size={14} />
|
|
1012
986
|
</button>
|
|
1013
|
-
</
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
</
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
987
|
+
</Tip>
|
|
988
|
+
)}
|
|
989
|
+
{(canReveal || canArchive) && (
|
|
990
|
+
<DropdownMenu.Root>
|
|
991
|
+
<DropdownMenu.Trigger asChild>
|
|
992
|
+
<button
|
|
993
|
+
className="act act-icon act-quiet"
|
|
994
|
+
aria-label={`More for ${entry.key}`}
|
|
995
|
+
disabled={disabled}
|
|
996
|
+
>
|
|
997
|
+
<MoreHorizontal size={16} />
|
|
998
|
+
</button>
|
|
999
|
+
</DropdownMenu.Trigger>
|
|
1000
|
+
<DropdownMenu.Portal>
|
|
1001
|
+
<DropdownMenu.Content className="menu" sideOffset={6} align="end">
|
|
1002
|
+
<SecretReadOnly canReveal={canReveal}>
|
|
1028
1003
|
<DropdownMenu.Item
|
|
1029
|
-
className="menu-item
|
|
1030
|
-
onSelect={() =>
|
|
1031
|
-
setReveal(null);
|
|
1032
|
-
onMarkArchive();
|
|
1033
|
-
}}
|
|
1004
|
+
className="menu-item"
|
|
1005
|
+
onSelect={() => setHistoryOpen((open) => !open)}
|
|
1034
1006
|
>
|
|
1035
|
-
<
|
|
1036
|
-
|
|
1037
|
-
<span className="menu-hint">on save</span>
|
|
1007
|
+
<History size={14} />
|
|
1008
|
+
{historyOpen ? 'Hide history' : 'Version history'}
|
|
1038
1009
|
</DropdownMenu.Item>
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1010
|
+
</SecretReadOnly>
|
|
1011
|
+
{canArchive && (
|
|
1012
|
+
<>
|
|
1013
|
+
{canReveal && <DropdownMenu.Separator className="menu-sep" />}
|
|
1014
|
+
<DropdownMenu.Item
|
|
1015
|
+
className="menu-item menu-item-danger"
|
|
1016
|
+
onSelect={() => {
|
|
1017
|
+
setReveal(null);
|
|
1018
|
+
onMarkArchive();
|
|
1019
|
+
}}
|
|
1020
|
+
>
|
|
1021
|
+
<Archive size={14} />
|
|
1022
|
+
Archive
|
|
1023
|
+
<span className="menu-hint">on save</span>
|
|
1024
|
+
</DropdownMenu.Item>
|
|
1025
|
+
</>
|
|
1026
|
+
)}
|
|
1027
|
+
</DropdownMenu.Content>
|
|
1028
|
+
</DropdownMenu.Portal>
|
|
1029
|
+
</DropdownMenu.Root>
|
|
1030
|
+
)}
|
|
1031
|
+
</>
|
|
1032
|
+
)}
|
|
1033
|
+
</div>
|
|
1034
|
+
)}
|
|
1048
1035
|
</td>
|
|
1049
1036
|
</tr>
|
|
1050
1037
|
|
|
@@ -1213,6 +1200,9 @@ function ArchivedRow({
|
|
|
1213
1200
|
entry,
|
|
1214
1201
|
canArchive,
|
|
1215
1202
|
canReveal,
|
|
1203
|
+
status: state,
|
|
1204
|
+
onRestore,
|
|
1205
|
+
onDismiss,
|
|
1216
1206
|
}: {
|
|
1217
1207
|
number: number;
|
|
1218
1208
|
project: string;
|
|
@@ -1220,26 +1210,15 @@ function ArchivedRow({
|
|
|
1220
1210
|
entry: SecretKey;
|
|
1221
1211
|
canArchive: boolean;
|
|
1222
1212
|
canReveal: boolean;
|
|
1213
|
+
status: ItemStatus;
|
|
1214
|
+
onRestore: () => void;
|
|
1215
|
+
onDismiss: (mutationId: number) => void;
|
|
1223
1216
|
}) {
|
|
1224
1217
|
const [historyOpen, setHistoryOpen] = useState(false);
|
|
1225
|
-
const coffre = useCoffre();
|
|
1226
|
-
const { pending, error, run } = useAction();
|
|
1227
|
-
|
|
1228
|
-
function setArchived(archived: boolean) {
|
|
1229
|
-
run(
|
|
1230
|
-
() => coffre.secrets.update(`${project}/${environment}/${entry.key}`, { archived }),
|
|
1231
|
-
() =>
|
|
1232
|
-
// Restoring is fully reversible, so it gets an undo rather than a
|
|
1233
|
-
// confirmation dialog in front of it.
|
|
1234
|
-
toast.success(archived ? `${entry.key} archived` : `${entry.key} restored`, {
|
|
1235
|
-
action: { label: 'Undo', onClick: () => setArchived(!archived) },
|
|
1236
|
-
}),
|
|
1237
|
-
);
|
|
1238
|
-
}
|
|
1239
1218
|
|
|
1240
1219
|
return (
|
|
1241
1220
|
<>
|
|
1242
|
-
<tr className=
|
|
1221
|
+
<tr className={`secret-row is-archived ${rowClass(state)}`}>
|
|
1243
1222
|
<td className="n">{number}</td>
|
|
1244
1223
|
<td className="cell-key" data-label="Key">
|
|
1245
1224
|
{breakAfterUnderscores(entry.key)}
|
|
@@ -1264,18 +1243,16 @@ function ArchivedRow({
|
|
|
1264
1243
|
</button>
|
|
1265
1244
|
</Tip>
|
|
1266
1245
|
</SecretReadOnly>
|
|
1267
|
-
{canArchive &&
|
|
1268
|
-
|
|
1269
|
-
<
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
</Tip>
|
|
1278
|
-
)}
|
|
1246
|
+
{canArchive &&
|
|
1247
|
+
(state.state === 'pending' ? (
|
|
1248
|
+
<RowPending status={state} />
|
|
1249
|
+
) : (
|
|
1250
|
+
<Tip label="Restore">
|
|
1251
|
+
<button className="act act-icon" onClick={onRestore} aria-label={`Restore ${entry.key}`}>
|
|
1252
|
+
<RotateBack size={14} />
|
|
1253
|
+
</button>
|
|
1254
|
+
</Tip>
|
|
1255
|
+
))}
|
|
1279
1256
|
</div>
|
|
1280
1257
|
</td>
|
|
1281
1258
|
</tr>
|
|
@@ -1294,13 +1271,11 @@ function ArchivedRow({
|
|
|
1294
1271
|
</td>
|
|
1295
1272
|
</tr>
|
|
1296
1273
|
)}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
</tr>
|
|
1303
|
-
)}
|
|
1274
|
+
<RowFailure
|
|
1275
|
+
status={state}
|
|
1276
|
+
columns={5}
|
|
1277
|
+
onDismiss={() => state.state === 'failed' && onDismiss(state.mutationId)}
|
|
1278
|
+
/>
|
|
1304
1279
|
</>
|
|
1305
1280
|
);
|
|
1306
1281
|
}
|
|
@@ -1436,9 +1411,12 @@ function VersionHistory({
|
|
|
1436
1411
|
`${project}/${environment}/${secretKey}`,
|
|
1437
1412
|
version.version,
|
|
1438
1413
|
),
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1414
|
+
{
|
|
1415
|
+
affects: affects.secrets({ project, environment }),
|
|
1416
|
+
onSuccess: () => {
|
|
1417
|
+
onRolledBack();
|
|
1418
|
+
toast.success(`${secretKey} rolled back to v${version.version}`);
|
|
1419
|
+
},
|
|
1442
1420
|
},
|
|
1443
1421
|
)
|
|
1444
1422
|
}
|
|
@@ -1504,9 +1482,13 @@ function ImportEnv({ project, environment }: { project: string; environment: str
|
|
|
1504
1482
|
function preview() {
|
|
1505
1483
|
run(
|
|
1506
1484
|
() => planEnv(coffre, path, content),
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1485
|
+
{
|
|
1486
|
+
// A dry run: nothing changes.
|
|
1487
|
+
affects: [],
|
|
1488
|
+
onSuccess: (result) => {
|
|
1489
|
+
setProblems(result.problems);
|
|
1490
|
+
setPlan({ entries: result.plan, changes: result.changes });
|
|
1491
|
+
},
|
|
1510
1492
|
},
|
|
1511
1493
|
);
|
|
1512
1494
|
}
|
|
@@ -1516,9 +1498,12 @@ function ImportEnv({ project, environment }: { project: string; environment: str
|
|
|
1516
1498
|
const written = Object.keys(plan.changes).length;
|
|
1517
1499
|
run(
|
|
1518
1500
|
() => coffre.secrets.set(path, plan.changes),
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1501
|
+
{
|
|
1502
|
+
affects: affects.secrets({ project, environment }),
|
|
1503
|
+
onSuccess: () => {
|
|
1504
|
+
toast.success(`Imported ${written} change${written === 1 ? '' : 's'}`);
|
|
1505
|
+
close();
|
|
1506
|
+
},
|
|
1522
1507
|
},
|
|
1523
1508
|
);
|
|
1524
1509
|
}
|