@coffre/ui 0.1.9 → 0.1.11
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-BJAdDvZf.js +2 -0
- package/dist/client/_coffre/assets/account-D0jLpk5c.js +1 -0
- package/dist/client/_coffre/assets/affordances-Bq2-oUB5.js +1 -0
- package/dist/client/_coffre/assets/audit-C-pcBgKe.js +2 -0
- package/dist/client/_coffre/assets/audit-CHGlDeBB.js +1 -0
- package/dist/client/_coffre/assets/{auth.device--rDR2F8w.js → auth.device-BndOUjse.js} +1 -1
- package/dist/client/_coffre/assets/auth.device-CWHNQn9W.js +2 -0
- package/dist/client/_coffre/assets/directory-nDExpkAz.js +1 -0
- package/dist/client/_coffre/assets/dist-QVHMLatb.js +1 -0
- package/dist/client/_coffre/assets/globals-CKBoTlyH.css +1 -0
- package/dist/client/_coffre/assets/grants-CjoOnxzz.js +1 -0
- package/dist/client/_coffre/assets/icons-BQ27Ds9u.js +1 -0
- package/dist/client/_coffre/assets/index-CUGytaO3.js +12 -0
- package/dist/client/_coffre/assets/link-DP8SVWon.js +1 -0
- package/dist/client/_coffre/assets/login-CeaxDMcr.js +2 -0
- package/dist/client/_coffre/assets/login-DrMgvqZn.js +1 -0
- package/dist/client/_coffre/assets/offboarding-CNr_1tnl.js +1 -0
- package/dist/client/_coffre/assets/page-CGmvjSy4.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-ClBkJ19f.js +1 -0
- package/dist/client/_coffre/assets/principal-page-DNLb_q_e.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CHzbboGp.js +3 -0
- package/dist/client/_coffre/assets/projects._project._environment-DDxu_HHD.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-CIAsjvg6.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DZ9l6d-1.js +1 -0
- package/dist/client/_coffre/assets/projects.index-4eUXreE_.js +1 -0
- package/dist/client/_coffre/assets/row-state-ByET1OKX.js +1 -0
- package/dist/client/_coffre/assets/settings-D2zp1Ssu.js +1 -0
- package/dist/client/_coffre/assets/suspense-C7KwSnTG.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-DWmbqzNk.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-Dui_4KfS.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-CSi5Wxwf.js +1 -0
- package/dist/client/_coffre/assets/ui-BdipqGpP.js +46 -0
- package/dist/client/_coffre/assets/unregistered-CA7B4C1m.js +1 -0
- package/dist/client/_coffre/assets/use-action-DRm9yVhV.js +1 -0
- package/dist/client/_coffre/assets/use-change-BRRMJocl.js +1 -0
- package/dist/client/_coffre/assets/use-shell-BMGlJ25Q.js +1 -0
- package/dist/client/_coffre/assets/useQuery-D__2KBOs.js +1 -0
- package/dist/client/_coffre/assets/useSuspenseQuery-CSXyDALB.js +1 -0
- package/dist/client/_coffre/assets/users._user-BkNrX7Qf.js +1 -0
- package/dist/client/_coffre/assets/users._user-jbSvtdOg.js +2 -0
- package/dist/client/_coffre/assets/users.index-CKnQ1G76.js +1 -0
- package/dist/server/.vite/manifest.json +343 -246
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-Dx-c3XVk.js +162 -0
- package/dist/server/_coffre/assets/{account-CZgVVZTf.js → account-BocTPU1J.js} +150 -117
- package/dist/server/_coffre/assets/{account-D7-ZAE2T.js → account-CL8hOGhO.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-BEbhtsEp.js → audit-Bcka4vA6.js} +46 -16
- package/dist/server/_coffre/assets/audit-CSRQYIhu.js +31 -0
- package/dist/server/_coffre/assets/{auth.device-w9N3FlNk.js → auth.device-CMcUISZY.js} +7 -5
- package/dist/server/_coffre/assets/{auth.device-CMR3csAI.js → auth.device-DqO0T-rU.js} +5 -5
- package/dist/server/_coffre/assets/{directory-Dr5X9TB5.js → directory-CyYx6Jx1.js} +87 -112
- package/dist/server/_coffre/assets/{use-action-DQUmeH-5.js → dist-CnnV3t2g.js} +3 -48
- package/dist/server/_coffre/assets/globals-CKBoTlyH.css +1 -0
- package/dist/server/_coffre/assets/grants-CRijabX0.js +158 -0
- package/dist/server/_coffre/assets/{page-BdnhpwvH.js → icons-Dy-5ccDF.js} +3 -196
- 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-BI9tzJEy.js} +7 -5
- package/dist/server/_coffre/assets/{login-B2njIq_o.js → login-C-v88YwP.js} +2 -2
- package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +56 -0
- package/dist/server/_coffre/assets/{offboarding-DY5MarpG.js → offboarding-1H0LavTd.js} +6 -4
- package/dist/server/_coffre/assets/page-D_mO0-sn.js +3592 -0
- package/dist/server/_coffre/assets/{principal-page-SdG8_zcu.js → principal-page-DQDoXute.js} +51 -42
- package/dist/server/_coffre/assets/{projects._project._environment-CUS0VFUe.js → projects._project._environment-C-yVwC92.js} +168 -248
- package/dist/server/_coffre/assets/{projects._project._environment-BQIrmE3r.js → projects._project._environment-D_5R40of.js} +4 -11
- package/dist/server/_coffre/assets/{projects._project.index-D1NxvBtZ.js → projects._project.index-A2BImFIT.js} +134 -96
- package/dist/server/_coffre/assets/{projects._project.index-BjNdR4KC.js → projects._project.index-BPPKxKrt.js} +5 -4
- package/dist/server/_coffre/assets/{projects.index-BQDuuh6t.js → projects.index-543IsPzY.js} +62 -54
- package/dist/server/_coffre/assets/{react-dom-qCTiwGGR.js → react-dom-bBoJXlK2.js} +417 -51
- package/dist/server/_coffre/assets/{router-BUwZOXEH.js → router-CM3vK8QO.js} +376 -92
- package/dist/server/_coffre/assets/row-state-XBtDoIA4.js +117 -0
- package/dist/server/_coffre/assets/{settings-HOErM3pd.js → settings-BLVU74ym.js} +8 -6
- package/dist/server/_coffre/assets/suspense-CzYTwxOj.js +602 -0
- package/dist/server/_coffre/assets/tokens._token-B-hBgwBW.js +10 -0
- package/dist/server/_coffre/assets/{tokens._token-BZUArbzi.js → tokens._token-aubAUonP.js} +97 -79
- package/dist/server/_coffre/assets/{tokens.index-BReCgoV9.js → tokens.index-4D3jwp5v.js} +9 -6
- package/dist/server/_coffre/assets/{ui-D_slKpSF.js → ui-BI3Bf72q.js} +7 -836
- package/dist/server/_coffre/assets/{unregistered-Z17da4Rc.js → unregistered-CagDxMyw.js} +5 -3
- package/dist/server/_coffre/assets/use-action-tzBZvjjQ.js +47 -0
- package/dist/server/_coffre/assets/use-change-Dggqxy5y.js +1212 -0
- package/dist/server/_coffre/assets/use-shell-CwStDfzX.js +462 -0
- package/dist/server/_coffre/assets/useQuery-C6_dBjem.js +8 -0
- package/dist/server/_coffre/assets/{useStore-DWGPqzXR.js → useRouter-CaUSUNsw.js} +1 -420
- package/dist/server/_coffre/assets/useSuspenseQuery-BuapQt_P.js +117 -0
- package/dist/server/_coffre/assets/{users._user-DHTNhQ9o.js → users._user-137WNyxn.js} +4 -5
- package/dist/server/_coffre/assets/users._user-C252Iilj.js +10 -0
- package/dist/server/_coffre/assets/{users.index-Cfo3ODpX.js → users.index-DQHsfnal.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/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/components/syncs.tsx +42 -26
- package/src/lib/announce.ts +36 -0
- package/src/lib/changes.ts +498 -0
- package/src/lib/coffre.ts +3 -2
- package/src/lib/optimistic.ts +233 -0
- package/src/lib/queries.ts +393 -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 +226 -231
- package/src/routes/projects.$project.index.tsx +136 -118
- package/src/routes/projects.index.tsx +125 -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/styles/globals.css +78 -1
- package/dist/client/_coffre/assets/account-C3rBPdu6.js +0 -2
- package/dist/client/_coffre/assets/account-J194gi6l.js +0 -1
- package/dist/client/_coffre/assets/affordances-CmoY-8Xf.js +0 -1
- package/dist/client/_coffre/assets/audit-BtI9em7Q.js +0 -2
- package/dist/client/_coffre/assets/audit-jURfT8Km.js +0 -1
- package/dist/client/_coffre/assets/auth.device-viDUwZRT.js +0 -2
- package/dist/client/_coffre/assets/coffre-CXkp3Efg.js +0 -1
- package/dist/client/_coffre/assets/directory-PEjdb8PS.js +0 -1
- package/dist/client/_coffre/assets/globals-Bh2x1gBM.css +0 -1
- package/dist/client/_coffre/assets/grants-4mSkXPU4.js +0 -1
- package/dist/client/_coffre/assets/index-CD7bvUCb.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-DQ-56W0H.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-DjH1cUyz.js +0 -1
- package/dist/client/_coffre/assets/projects._project._environment-BZnNvENc.js +0 -3
- package/dist/client/_coffre/assets/projects._project._environment-CLUpTvi-.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-CWXRo307.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-Dzgf95zv.js +0 -1
- package/dist/client/_coffre/assets/projects.index-BG8W91BX.js +0 -2
- package/dist/client/_coffre/assets/projects.index-N_kCFBMq.js +0 -1
- package/dist/client/_coffre/assets/settings-CNIY0--5.js +0 -1
- package/dist/client/_coffre/assets/settings-EimGqlQL.js +0 -2
- package/dist/client/_coffre/assets/tokens._token-CkU4dCwo.js +0 -1
- package/dist/client/_coffre/assets/tokens._token-Df2R8TF_.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-CSf5Mlz8.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-DtiWrKVq.js +0 -1
- package/dist/client/_coffre/assets/unregistered-D5go1AfR.js +0 -1
- package/dist/client/_coffre/assets/use-action-CUvWPRTx.js +0 -1
- package/dist/client/_coffre/assets/users._user-CImGVpYj.js +0 -1
- package/dist/client/_coffre/assets/users._user-D0JK911L.js +0 -2
- package/dist/client/_coffre/assets/users.index-B-7o0KBD.js +0 -1
- package/dist/client/_coffre/assets/users.index-BoFWF3mF.js +0 -2
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-CrnrBINO.js +0 -133
- package/dist/server/_coffre/assets/audit-wjpo1BWg.js +0 -74
- package/dist/server/_coffre/assets/coffre-DMs96kfX.js +0 -280
- package/dist/server/_coffre/assets/globals-Bh2x1gBM.css +0 -1
- package/dist/server/_coffre/assets/grants-C6UmWE8b.js +0 -243
- package/dist/server/_coffre/assets/projects.index-ha7jO4nC.js +0 -54
- package/dist/server/_coffre/assets/settings-Cy__khNA.js +0 -18
- package/dist/server/_coffre/assets/tokens._token-CmpmtfB_.js +0 -18
- package/dist/server/_coffre/assets/tokens.index-B5-4dD4C.js +0 -10
- package/dist/server/_coffre/assets/users._user-BKdSQhIg.js +0 -10
- package/dist/server/_coffre/assets/users.index-dMn0tlmc.js +0 -10
|
@@ -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,
|
|
@@ -78,20 +83,17 @@ export const Route = createFileRoute('/projects/$project/$environment')({
|
|
|
78
83
|
validateSearch: (search: Record<string, unknown>): { filter?: string } => ({
|
|
79
84
|
filter: typeof search.filter === 'string' && search.filter !== '' ? search.filter : undefined,
|
|
80
85
|
}),
|
|
81
|
-
loader:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
]);
|
|
87
|
-
return { keys, syncs };
|
|
88
|
-
},
|
|
86
|
+
loader: ({ context: { client, queryClient }, params }) =>
|
|
87
|
+
Promise.all([
|
|
88
|
+
queryClient.fetchQuery(queries.secrets(client, params)),
|
|
89
|
+
queryClient.fetchQuery(queries.syncs(client, params)),
|
|
90
|
+
]),
|
|
89
91
|
component: EnvironmentPage,
|
|
90
92
|
});
|
|
91
93
|
|
|
92
94
|
function EnvironmentPage() {
|
|
93
|
-
const { keys: result, syncs } = Route.useLoaderData();
|
|
94
95
|
const { project, environment } = Route.useParams();
|
|
96
|
+
const { data: result } = useSuspenseQuery(queries.secrets(useCoffre(), { project, environment }));
|
|
95
97
|
|
|
96
98
|
if (!result.ok) {
|
|
97
99
|
return (
|
|
@@ -124,7 +126,6 @@ function EnvironmentPage() {
|
|
|
124
126
|
environment={environment}
|
|
125
127
|
permissions={result.permissions}
|
|
126
128
|
keys={result.keys}
|
|
127
|
-
syncs={syncs}
|
|
128
129
|
/>
|
|
129
130
|
);
|
|
130
131
|
}
|
|
@@ -136,23 +137,23 @@ function EnvironmentLedger({
|
|
|
136
137
|
environment,
|
|
137
138
|
permissions,
|
|
138
139
|
keys,
|
|
139
|
-
syncs,
|
|
140
140
|
}: {
|
|
141
141
|
project: string;
|
|
142
142
|
environment: string;
|
|
143
143
|
permissions: Permission[];
|
|
144
144
|
keys: SecretKey[];
|
|
145
|
-
syncs: ComponentProps<typeof Syncs>['result'];
|
|
146
145
|
}) {
|
|
147
|
-
const router = useRouter();
|
|
148
146
|
const coffre = useCoffre();
|
|
149
|
-
const
|
|
147
|
+
const { principal } = useShell();
|
|
148
|
+
const save = useChange(saveSecrets(coffre, { project, environment }, principal?.id ?? null));
|
|
149
|
+
const restore = useChange(restoreSecret(coffre, { project, environment }));
|
|
150
|
+
const archive = useChange(archiveSecret(coffre, { project, environment }));
|
|
151
|
+
const { status, dismiss } = useChangeStatus(queryKeys.secrets({ project, environment }));
|
|
150
152
|
const [drafts, setDrafts] = useState<SecretDraft[]>([]);
|
|
151
153
|
const [changes, setChanges] = useState<Record<string, SecretChange>>({});
|
|
152
154
|
// Rows opened for editing that may not have changed yet. A row with a
|
|
153
155
|
// pending change is in edit mode whether or not it is listed here.
|
|
154
156
|
const [editing, setEditing] = useState<ReadonlySet<string>>(() => new Set());
|
|
155
|
-
const [saving, setSaving] = useState(false);
|
|
156
157
|
const [saveError, setSaveError] = useState<string | null>(null);
|
|
157
158
|
const [query, setQuery] = useState(Route.useSearch().filter ?? '');
|
|
158
159
|
const nextDraftId = useRef(0);
|
|
@@ -223,68 +224,53 @@ function EnvironmentLedger({
|
|
|
223
224
|
setChanges({});
|
|
224
225
|
setEditing(new Set());
|
|
225
226
|
setSaveError(null);
|
|
227
|
+
// A refused save, given up: its rows stop saying so.
|
|
228
|
+
for (const entry of keys) {
|
|
229
|
+
const state = status(entry.key);
|
|
230
|
+
if (state.state === 'failed') dismiss(state.mutationId);
|
|
231
|
+
}
|
|
226
232
|
}
|
|
227
233
|
|
|
228
234
|
/**
|
|
229
|
-
* Write every pending edit: renames one by one, then the
|
|
230
|
-
* that lands whole or not at all
|
|
231
|
-
*
|
|
235
|
+
* Write every pending edit (`saveSecrets`): renames one by one, then the
|
|
236
|
+
* rest as one patch that lands whole or not at all. The edits show in the
|
|
237
|
+
* list at once, each row marked as saving; whatever did not land comes
|
|
238
|
+
* back as pending, so pressing save again retries exactly that, and the
|
|
239
|
+
* save bar says why.
|
|
232
240
|
*/
|
|
233
|
-
|
|
234
|
-
if (!ready
|
|
235
|
-
|
|
241
|
+
function saveChanges() {
|
|
242
|
+
if (!ready) return;
|
|
243
|
+
const batch = { active, drafts, changes };
|
|
244
|
+
setDrafts([]);
|
|
245
|
+
setChanges({});
|
|
246
|
+
setEditing(new Set());
|
|
236
247
|
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
|
-
},
|
|
248
|
+
save(batch, {
|
|
249
|
+
onError: (error) => {
|
|
250
|
+
const left = error instanceof UnsavedEdits ? error.outcome : batch;
|
|
251
|
+
setDrafts(left.drafts);
|
|
252
|
+
setChanges(left.changes);
|
|
253
|
+
setSaveError(failureMessage(error));
|
|
257
254
|
},
|
|
258
255
|
});
|
|
256
|
+
}
|
|
259
257
|
|
|
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);
|
|
258
|
+
/**
|
|
259
|
+
* Bring an archived secret back: in the list at once, as saving. Restoring
|
|
260
|
+
* is fully reversible, so it gets an undo rather than a confirmation
|
|
261
|
+
* dialog in front of it. Asked here, not by its row, which leaves the
|
|
262
|
+
* Archived list as soon as it is restored.
|
|
263
|
+
*/
|
|
264
|
+
function restoreSecretKey(key: string) {
|
|
265
|
+
restore(
|
|
266
|
+
{ key },
|
|
267
|
+
{
|
|
268
|
+
onSuccess: () =>
|
|
269
|
+
toast.success(`${key} restored`, {
|
|
270
|
+
action: { label: 'Undo', onClick: () => archive({ key }) },
|
|
271
|
+
}),
|
|
272
|
+
},
|
|
273
|
+
);
|
|
288
274
|
}
|
|
289
275
|
|
|
290
276
|
// Cmd/Ctrl+Enter saves from anywhere on the page while edits are pending.
|
|
@@ -295,7 +281,7 @@ function EnvironmentLedger({
|
|
|
295
281
|
function onKeyDown(event: KeyboardEvent) {
|
|
296
282
|
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
|
|
297
283
|
event.preventDefault();
|
|
298
|
-
|
|
284
|
+
saveRef.current();
|
|
299
285
|
}
|
|
300
286
|
}
|
|
301
287
|
document.addEventListener('keydown', onKeyDown);
|
|
@@ -346,7 +332,7 @@ function EnvironmentLedger({
|
|
|
346
332
|
<>
|
|
347
333
|
{canWrite && canReveal && <ImportEnv project={project} environment={environment} />}
|
|
348
334
|
{canWrite && (
|
|
349
|
-
<button className="btn btn-primary" onClick={addDraft}
|
|
335
|
+
<button className="btn btn-primary" onClick={addDraft}>
|
|
350
336
|
<Plus size={14} />
|
|
351
337
|
New secret
|
|
352
338
|
</button>
|
|
@@ -449,7 +435,7 @@ function EnvironmentLedger({
|
|
|
449
435
|
existingVersion={
|
|
450
436
|
keys.find((entry) => entry.key === draft.key.trim())?.version ?? null
|
|
451
437
|
}
|
|
452
|
-
disabled={
|
|
438
|
+
disabled={false}
|
|
453
439
|
onChange={(patch) =>
|
|
454
440
|
setDrafts((rows) =>
|
|
455
441
|
rows.map((row) => (row.id === draft.id ? { ...row, ...patch } : row)),
|
|
@@ -461,6 +447,7 @@ function EnvironmentLedger({
|
|
|
461
447
|
|
|
462
448
|
{listed.map((entry) => {
|
|
463
449
|
const change = secretChangeFor(changes, entry.key);
|
|
450
|
+
const state = status(entry.key);
|
|
464
451
|
return (
|
|
465
452
|
<SecretRow
|
|
466
453
|
key={entry.key}
|
|
@@ -476,7 +463,9 @@ function EnvironmentLedger({
|
|
|
476
463
|
canWrite={canWrite}
|
|
477
464
|
canArchive={canArchive}
|
|
478
465
|
canReveal={canReveal}
|
|
479
|
-
|
|
466
|
+
status={state}
|
|
467
|
+
// Not while its save is on its way.
|
|
468
|
+
disabled={state.state === 'pending'}
|
|
480
469
|
columns={columns}
|
|
481
470
|
onEdit={() => setEditing((current) => new Set(current).add(entry.key))}
|
|
482
471
|
onPatch={(patch) => patchChange(entry, patch)}
|
|
@@ -512,7 +501,6 @@ function EnvironmentLedger({
|
|
|
512
501
|
<Syncs
|
|
513
502
|
project={project}
|
|
514
503
|
environment={environment}
|
|
515
|
-
result={syncs}
|
|
516
504
|
canRun={canWrite || permissions.includes('environment.manage')}
|
|
517
505
|
/>
|
|
518
506
|
|
|
@@ -565,6 +553,9 @@ function EnvironmentLedger({
|
|
|
565
553
|
entry={entry}
|
|
566
554
|
canArchive={canArchive}
|
|
567
555
|
canReveal={canReveal}
|
|
556
|
+
status={status(entry.key)}
|
|
557
|
+
onRestore={() => restoreSecretKey(entry.key)}
|
|
558
|
+
onDismiss={dismiss}
|
|
568
559
|
/>
|
|
569
560
|
))}
|
|
570
561
|
</tbody>
|
|
@@ -590,17 +581,16 @@ function EnvironmentLedger({
|
|
|
590
581
|
{pending.length > 3 && ` · and ${pending.length - 3} more`}
|
|
591
582
|
</span>
|
|
592
583
|
<div className="savebar-actions">
|
|
593
|
-
<button className="btn btn-sm" onClick={discardAll}
|
|
584
|
+
<button className="btn btn-sm" onClick={discardAll}>
|
|
594
585
|
Discard
|
|
595
586
|
</button>
|
|
596
587
|
<button
|
|
597
588
|
className="btn btn-sm btn-primary"
|
|
598
|
-
onClick={
|
|
599
|
-
disabled={
|
|
589
|
+
onClick={saveChanges}
|
|
590
|
+
disabled={!ready}
|
|
600
591
|
title="Save (⌘ Enter or Ctrl Enter)"
|
|
601
592
|
aria-keyshortcuts="Meta+Enter Control+Enter"
|
|
602
593
|
>
|
|
603
|
-
{saving && <Spinner size={13} />}
|
|
604
594
|
Save {pendingCount === 1 ? 'change' : `${pendingCount} changes`}
|
|
605
595
|
</button>
|
|
606
596
|
</div>
|
|
@@ -619,7 +609,7 @@ function EnvironmentLedger({
|
|
|
619
609
|
|
|
620
610
|
/** The display name sits beside the slug; it comes from the shell's project tree. */
|
|
621
611
|
function EnvironmentName({ project, environment }: { project: string; environment: string }) {
|
|
622
|
-
const { projects } =
|
|
612
|
+
const { projects } = useShell();
|
|
623
613
|
const name = projects
|
|
624
614
|
.find((entry) => entry.slug === project)
|
|
625
615
|
?.environments.find((entry) => entry.slug === environment)?.name;
|
|
@@ -729,6 +719,7 @@ function SecretRow({
|
|
|
729
719
|
canWrite,
|
|
730
720
|
canArchive,
|
|
731
721
|
canReveal,
|
|
722
|
+
status,
|
|
732
723
|
disabled,
|
|
733
724
|
columns,
|
|
734
725
|
onEdit,
|
|
@@ -745,6 +736,8 @@ function SecretRow({
|
|
|
745
736
|
canWrite: boolean;
|
|
746
737
|
canArchive: boolean;
|
|
747
738
|
canReveal: boolean;
|
|
739
|
+
/** A save of this row on its way, or refused. */
|
|
740
|
+
status: ItemStatus;
|
|
748
741
|
disabled: boolean;
|
|
749
742
|
columns: number;
|
|
750
743
|
onEdit: () => void;
|
|
@@ -825,7 +818,7 @@ function SecretRow({
|
|
|
825
818
|
|
|
826
819
|
return (
|
|
827
820
|
<>
|
|
828
|
-
<tr className={`secret-row${state}`}>
|
|
821
|
+
<tr className={`secret-row${state} ${rowClass(status)}`}>
|
|
829
822
|
<td className="n">{number}</td>
|
|
830
823
|
<td className="cell-key" data-label="Key">
|
|
831
824
|
{editing && canWrite ? (
|
|
@@ -934,117 +927,121 @@ function SecretRow({
|
|
|
934
927
|
</td>
|
|
935
928
|
|
|
936
929
|
<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
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
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>
|
|
930
|
+
{status.state === 'pending' ? (
|
|
931
|
+
<RowPending status={status} />
|
|
932
|
+
) : (
|
|
933
|
+
<div className="acts">
|
|
934
|
+
{leaving ? (
|
|
935
|
+
<Tip label="Keep">
|
|
936
|
+
<button
|
|
937
|
+
className="act act-icon act-quiet"
|
|
938
|
+
onClick={onUndo}
|
|
939
|
+
disabled={disabled}
|
|
940
|
+
aria-label={`Keep ${entry.key}`}
|
|
941
|
+
>
|
|
942
|
+
<RotateBack size={14} />
|
|
943
|
+
</button>
|
|
944
|
+
</Tip>
|
|
945
|
+
) : editing ? (
|
|
946
|
+
<Tip label={renamed || valueChanged ? 'Undo changes' : 'Cancel'}>
|
|
947
|
+
<button
|
|
948
|
+
className="act act-icon act-quiet"
|
|
949
|
+
onClick={onUndo}
|
|
950
|
+
disabled={disabled}
|
|
951
|
+
aria-label={`${renamed || valueChanged ? 'Undo changes to' : 'Stop editing'} ${entry.key}`}
|
|
952
|
+
>
|
|
953
|
+
{renamed || valueChanged ? <RotateBack size={14} /> : <X size={15} />}
|
|
954
|
+
</button>
|
|
955
|
+
</Tip>
|
|
956
|
+
) : (
|
|
957
|
+
<>
|
|
958
|
+
{/* Copy comes in to the left, so Hide stays where Reveal was clicked. */}
|
|
959
|
+
{shown !== null && (
|
|
960
|
+
<CopyButton variant="act" value={shown.value} label={`Copy ${entry.key}`} />
|
|
961
|
+
)}
|
|
962
|
+
<SecretReadOnly canReveal={canReveal}>
|
|
963
|
+
<Tip label={shown === null ? 'Reveal' : 'Hide'}>
|
|
964
|
+
<button
|
|
965
|
+
className="act act-icon act-accent"
|
|
966
|
+
onClick={toggleReveal}
|
|
967
|
+
disabled={revealing}
|
|
968
|
+
aria-label={`${shown === null ? 'Reveal' : 'Hide'} ${entry.key}`}
|
|
969
|
+
>
|
|
970
|
+
{revealing ? (
|
|
971
|
+
<Spinner size={13} />
|
|
972
|
+
) : shown === null ? (
|
|
973
|
+
<Eye size={15} />
|
|
974
|
+
) : (
|
|
975
|
+
<EyeOff size={15} />
|
|
976
|
+
)}
|
|
977
|
+
</button>
|
|
978
|
+
</Tip>
|
|
979
|
+
</SecretReadOnly>
|
|
980
|
+
{canWrite && (
|
|
981
|
+
<Tip label="Edit">
|
|
1006
982
|
<button
|
|
1007
|
-
className="act act-icon
|
|
1008
|
-
|
|
983
|
+
className="act act-icon"
|
|
984
|
+
onClick={() => {
|
|
985
|
+
// A value already revealed is already on the record, so
|
|
986
|
+
// it becomes the starting point instead of being thrown
|
|
987
|
+
// away and read again.
|
|
988
|
+
if (shown !== null) setBase(shown);
|
|
989
|
+
setReveal(null);
|
|
990
|
+
onEdit();
|
|
991
|
+
}}
|
|
1009
992
|
disabled={disabled}
|
|
993
|
+
aria-label={`Edit ${entry.key}`}
|
|
1010
994
|
>
|
|
1011
|
-
<
|
|
995
|
+
<Pencil size={14} />
|
|
1012
996
|
</button>
|
|
1013
|
-
</
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
</
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
997
|
+
</Tip>
|
|
998
|
+
)}
|
|
999
|
+
{(canReveal || canArchive) && (
|
|
1000
|
+
<DropdownMenu.Root>
|
|
1001
|
+
<DropdownMenu.Trigger asChild>
|
|
1002
|
+
<button
|
|
1003
|
+
className="act act-icon act-quiet"
|
|
1004
|
+
aria-label={`More for ${entry.key}`}
|
|
1005
|
+
disabled={disabled}
|
|
1006
|
+
>
|
|
1007
|
+
<MoreHorizontal size={16} />
|
|
1008
|
+
</button>
|
|
1009
|
+
</DropdownMenu.Trigger>
|
|
1010
|
+
<DropdownMenu.Portal>
|
|
1011
|
+
<DropdownMenu.Content className="menu" sideOffset={6} align="end">
|
|
1012
|
+
<SecretReadOnly canReveal={canReveal}>
|
|
1028
1013
|
<DropdownMenu.Item
|
|
1029
|
-
className="menu-item
|
|
1030
|
-
onSelect={() =>
|
|
1031
|
-
setReveal(null);
|
|
1032
|
-
onMarkArchive();
|
|
1033
|
-
}}
|
|
1014
|
+
className="menu-item"
|
|
1015
|
+
onSelect={() => setHistoryOpen((open) => !open)}
|
|
1034
1016
|
>
|
|
1035
|
-
<
|
|
1036
|
-
|
|
1037
|
-
<span className="menu-hint">on save</span>
|
|
1017
|
+
<History size={14} />
|
|
1018
|
+
{historyOpen ? 'Hide history' : 'Version history'}
|
|
1038
1019
|
</DropdownMenu.Item>
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1020
|
+
</SecretReadOnly>
|
|
1021
|
+
{canArchive && (
|
|
1022
|
+
<>
|
|
1023
|
+
{canReveal && <DropdownMenu.Separator className="menu-sep" />}
|
|
1024
|
+
<DropdownMenu.Item
|
|
1025
|
+
className="menu-item menu-item-danger"
|
|
1026
|
+
onSelect={() => {
|
|
1027
|
+
setReveal(null);
|
|
1028
|
+
onMarkArchive();
|
|
1029
|
+
}}
|
|
1030
|
+
>
|
|
1031
|
+
<Archive size={14} />
|
|
1032
|
+
Archive
|
|
1033
|
+
<span className="menu-hint">on save</span>
|
|
1034
|
+
</DropdownMenu.Item>
|
|
1035
|
+
</>
|
|
1036
|
+
)}
|
|
1037
|
+
</DropdownMenu.Content>
|
|
1038
|
+
</DropdownMenu.Portal>
|
|
1039
|
+
</DropdownMenu.Root>
|
|
1040
|
+
)}
|
|
1041
|
+
</>
|
|
1042
|
+
)}
|
|
1043
|
+
</div>
|
|
1044
|
+
)}
|
|
1048
1045
|
</td>
|
|
1049
1046
|
</tr>
|
|
1050
1047
|
|
|
@@ -1213,6 +1210,9 @@ function ArchivedRow({
|
|
|
1213
1210
|
entry,
|
|
1214
1211
|
canArchive,
|
|
1215
1212
|
canReveal,
|
|
1213
|
+
status: state,
|
|
1214
|
+
onRestore,
|
|
1215
|
+
onDismiss,
|
|
1216
1216
|
}: {
|
|
1217
1217
|
number: number;
|
|
1218
1218
|
project: string;
|
|
@@ -1220,26 +1220,15 @@ function ArchivedRow({
|
|
|
1220
1220
|
entry: SecretKey;
|
|
1221
1221
|
canArchive: boolean;
|
|
1222
1222
|
canReveal: boolean;
|
|
1223
|
+
status: ItemStatus;
|
|
1224
|
+
onRestore: () => void;
|
|
1225
|
+
onDismiss: (mutationId: number) => void;
|
|
1223
1226
|
}) {
|
|
1224
1227
|
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
1228
|
|
|
1240
1229
|
return (
|
|
1241
1230
|
<>
|
|
1242
|
-
<tr className=
|
|
1231
|
+
<tr className={`secret-row is-archived ${rowClass(state)}`}>
|
|
1243
1232
|
<td className="n">{number}</td>
|
|
1244
1233
|
<td className="cell-key" data-label="Key">
|
|
1245
1234
|
{breakAfterUnderscores(entry.key)}
|
|
@@ -1264,18 +1253,16 @@ function ArchivedRow({
|
|
|
1264
1253
|
</button>
|
|
1265
1254
|
</Tip>
|
|
1266
1255
|
</SecretReadOnly>
|
|
1267
|
-
{canArchive &&
|
|
1268
|
-
|
|
1269
|
-
<
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
</Tip>
|
|
1278
|
-
)}
|
|
1256
|
+
{canArchive &&
|
|
1257
|
+
(state.state === 'pending' ? (
|
|
1258
|
+
<RowPending status={state} />
|
|
1259
|
+
) : (
|
|
1260
|
+
<Tip label="Restore">
|
|
1261
|
+
<button className="act act-icon" onClick={onRestore} aria-label={`Restore ${entry.key}`}>
|
|
1262
|
+
<RotateBack size={14} />
|
|
1263
|
+
</button>
|
|
1264
|
+
</Tip>
|
|
1265
|
+
))}
|
|
1279
1266
|
</div>
|
|
1280
1267
|
</td>
|
|
1281
1268
|
</tr>
|
|
@@ -1294,13 +1281,11 @@ function ArchivedRow({
|
|
|
1294
1281
|
</td>
|
|
1295
1282
|
</tr>
|
|
1296
1283
|
)}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
</tr>
|
|
1303
|
-
)}
|
|
1284
|
+
<RowFailure
|
|
1285
|
+
status={state}
|
|
1286
|
+
columns={5}
|
|
1287
|
+
onDismiss={() => state.state === 'failed' && onDismiss(state.mutationId)}
|
|
1288
|
+
/>
|
|
1304
1289
|
</>
|
|
1305
1290
|
);
|
|
1306
1291
|
}
|
|
@@ -1436,9 +1421,12 @@ function VersionHistory({
|
|
|
1436
1421
|
`${project}/${environment}/${secretKey}`,
|
|
1437
1422
|
version.version,
|
|
1438
1423
|
),
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1424
|
+
{
|
|
1425
|
+
affects: affects.secrets({ project, environment }),
|
|
1426
|
+
onSuccess: () => {
|
|
1427
|
+
onRolledBack();
|
|
1428
|
+
toast.success(`${secretKey} rolled back to v${version.version}`);
|
|
1429
|
+
},
|
|
1442
1430
|
},
|
|
1443
1431
|
)
|
|
1444
1432
|
}
|
|
@@ -1504,9 +1492,13 @@ function ImportEnv({ project, environment }: { project: string; environment: str
|
|
|
1504
1492
|
function preview() {
|
|
1505
1493
|
run(
|
|
1506
1494
|
() => planEnv(coffre, path, content),
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1495
|
+
{
|
|
1496
|
+
// A dry run: nothing changes.
|
|
1497
|
+
affects: [],
|
|
1498
|
+
onSuccess: (result) => {
|
|
1499
|
+
setProblems(result.problems);
|
|
1500
|
+
setPlan({ entries: result.plan, changes: result.changes });
|
|
1501
|
+
},
|
|
1510
1502
|
},
|
|
1511
1503
|
);
|
|
1512
1504
|
}
|
|
@@ -1516,9 +1508,12 @@ function ImportEnv({ project, environment }: { project: string; environment: str
|
|
|
1516
1508
|
const written = Object.keys(plan.changes).length;
|
|
1517
1509
|
run(
|
|
1518
1510
|
() => coffre.secrets.set(path, plan.changes),
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1511
|
+
{
|
|
1512
|
+
affects: affects.secrets({ project, environment }),
|
|
1513
|
+
onSuccess: () => {
|
|
1514
|
+
toast.success(`Imported ${written} change${written === 1 ? '' : 's'}`);
|
|
1515
|
+
close();
|
|
1516
|
+
},
|
|
1522
1517
|
},
|
|
1523
1518
|
);
|
|
1524
1519
|
}
|