@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
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { i as require_react, r as require_jsx_runtime, s as __toESM } from "./useRouter-CaUSUNsw.js";
|
|
2
|
+
import { t as Link } from "./link-42ZWdjzZ.js";
|
|
3
|
+
import { C as useCoffre, U as planImport, V as CoffreError, c as keys, h as queries, i as PageHeader, n as ClosedDoor, o as affects, t as Card, w as canRevealSecrets, y as failureMessage } from "./page-BGeDoQO5.js";
|
|
4
|
+
import { C as hasSecretEditConflict, a as archiveSecret, n as useChangeStatus, r as UnsavedEdits, t as useChange, v as restoreSecret, w as secretChangeFor, x as saveSecrets } from "./use-change-CJpGSNIq.js";
|
|
5
|
+
import { t as useShell } from "./use-shell-C3iYcyP1.js";
|
|
6
|
+
import { t as useSuspenseQuery } from "./useSuspenseQuery-BjAmlGZl.js";
|
|
7
|
+
import { n as toast } from "./dist-CnnV3t2g.js";
|
|
8
|
+
import { a as ErrorLine, c as Spinner, h as dropdown_menu_exports, i as EmptyState, l as Timestamp, o as Modal, p as breakAfterUnderscores, r as CopyButton, s as Notice, t as ConfirmButton, u as Tip } from "./ui-DvlGkmaH.js";
|
|
9
|
+
import { i as SecretReadOnly } from "./affordances-CKANXDTG.js";
|
|
10
|
+
import { A as Plus, B as Upload, D as MoreHorizontal, M as RotateBack, N as Search, S as Lock, W as X, d as Eye, f as EyeOff, g as History, h as Hash, i as Archive, k as Pencil, l as Clock, n as AlertCircle, v as Key, z as Terminal } from "./icons-CWsTEfpn.js";
|
|
11
|
+
import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-CAItu3n_.js";
|
|
12
|
+
import { t as Route } from "./projects._project._environment-BXU1Mee5.js";
|
|
13
|
+
import { t as useAction } from "./use-action-C2wz34kq.js";
|
|
8
14
|
import { t as secretKeyProblem } from "./validation-BQtqPe2V.js";
|
|
9
15
|
//#region ../core/dist/dotenv.js
|
|
10
16
|
var KEY_RE = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
@@ -153,646 +159,14 @@ function unescapeDoubleQuoted(text) {
|
|
|
153
159
|
});
|
|
154
160
|
}
|
|
155
161
|
//#endregion
|
|
156
|
-
//#region src/lib/secret-edit-batch.ts
|
|
157
|
-
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
158
|
-
function secretChangeFor(changes, key) {
|
|
159
|
-
return Object.hasOwn(changes, key) ? changes[key] : void 0;
|
|
160
|
-
}
|
|
161
|
-
/** Return true when one save would give two pending edits the same target. */
|
|
162
|
-
function hasSecretEditConflict(active, drafts, changes) {
|
|
163
|
-
const finalActiveKeys = active.filter((entry) => !secretChangeFor(changes, entry.key)?.archived).map((entry) => secretChangeFor(changes, entry.key)?.key.trim() ?? entry.key);
|
|
164
|
-
if (new Set(finalActiveKeys).size !== finalActiveKeys.length) return true;
|
|
165
|
-
const draftKeys = drafts.map((draft) => draft.key.trim());
|
|
166
|
-
if (new Set(draftKeys).size !== draftKeys.length) return true;
|
|
167
|
-
const valueEditTargets = new Set(active.flatMap((entry) => {
|
|
168
|
-
const change = secretChangeFor(changes, entry.key);
|
|
169
|
-
return change !== void 0 && !change.archived && change.value !== null ? [change.key.trim()] : [];
|
|
170
|
-
}));
|
|
171
|
-
if (draftKeys.some((key) => valueEditTargets.has(key))) return true;
|
|
172
|
-
const archivedKeys = new Set(active.filter((entry) => secretChangeFor(changes, entry.key)?.archived).map((entry) => entry.key));
|
|
173
|
-
return draftKeys.some((key) => archivedKeys.has(key));
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Save every pending edit: renames first, one call each, then everything else
|
|
177
|
-
* as one merge patch.
|
|
178
|
-
*
|
|
179
|
-
* The patch is a single transaction, so values, new keys and archives land
|
|
180
|
-
* together or not at all. Renames cannot join it: a merge patch names keys and
|
|
181
|
-
* has no way to move one with its history. A failed rename therefore stops the
|
|
182
|
-
* save before the patch. The renames before it stay done, and every other edit
|
|
183
|
-
* is kept for the retry, a value following its key to the new name.
|
|
184
|
-
*/
|
|
185
|
-
async function applySecretEditBatch({ active, drafts, changes, operations }) {
|
|
186
|
-
const remainingChanges = { ...changes };
|
|
187
|
-
const plan = planEdits(active, drafts, changes);
|
|
188
|
-
if (plan instanceof Error) return {
|
|
189
|
-
applied: 0,
|
|
190
|
-
drafts: [...drafts],
|
|
191
|
-
changes: remainingChanges,
|
|
192
|
-
error: plan
|
|
193
|
-
};
|
|
194
|
-
let applied = 0;
|
|
195
|
-
const patch = Object.create(null);
|
|
196
|
-
try {
|
|
197
|
-
for (const { sourceKey, change } of plan) {
|
|
198
|
-
if (change.archived) {
|
|
199
|
-
patch[sourceKey] = null;
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
const key = change.key.trim();
|
|
203
|
-
if (key !== sourceKey) {
|
|
204
|
-
await operations.rename(sourceKey, key);
|
|
205
|
-
delete remainingChanges[sourceKey];
|
|
206
|
-
applied += 1;
|
|
207
|
-
if (change.value !== null) remainingChanges[key] = {
|
|
208
|
-
key,
|
|
209
|
-
value: change.value,
|
|
210
|
-
archived: false
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
if (change.value !== null) patch[key] = change.value;
|
|
214
|
-
}
|
|
215
|
-
for (const draft of drafts) patch[draft.key.trim()] = draft.value;
|
|
216
|
-
const written = Object.keys(patch).length;
|
|
217
|
-
if (written > 0) await operations.write({ ...patch });
|
|
218
|
-
return {
|
|
219
|
-
applied: applied + written,
|
|
220
|
-
drafts: [],
|
|
221
|
-
changes: {},
|
|
222
|
-
error: null
|
|
223
|
-
};
|
|
224
|
-
} catch (error) {
|
|
225
|
-
return {
|
|
226
|
-
applied,
|
|
227
|
-
drafts: [...drafts],
|
|
228
|
-
changes: remainingChanges,
|
|
229
|
-
error
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Put dependent renames in an order that frees each destination first.
|
|
235
|
-
* Cycles and archive-then-restore plans fail before the first mutation.
|
|
236
|
-
*/
|
|
237
|
-
function planEdits(active, drafts, changes) {
|
|
238
|
-
const activeKeys = new Set(active.map((entry) => entry.key));
|
|
239
|
-
const archivedKeys = new Set(active.filter((entry) => secretChangeFor(changes, entry.key)?.archived).map((entry) => entry.key));
|
|
240
|
-
const restoredByDraft = drafts.find((draft) => archivedKeys.has(draft.key.trim()));
|
|
241
|
-
if (restoredByDraft) return /* @__PURE__ */ new Error(`${restoredByDraft.key.trim()}: cannot archive and write the same key in one save`);
|
|
242
|
-
const renames = /* @__PURE__ */ new Map();
|
|
243
|
-
const otherEdits = [];
|
|
244
|
-
for (const entry of active) {
|
|
245
|
-
const change = secretChangeFor(changes, entry.key);
|
|
246
|
-
if (change === void 0) continue;
|
|
247
|
-
if (!change.archived && change.key.trim() !== entry.key) renames.set(entry.key, change);
|
|
248
|
-
else otherEdits.push({
|
|
249
|
-
sourceKey: entry.key,
|
|
250
|
-
change
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
for (const [sourceKey, change] of renames) {
|
|
254
|
-
const destination = change.key.trim();
|
|
255
|
-
if (activeKeys.has(destination) && !renames.has(destination)) return /* @__PURE__ */ new Error(`${sourceKey}: ${destination} is already in use`);
|
|
256
|
-
}
|
|
257
|
-
const orderedRenames = [];
|
|
258
|
-
const freedKeys = /* @__PURE__ */ new Set();
|
|
259
|
-
while (renames.size > 0) {
|
|
260
|
-
const ready = [...renames].find(([, change]) => {
|
|
261
|
-
const destination = change.key.trim();
|
|
262
|
-
return !activeKeys.has(destination) || freedKeys.has(destination);
|
|
263
|
-
});
|
|
264
|
-
if (!ready) return /* @__PURE__ */ new Error("Secret renames contain a cycle. Save them in separate steps.");
|
|
265
|
-
const [sourceKey, change] = ready;
|
|
266
|
-
renames.delete(sourceKey);
|
|
267
|
-
freedKeys.add(sourceKey);
|
|
268
|
-
orderedRenames.push({
|
|
269
|
-
sourceKey,
|
|
270
|
-
change
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
return [...orderedRenames, ...otherEdits];
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
162
|
//#region src/lib/reveal.ts
|
|
163
|
+
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
277
164
|
function revealIsCurrent(reveal, currentVersion) {
|
|
278
165
|
return reveal !== null && reveal.version === currentVersion;
|
|
279
166
|
}
|
|
280
167
|
//#endregion
|
|
281
|
-
//#region src/components/syncs.tsx
|
|
282
|
-
var import_jsx_runtime = require_jsx_runtime();
|
|
283
|
-
/** How often the card refreshes while a run is in flight. */
|
|
284
|
-
var RUNNING_POLL_MS = 2e3;
|
|
285
|
-
/** How long a new sync's toast waits for its first push to end. */
|
|
286
|
-
var FIRST_RUN_WAIT_MS = 6e4;
|
|
287
|
-
/**
|
|
288
|
-
* Where this environment's secrets are pushed.
|
|
289
|
-
*
|
|
290
|
-
* Hidden from people who can neither see a sync nor add one; everyone who can
|
|
291
|
-
* write a secret sees them, since saving one sends it on.
|
|
292
|
-
*/
|
|
293
|
-
function Syncs({ project, environment, result, canRun }) {
|
|
294
|
-
const router = useRouter();
|
|
295
|
-
const running = result.ok && result.syncs.some((sync) => sync.running);
|
|
296
|
-
(0, import_react.useEffect)(() => {
|
|
297
|
-
if (!running) return;
|
|
298
|
-
const timer = setInterval(() => void router.invalidate(), RUNNING_POLL_MS);
|
|
299
|
-
return () => clearInterval(timer);
|
|
300
|
-
}, [running, router]);
|
|
301
|
-
if (result.ok && result.syncs.length === 0 && !result.canManage) return null;
|
|
302
|
-
const canManage = result.ok && result.canManage;
|
|
303
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, {
|
|
304
|
-
labelledBy: "syncs",
|
|
305
|
-
title: "Syncs",
|
|
306
|
-
description: "Destinations these secrets are pushed to. A change goes out when it is saved, and every hour coffre checks each destination and repairs what drifted.",
|
|
307
|
-
actions: canManage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddSync, {
|
|
308
|
-
project,
|
|
309
|
-
environment
|
|
310
|
-
}) : void 0,
|
|
311
|
-
children: !result.ok ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
312
|
-
className: "card-body",
|
|
313
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error: result.error })
|
|
314
|
-
}) : result.syncs.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyState, {
|
|
315
|
-
title: "Not synced anywhere",
|
|
316
|
-
children: [
|
|
317
|
-
"Push these secrets where your code runs, such as GitHub Actions or Vercel, and keep them current there. Anything else can read them with ",
|
|
318
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "coffre run" }),
|
|
319
|
-
"."
|
|
320
|
-
]
|
|
321
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
322
|
-
className: "dt-wrap",
|
|
323
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
|
|
324
|
-
className: "dt syncs stacks",
|
|
325
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
326
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Destination" }),
|
|
327
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
|
|
328
|
-
className: "col-shrink",
|
|
329
|
-
children: "Status"
|
|
330
|
-
}),
|
|
331
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
|
|
332
|
-
className: "col-shrink col-hide-narrow",
|
|
333
|
-
children: "Token"
|
|
334
|
-
}),
|
|
335
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
|
|
336
|
-
className: "col-actions",
|
|
337
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
338
|
-
className: "visually-hidden",
|
|
339
|
-
children: "Actions"
|
|
340
|
-
})
|
|
341
|
-
})
|
|
342
|
-
] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: result.syncs.map((sync) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyncRow, {
|
|
343
|
-
sync,
|
|
344
|
-
canRun,
|
|
345
|
-
canManage
|
|
346
|
-
}, sync.id)) })]
|
|
347
|
-
})
|
|
348
|
-
})
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
function SyncRow({ sync, canRun, canManage }) {
|
|
352
|
-
const [removing, setRemoving] = (0, import_react.useState)(false);
|
|
353
|
-
const coffre = useCoffre();
|
|
354
|
-
const pushing = useAction();
|
|
355
|
-
const managing = useAction();
|
|
356
|
-
const pending = pushing.pending || managing.pending;
|
|
357
|
-
const error = pushing.error ?? managing.error;
|
|
358
|
-
function runNow() {
|
|
359
|
-
pushing.run(() => coffre.syncs.run(sync.id), (result) => announce(sync, result.outcome));
|
|
360
|
-
}
|
|
361
|
-
function setPaused(paused) {
|
|
362
|
-
managing.run(() => coffre.syncs.update(sync.id, { paused }), () => toast.success(paused ? `Paused ${sync.destination}` : `Resumed ${sync.destination}`, { action: {
|
|
363
|
-
label: "Undo",
|
|
364
|
-
onClick: () => setPaused(!paused)
|
|
365
|
-
} }));
|
|
366
|
-
}
|
|
367
|
-
const shownError = error ?? (sync.offered ? sync.lastError : null);
|
|
368
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
|
|
369
|
-
className: shownError !== null && !sync.running ? "has-error" : void 0,
|
|
370
|
-
children: [
|
|
371
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
372
|
-
className: "col-destination",
|
|
373
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
374
|
-
className: "cell-account",
|
|
375
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyncMark, {
|
|
376
|
-
brand: sync.brand,
|
|
377
|
-
size: 15
|
|
378
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
379
|
-
className: "cell-stack",
|
|
380
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: sync.providerLabel }), sync.offered ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", {
|
|
381
|
-
className: "mono",
|
|
382
|
-
children: sync.destination
|
|
383
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "No longer offered by this deployment" })]
|
|
384
|
-
})]
|
|
385
|
-
})
|
|
386
|
-
}),
|
|
387
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
388
|
-
className: "nowrap col-status",
|
|
389
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
390
|
-
className: "cell-stack",
|
|
391
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyncState, { sync }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counts, { sync }) })]
|
|
392
|
-
})
|
|
393
|
-
}),
|
|
394
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
395
|
-
className: "col-shrink col-hide-narrow cell-mono cell-muted",
|
|
396
|
-
children: sync.credential
|
|
397
|
-
}),
|
|
398
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", {
|
|
399
|
-
className: "col-actions",
|
|
400
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
401
|
-
className: "acts",
|
|
402
|
-
children: [canRun && !sync.paused && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
403
|
-
className: "act",
|
|
404
|
-
onClick: runNow,
|
|
405
|
-
disabled: pending || sync.running || !sync.offered,
|
|
406
|
-
title: sync.offered ? void 0 : "This deployment no longer offers this provider",
|
|
407
|
-
children: [pushing.pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { size: 13 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sync, { size: 13 }), "Run now"]
|
|
408
|
-
}), canManage && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Root, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(dropdown_menu_exports.Trigger, {
|
|
409
|
-
asChild: true,
|
|
410
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
411
|
-
className: "act act-icon act-quiet",
|
|
412
|
-
"aria-label": `More for ${sync.destination}`,
|
|
413
|
-
disabled: pending,
|
|
414
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreHorizontal, { size: 16 })
|
|
415
|
-
})
|
|
416
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(dropdown_menu_exports.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Content, {
|
|
417
|
-
className: "menu",
|
|
418
|
-
sideOffset: 6,
|
|
419
|
-
align: "end",
|
|
420
|
-
children: [
|
|
421
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Item, {
|
|
422
|
-
className: "menu-item",
|
|
423
|
-
onSelect: () => setPaused(!sync.paused),
|
|
424
|
-
children: [sync.paused ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Play, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pause, { size: 14 }), sync.paused ? "Resume" : "Pause"]
|
|
425
|
-
}),
|
|
426
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(dropdown_menu_exports.Separator, { className: "menu-sep" }),
|
|
427
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Item, {
|
|
428
|
-
className: "menu-item menu-item-danger",
|
|
429
|
-
onSelect: () => setRemoving(true),
|
|
430
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(X, { size: 14 }), "Remove"]
|
|
431
|
-
})
|
|
432
|
-
]
|
|
433
|
-
}) })] })]
|
|
434
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfirmDialog, {
|
|
435
|
-
open: removing,
|
|
436
|
-
onOpenChange: setRemoving,
|
|
437
|
-
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
438
|
-
"Stop syncing to ",
|
|
439
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
440
|
-
className: "mono",
|
|
441
|
-
children: sync.destination
|
|
442
|
-
}),
|
|
443
|
-
"?"
|
|
444
|
-
] }),
|
|
445
|
-
body: `Nothing more is pushed to ${sync.providerLabel}. Keys coffre already pushed stay there; remove them at ${sync.providerLabel} if they should go too.`,
|
|
446
|
-
confirmLabel: "Remove sync",
|
|
447
|
-
onConfirm: () => managing.run(() => coffre.syncs.remove(sync.id), () => toast.success(`No longer syncing to ${sync.destination}`))
|
|
448
|
-
})]
|
|
449
|
-
})
|
|
450
|
-
]
|
|
451
|
-
}), shownError !== null && !sync.running && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", {
|
|
452
|
-
className: "row-error",
|
|
453
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
454
|
-
colSpan: 4,
|
|
455
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error: shownError })
|
|
456
|
-
})
|
|
457
|
-
})] });
|
|
458
|
-
}
|
|
459
|
-
/** One tag for the state that matters most right now. */
|
|
460
|
-
function SyncState({ sync }) {
|
|
461
|
-
if (!sync.offered) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
462
|
-
className: "tag tag-outline",
|
|
463
|
-
children: "Unavailable"
|
|
464
|
-
});
|
|
465
|
-
if (sync.running) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
466
|
-
className: "tag tag-blue",
|
|
467
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { size: 11 }), "Pushing"]
|
|
468
|
-
});
|
|
469
|
-
if (sync.paused) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
470
|
-
className: "tag tag-outline",
|
|
471
|
-
children: "Paused"
|
|
472
|
-
});
|
|
473
|
-
if (sync.lastStatus === "failed") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
474
|
-
className: "tag tag-red",
|
|
475
|
-
children: "Failed"
|
|
476
|
-
});
|
|
477
|
-
if (sync.pending > 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
478
|
-
className: "tag tag-amber",
|
|
479
|
-
children: [sync.pending, " pending"]
|
|
480
|
-
});
|
|
481
|
-
if (sync.lastStatus === "partial") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
482
|
-
className: "tag tag-amber",
|
|
483
|
-
children: "Partial"
|
|
484
|
-
});
|
|
485
|
-
if (sync.lastRunAt === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
486
|
-
className: "tag",
|
|
487
|
-
children: "Not run yet"
|
|
488
|
-
});
|
|
489
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
490
|
-
className: "tag tag-green",
|
|
491
|
-
children: "In sync"
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
function Counts({ sync }) {
|
|
495
|
-
const skipped = sync.skipped.length;
|
|
496
|
-
const parts = [];
|
|
497
|
-
if (sync.synced > 0 || sync.pending === 0) parts.push(`${sync.synced} synced`);
|
|
498
|
-
if (sync.pending > 0) parts.push(`${sync.pending} pending`);
|
|
499
|
-
if (skipped > 0) parts.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Toggletip, {
|
|
500
|
-
label: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
501
|
-
style: {
|
|
502
|
-
margin: 0,
|
|
503
|
-
paddingLeft: "1rem"
|
|
504
|
-
},
|
|
505
|
-
children: sync.skipped.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
506
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
507
|
-
className: "mono",
|
|
508
|
-
children: entry.key
|
|
509
|
-
}),
|
|
510
|
-
": ",
|
|
511
|
-
entry.reason
|
|
512
|
-
] }, entry.key))
|
|
513
|
-
}),
|
|
514
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
515
|
-
type: "button",
|
|
516
|
-
className: "tag tag-amber tag-button",
|
|
517
|
-
children: [
|
|
518
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTriangle, { size: 11 }),
|
|
519
|
-
skipped,
|
|
520
|
-
" skipped"
|
|
521
|
-
]
|
|
522
|
-
})
|
|
523
|
-
}));
|
|
524
|
-
if (sync.lastRunAt !== null) parts.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Timestamp, {
|
|
525
|
-
iso: sync.lastRunAt,
|
|
526
|
-
display: "relative"
|
|
527
|
-
}));
|
|
528
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: parts.map((part, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [index > 0 && " · ", part] }, index)) });
|
|
529
|
-
}
|
|
530
|
-
function announce(sync, outcome) {
|
|
531
|
-
if (outcome.status === "busy") {
|
|
532
|
-
toast("A run is already under way", { description: "Its result appears here when it ends." });
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const changed = outcome.upserted.length + outcome.deleted.length;
|
|
536
|
-
if (outcome.status === "failed") toast.error(`Could not sync to ${sync.destination}`, { description: outcome.error ?? void 0 });
|
|
537
|
-
else if (outcome.status === "partial") toast.warning(`${outcome.failed.length} of ${changed + outcome.failed.length} changes failed`, { description: outcome.failed[0]?.message });
|
|
538
|
-
else if (changed === 0) toast.success(`${sync.destination} was already current`);
|
|
539
|
-
else {
|
|
540
|
-
const parts = [outcome.upserted.length > 0 && `pushed ${outcome.upserted.length}`, outcome.deleted.length > 0 && `removed ${outcome.deleted.length}`].filter(Boolean);
|
|
541
|
-
toast.success(`${capitalize(parts.join(", "))} to ${sync.destination}`);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* A new sync pushes in the background once it is made. Say so while it does,
|
|
546
|
-
* then say how it went: a green toast beside a row already marked Failed
|
|
547
|
-
* would be telling two stories.
|
|
548
|
-
*/
|
|
549
|
-
async function followFirstRun(coffre, path, sync, refresh) {
|
|
550
|
-
const id = toast.loading(`Pushing to ${sync.destination}`, { description: "The first push is under way." });
|
|
551
|
-
const deadline = Date.now() + FIRST_RUN_WAIT_MS;
|
|
552
|
-
while (Date.now() < deadline) {
|
|
553
|
-
await new Promise((resolve) => setTimeout(resolve, RUNNING_POLL_MS));
|
|
554
|
-
const listed = await uiResult(() => coffre.syncs.list(path));
|
|
555
|
-
const now = listed.ok ? listed.syncs.find((other) => other.id === sync.id) : void 0;
|
|
556
|
-
if (now === void 0 || now.running || now.lastRunAt === null) continue;
|
|
557
|
-
await refresh();
|
|
558
|
-
if (now.lastStatus === "failed") toast.error(`Could not sync to ${sync.destination}`, {
|
|
559
|
-
id,
|
|
560
|
-
description: now.lastError ?? void 0
|
|
561
|
-
});
|
|
562
|
-
else if (now.lastStatus === "partial") toast.warning(`Synced to ${sync.destination}, but not every key`, {
|
|
563
|
-
id,
|
|
564
|
-
description: now.lastError ?? void 0
|
|
565
|
-
});
|
|
566
|
-
else toast.success(`Synced to ${sync.destination}`, {
|
|
567
|
-
id,
|
|
568
|
-
description: `${now.synced} ${now.synced === 1 ? "key is" : "keys are"} there now.`
|
|
569
|
-
});
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
await refresh();
|
|
573
|
-
toast(`Still pushing to ${sync.destination}`, {
|
|
574
|
-
id,
|
|
575
|
-
description: "Its result appears in the list when it ends."
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
function capitalize(text) {
|
|
579
|
-
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
580
|
-
}
|
|
581
|
-
function AddSync({ project, environment }) {
|
|
582
|
-
const [open, setOpen] = (0, import_react.useState)(false);
|
|
583
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
584
|
-
className: "btn btn-sm",
|
|
585
|
-
onClick: () => setOpen(true),
|
|
586
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Plus, { size: 14 }), "Add sync"]
|
|
587
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Modal, {
|
|
588
|
-
open,
|
|
589
|
-
onOpenChange: setOpen,
|
|
590
|
-
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["Sync ", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
591
|
-
className: "mono",
|
|
592
|
-
children: [
|
|
593
|
-
project,
|
|
594
|
-
"/",
|
|
595
|
-
environment
|
|
596
|
-
]
|
|
597
|
-
})] }),
|
|
598
|
-
description: "Every key in this environment is pushed to the destination and kept current. coffre only ever removes keys it pushed itself.",
|
|
599
|
-
wide: true,
|
|
600
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyncProviders, { children: (providers) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddSyncForm, {
|
|
601
|
-
project,
|
|
602
|
-
environment,
|
|
603
|
-
providers,
|
|
604
|
-
onDone: () => setOpen(false)
|
|
605
|
-
}) })
|
|
606
|
-
})] });
|
|
607
|
-
}
|
|
608
|
-
/** Where this instance can sync to, as the deployment lists it. */
|
|
609
|
-
function SyncProviders({ children }) {
|
|
610
|
-
const coffre = useCoffre();
|
|
611
|
-
const [offered, setOffered] = (0, import_react.useState)(null);
|
|
612
|
-
(0, import_react.useEffect)(() => {
|
|
613
|
-
let live = true;
|
|
614
|
-
uiResult(() => coffre.syncs.providers()).then((result) => {
|
|
615
|
-
if (live) setOffered(result);
|
|
616
|
-
});
|
|
617
|
-
return () => {
|
|
618
|
-
live = false;
|
|
619
|
-
};
|
|
620
|
-
}, [coffre]);
|
|
621
|
-
if (offered === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
622
|
-
className: "picker-empty sync-providers-state",
|
|
623
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { size: 13 }), "Loading where coffre can sync to…"]
|
|
624
|
-
});
|
|
625
|
-
if (!offered.ok) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
626
|
-
className: "sync-providers-state",
|
|
627
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error: offered.error })
|
|
628
|
-
});
|
|
629
|
-
if (offered.providers.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
630
|
-
className: "picker-empty sync-providers-state",
|
|
631
|
-
children: [
|
|
632
|
-
"This instance offers nowhere to sync to. Whoever runs coffre lists the providers in its",
|
|
633
|
-
" ",
|
|
634
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
635
|
-
className: "mono",
|
|
636
|
-
children: "syncs"
|
|
637
|
-
}),
|
|
638
|
-
" settings."
|
|
639
|
-
]
|
|
640
|
-
});
|
|
641
|
-
return children(offered.providers);
|
|
642
|
-
}
|
|
643
|
-
function AddSyncForm({ project, environment, providers, onDone }) {
|
|
644
|
-
const [provider, setProvider] = (0, import_react.useState)(providers[0]);
|
|
645
|
-
const [values, setValues] = (0, import_react.useState)(() => initialValues(providers[0]));
|
|
646
|
-
const [credential, setCredential] = (0, import_react.useState)("");
|
|
647
|
-
const coffre = useCoffre();
|
|
648
|
-
const router = useRouter();
|
|
649
|
-
const { pending, error, setError, run } = useAction();
|
|
650
|
-
const missing = firstMissing(provider, values);
|
|
651
|
-
function pick(next) {
|
|
652
|
-
setProvider(next);
|
|
653
|
-
setValues(initialValues(next));
|
|
654
|
-
setError(null);
|
|
655
|
-
}
|
|
656
|
-
function set(name, value) {
|
|
657
|
-
setValues((current) => ({
|
|
658
|
-
...current,
|
|
659
|
-
[name]: value
|
|
660
|
-
}));
|
|
661
|
-
}
|
|
662
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
|
|
663
|
-
className: "form",
|
|
664
|
-
style: { marginTop: "1.25rem" },
|
|
665
|
-
onSubmit: (event) => {
|
|
666
|
-
event.preventDefault();
|
|
667
|
-
run(() => coffre.syncs.add(`${project}/${environment}`, {
|
|
668
|
-
provider: provider.id,
|
|
669
|
-
config: configFromForm(provider, values),
|
|
670
|
-
credential: credential.trim()
|
|
671
|
-
}), (sync) => {
|
|
672
|
-
onDone();
|
|
673
|
-
followFirstRun(coffre, `${project}/${environment}`, sync, () => router.invalidate());
|
|
674
|
-
});
|
|
675
|
-
},
|
|
676
|
-
children: [
|
|
677
|
-
providers.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
678
|
-
className: "choice-grid sync-providers",
|
|
679
|
-
role: "group",
|
|
680
|
-
"aria-label": "Destination",
|
|
681
|
-
children: providers.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
682
|
-
type: "button",
|
|
683
|
-
className: "choice",
|
|
684
|
-
"aria-pressed": option.id === provider.id,
|
|
685
|
-
onClick: () => pick(option),
|
|
686
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyncMark, { brand: option.brand }), option.label]
|
|
687
|
-
}, option.id))
|
|
688
|
-
}),
|
|
689
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
690
|
-
className: "form-row",
|
|
691
|
-
children: provider.fields.map((field) => {
|
|
692
|
-
if (!isAsked(field, values)) return null;
|
|
693
|
-
if (field.type === "text") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
694
|
-
className: "field",
|
|
695
|
-
children: [
|
|
696
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
697
|
-
className: "label",
|
|
698
|
-
children: [field.label, field.optional === true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
699
|
-
className: "hint",
|
|
700
|
-
children: " (optional)"
|
|
701
|
-
})]
|
|
702
|
-
}),
|
|
703
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
704
|
-
className: "input input-mono",
|
|
705
|
-
value: values[field.name],
|
|
706
|
-
placeholder: field.placeholder,
|
|
707
|
-
spellCheck: false,
|
|
708
|
-
autoComplete: "off",
|
|
709
|
-
onChange: (event) => set(field.name, event.target.value)
|
|
710
|
-
}),
|
|
711
|
-
field.hint !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
712
|
-
className: "hint",
|
|
713
|
-
children: field.hint
|
|
714
|
-
})
|
|
715
|
-
]
|
|
716
|
-
}, `${provider.id}.${field.name}`);
|
|
717
|
-
const picked = values[field.name];
|
|
718
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
719
|
-
className: "field field-options",
|
|
720
|
-
role: "group",
|
|
721
|
-
"aria-label": field.label,
|
|
722
|
-
children: [
|
|
723
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
724
|
-
className: "label",
|
|
725
|
-
children: field.label
|
|
726
|
-
}),
|
|
727
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
728
|
-
className: "segmented",
|
|
729
|
-
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
730
|
-
type: "button",
|
|
731
|
-
"aria-pressed": picked.includes(option.value),
|
|
732
|
-
onClick: () => set(field.name, !field.multiple ? [option.value] : picked.includes(option.value) ? picked.filter((value) => value !== option.value) : [...picked, option.value]),
|
|
733
|
-
children: option.label
|
|
734
|
-
}, option.value))
|
|
735
|
-
}),
|
|
736
|
-
field.hint !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
737
|
-
className: "hint",
|
|
738
|
-
children: field.hint
|
|
739
|
-
})
|
|
740
|
-
]
|
|
741
|
-
}, `${provider.id}.${field.name}`);
|
|
742
|
-
})
|
|
743
|
-
}),
|
|
744
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
745
|
-
className: "field",
|
|
746
|
-
children: [
|
|
747
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
748
|
-
className: "label",
|
|
749
|
-
children: "Token"
|
|
750
|
-
}),
|
|
751
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
752
|
-
className: "input input-mono",
|
|
753
|
-
value: credential,
|
|
754
|
-
placeholder: provider.credential.placeholder,
|
|
755
|
-
spellCheck: false,
|
|
756
|
-
autoComplete: "off",
|
|
757
|
-
onChange: (event) => setCredential(event.target.value)
|
|
758
|
-
}),
|
|
759
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
760
|
-
className: "hint",
|
|
761
|
-
children: [
|
|
762
|
-
"The secret that holds it, as ",
|
|
763
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "project/environment/KEY" }),
|
|
764
|
-
". An environment of its own, such as ",
|
|
765
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "ops/sync" }),
|
|
766
|
-
", keeps it from everyone who reads these secrets. You need read access to it."
|
|
767
|
-
]
|
|
768
|
-
})
|
|
769
|
-
]
|
|
770
|
-
}),
|
|
771
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Notice, {
|
|
772
|
-
tone: "info",
|
|
773
|
-
children: provider.credential.hint
|
|
774
|
-
}),
|
|
775
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
|
|
776
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
777
|
-
className: "dialog-actions",
|
|
778
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
779
|
-
className: "btn",
|
|
780
|
-
type: "button",
|
|
781
|
-
onClick: onDone,
|
|
782
|
-
children: "Cancel"
|
|
783
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
784
|
-
className: "btn btn-primary",
|
|
785
|
-
type: "submit",
|
|
786
|
-
disabled: pending || missing !== null || credential.trim() === "",
|
|
787
|
-
title: missing !== null ? `${missing} is required` : void 0,
|
|
788
|
-
children: [pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Start syncing"]
|
|
789
|
-
})]
|
|
790
|
-
})
|
|
791
|
-
]
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
//#endregion
|
|
795
168
|
//#region src/routes/projects.$project.$environment.tsx?tsr-split=component
|
|
169
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
796
170
|
/**
|
|
797
171
|
* How long a revealed value stays on screen.
|
|
798
172
|
*
|
|
@@ -802,8 +176,11 @@ function AddSyncForm({ project, environment, providers, onDone }) {
|
|
|
802
176
|
*/
|
|
803
177
|
var REVEAL_TTL_SECONDS = 45;
|
|
804
178
|
function EnvironmentPage() {
|
|
805
|
-
const { keys: result, syncs } = Route.useLoaderData();
|
|
806
179
|
const { project, environment } = Route.useParams();
|
|
180
|
+
const { data: result } = useSuspenseQuery(queries.secrets(useCoffre(), {
|
|
181
|
+
project,
|
|
182
|
+
environment
|
|
183
|
+
}));
|
|
807
184
|
if (!result.ok) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClosedDoor, {
|
|
808
185
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Lock, { size: 18 }),
|
|
809
186
|
label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
@@ -827,27 +204,40 @@ function EnvironmentPage() {
|
|
|
827
204
|
project,
|
|
828
205
|
environment,
|
|
829
206
|
permissions: result.permissions,
|
|
830
|
-
keys: result.keys
|
|
831
|
-
syncs
|
|
207
|
+
keys: result.keys
|
|
832
208
|
}, `${project}/${environment}`);
|
|
833
209
|
}
|
|
834
|
-
function EnvironmentLedger({ project, environment, permissions, keys
|
|
835
|
-
const router = useRouter();
|
|
210
|
+
function EnvironmentLedger({ project, environment, permissions, keys: keys$1 }) {
|
|
836
211
|
const coffre = useCoffre();
|
|
837
|
-
const
|
|
212
|
+
const { principal } = useShell();
|
|
213
|
+
const save = useChange(saveSecrets(coffre, {
|
|
214
|
+
project,
|
|
215
|
+
environment
|
|
216
|
+
}, principal?.id ?? null));
|
|
217
|
+
const restore = useChange(restoreSecret(coffre, {
|
|
218
|
+
project,
|
|
219
|
+
environment
|
|
220
|
+
}));
|
|
221
|
+
const archive = useChange(archiveSecret(coffre, {
|
|
222
|
+
project,
|
|
223
|
+
environment
|
|
224
|
+
}));
|
|
225
|
+
const { status, dismiss } = useChangeStatus(keys.secrets({
|
|
226
|
+
project,
|
|
227
|
+
environment
|
|
228
|
+
}));
|
|
838
229
|
const [drafts, setDrafts] = (0, import_react.useState)([]);
|
|
839
230
|
const [changes, setChanges] = (0, import_react.useState)({});
|
|
840
231
|
const [editing, setEditing] = (0, import_react.useState)(() => /* @__PURE__ */ new Set());
|
|
841
|
-
const [saving, setSaving] = (0, import_react.useState)(false);
|
|
842
232
|
const [saveError, setSaveError] = (0, import_react.useState)(null);
|
|
843
233
|
const [query, setQuery] = (0, import_react.useState)(Route.useSearch().filter ?? "");
|
|
844
234
|
const nextDraftId = (0, import_react.useRef)(0);
|
|
845
235
|
const canWrite = permissions.includes("secret.write");
|
|
846
236
|
const canArchive = permissions.includes("secret.archive");
|
|
847
237
|
const canReveal = canRevealSecrets(permissions);
|
|
848
|
-
const active = keys.filter((entry) => !entry.archived);
|
|
849
|
-
const archived = keys.filter((entry) => entry.archived);
|
|
850
|
-
const existing = new Set(keys.map((entry) => entry.key));
|
|
238
|
+
const active = keys$1.filter((entry) => !entry.archived);
|
|
239
|
+
const archived = keys$1.filter((entry) => entry.archived);
|
|
240
|
+
const existing = new Set(keys$1.map((entry) => entry.key));
|
|
851
241
|
const changedEntries = active.filter((entry) => secretChangeFor(changes, entry.key) !== void 0);
|
|
852
242
|
const hasConflict = hasSecretEditConflict(active, drafts, changes);
|
|
853
243
|
const pendingNames = [...drafts.map((row) => row.key.trim()), ...changedEntries.flatMap((entry) => {
|
|
@@ -899,53 +289,47 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
899
289
|
setChanges({});
|
|
900
290
|
setEditing(/* @__PURE__ */ new Set());
|
|
901
291
|
setSaveError(null);
|
|
292
|
+
for (const entry of keys$1) {
|
|
293
|
+
const state = status(entry.key);
|
|
294
|
+
if (state.state === "failed") dismiss(state.mutationId);
|
|
295
|
+
}
|
|
902
296
|
}
|
|
903
297
|
/**
|
|
904
|
-
* Write every pending edit: renames one by one, then the
|
|
905
|
-
* that lands whole or not at all
|
|
906
|
-
*
|
|
298
|
+
* Write every pending edit (`saveSecrets`): renames one by one, then the
|
|
299
|
+
* rest as one patch that lands whole or not at all. The edits show in the
|
|
300
|
+
* list at once, each row marked as saving; whatever did not land comes
|
|
301
|
+
* back as pending, so pressing save again retries exactly that, and the
|
|
302
|
+
* save bar says why.
|
|
907
303
|
*/
|
|
908
|
-
|
|
909
|
-
if (!ready
|
|
910
|
-
|
|
911
|
-
setSaveError(null);
|
|
912
|
-
const outcome = await applySecretEditBatch({
|
|
304
|
+
function saveChanges() {
|
|
305
|
+
if (!ready) return;
|
|
306
|
+
const batch = {
|
|
913
307
|
active,
|
|
914
308
|
drafts,
|
|
915
|
-
changes
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
await coffre.secrets.rename(`${place}/${key}`, nextKey);
|
|
920
|
-
} catch (error) {
|
|
921
|
-
throw new Refusal(`${key}: ${failureMessage(error)}`);
|
|
922
|
-
}
|
|
923
|
-
},
|
|
924
|
-
write: async (patch) => {
|
|
925
|
-
try {
|
|
926
|
-
await coffre.secrets.set(place, patch);
|
|
927
|
-
} catch (error) {
|
|
928
|
-
throw new Refusal(failureMessage(error));
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
setDrafts(outcome.drafts);
|
|
934
|
-
setChanges(outcome.changes);
|
|
309
|
+
changes
|
|
310
|
+
};
|
|
311
|
+
setDrafts([]);
|
|
312
|
+
setChanges({});
|
|
935
313
|
setEditing(/* @__PURE__ */ new Set());
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
314
|
+
setSaveError(null);
|
|
315
|
+
save(batch, { onError: (error) => {
|
|
316
|
+
const left = error instanceof UnsavedEdits ? error.outcome : batch;
|
|
317
|
+
setDrafts(left.drafts);
|
|
318
|
+
setChanges(left.changes);
|
|
319
|
+
setSaveError(failureMessage(error));
|
|
320
|
+
} });
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Bring an archived secret back: in the list at once, as saving. Restoring
|
|
324
|
+
* is fully reversible, so it gets an undo rather than a confirmation
|
|
325
|
+
* dialog in front of it. Asked here, not by its row, which leaves the
|
|
326
|
+
* Archived list as soon as it is restored.
|
|
327
|
+
*/
|
|
328
|
+
function restoreSecretKey(key) {
|
|
329
|
+
restore({ key }, { onSuccess: () => toast.success(`${key} restored`, { action: {
|
|
330
|
+
label: "Undo",
|
|
331
|
+
onClick: () => archive({ key })
|
|
332
|
+
} }) });
|
|
949
333
|
}
|
|
950
334
|
const saveRef = (0, import_react.useRef)(saveChanges);
|
|
951
335
|
saveRef.current = saveChanges;
|
|
@@ -1001,7 +385,6 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1001
385
|
}), canWrite && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
1002
386
|
className: "btn btn-primary",
|
|
1003
387
|
onClick: addDraft,
|
|
1004
|
-
disabled: saving,
|
|
1005
388
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Plus, { size: 14 }), "New secret"]
|
|
1006
389
|
})] })
|
|
1007
390
|
}),
|
|
@@ -1115,8 +498,8 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1115
498
|
] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [
|
|
1116
499
|
drafts.map((draft) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DraftRow, {
|
|
1117
500
|
draft,
|
|
1118
|
-
existingVersion: keys.find((entry) => entry.key === draft.key.trim())?.version ?? null,
|
|
1119
|
-
disabled:
|
|
501
|
+
existingVersion: keys$1.find((entry) => entry.key === draft.key.trim())?.version ?? null,
|
|
502
|
+
disabled: false,
|
|
1120
503
|
onChange: (patch) => setDrafts((rows) => rows.map((row) => row.id === draft.id ? {
|
|
1121
504
|
...row,
|
|
1122
505
|
...patch
|
|
@@ -1125,6 +508,7 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1125
508
|
}, draft.id)),
|
|
1126
509
|
listed.map((entry) => {
|
|
1127
510
|
const change = secretChangeFor(changes, entry.key);
|
|
511
|
+
const state = status(entry.key);
|
|
1128
512
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SecretRow, {
|
|
1129
513
|
number: active.indexOf(entry) + 1,
|
|
1130
514
|
project,
|
|
@@ -1139,7 +523,8 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1139
523
|
canWrite,
|
|
1140
524
|
canArchive,
|
|
1141
525
|
canReveal,
|
|
1142
|
-
|
|
526
|
+
status: state,
|
|
527
|
+
disabled: state.state === "pending",
|
|
1143
528
|
columns,
|
|
1144
529
|
onEdit: () => setEditing((current) => new Set(current).add(entry.key)),
|
|
1145
530
|
onPatch: (patch) => patchChange(entry, patch),
|
|
@@ -1175,12 +560,6 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1175
560
|
})
|
|
1176
561
|
})
|
|
1177
562
|
}),
|
|
1178
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Syncs, {
|
|
1179
|
-
project,
|
|
1180
|
-
environment,
|
|
1181
|
-
result: syncs,
|
|
1182
|
-
canRun: canWrite || permissions.includes("environment.manage")
|
|
1183
|
-
}),
|
|
1184
563
|
archived.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, {
|
|
1185
564
|
labelledBy: "archived-secrets",
|
|
1186
565
|
title: "Archived",
|
|
@@ -1232,7 +611,10 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1232
611
|
environment,
|
|
1233
612
|
entry,
|
|
1234
613
|
canArchive,
|
|
1235
|
-
canReveal
|
|
614
|
+
canReveal,
|
|
615
|
+
status: status(entry.key),
|
|
616
|
+
onRestore: () => restoreSecretKey(entry.key),
|
|
617
|
+
onDismiss: dismiss
|
|
1236
618
|
}, entry.key)) })]
|
|
1237
619
|
})
|
|
1238
620
|
})
|
|
@@ -1273,19 +655,14 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1273
655
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1274
656
|
className: "btn btn-sm",
|
|
1275
657
|
onClick: discardAll,
|
|
1276
|
-
disabled: saving,
|
|
1277
658
|
children: "Discard"
|
|
1278
659
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
1279
660
|
className: "btn btn-sm btn-primary",
|
|
1280
|
-
onClick:
|
|
1281
|
-
disabled:
|
|
661
|
+
onClick: saveChanges,
|
|
662
|
+
disabled: !ready,
|
|
1282
663
|
title: "Save (⌘ Enter or Ctrl Enter)",
|
|
1283
664
|
"aria-keyshortcuts": "Meta+Enter Control+Enter",
|
|
1284
|
-
children: [
|
|
1285
|
-
saving && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { size: 13 }),
|
|
1286
|
-
"Save ",
|
|
1287
|
-
pendingCount === 1 ? "change" : `${pendingCount} changes`
|
|
1288
|
-
]
|
|
665
|
+
children: ["Save ", pendingCount === 1 ? "change" : `${pendingCount} changes`]
|
|
1289
666
|
})]
|
|
1290
667
|
}),
|
|
1291
668
|
(saveError ?? problem) !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
@@ -1300,7 +677,7 @@ function EnvironmentLedger({ project, environment, permissions, keys, syncs }) {
|
|
|
1300
677
|
}
|
|
1301
678
|
/** The display name sits beside the slug; it comes from the shell's project tree. */
|
|
1302
679
|
function EnvironmentName({ project, environment }) {
|
|
1303
|
-
const { projects } =
|
|
680
|
+
const { projects } = useShell();
|
|
1304
681
|
const name = projects.find((entry) => entry.slug === project)?.environments.find((entry) => entry.slug === environment)?.name;
|
|
1305
682
|
return name === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: name });
|
|
1306
683
|
}
|
|
@@ -1364,7 +741,7 @@ function useSecondsLeft(reveal) {
|
|
|
1364
741
|
if (reveal === null) return 0;
|
|
1365
742
|
return Math.max(0, Math.ceil(REVEAL_TTL_SECONDS - (now - reveal.at) / 1e3));
|
|
1366
743
|
}
|
|
1367
|
-
function SecretRow({ number, project, environment, entry, change, editing, canWrite, canArchive, canReveal, disabled, columns, onEdit, onPatch, onUndo, onMarkArchive }) {
|
|
744
|
+
function SecretRow({ number, project, environment, entry, change, editing, canWrite, canArchive, canReveal, status, disabled, columns, onEdit, onPatch, onUndo, onMarkArchive }) {
|
|
1368
745
|
const [reveal, setReveal] = (0, import_react.useState)(null);
|
|
1369
746
|
const coffre = useCoffre();
|
|
1370
747
|
const [revealing, setRevealing] = (0, import_react.useState)(false);
|
|
@@ -1417,7 +794,7 @@ function SecretRow({ number, project, environment, entry, change, editing, canWr
|
|
|
1417
794
|
const version = entry.version ?? 0;
|
|
1418
795
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1419
796
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
|
|
1420
|
-
className: `secret-row${state}`,
|
|
797
|
+
className: `secret-row${state} ${rowClass(status)}`,
|
|
1421
798
|
children: [
|
|
1422
799
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
1423
800
|
className: "n",
|
|
@@ -1534,7 +911,7 @@ function SecretRow({ number, project, environment, entry, change, editing, canWr
|
|
|
1534
911
|
}),
|
|
1535
912
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
1536
913
|
className: "col-actions",
|
|
1537
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
914
|
+
children: status.state === "pending" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowPending, { status }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1538
915
|
className: "acts",
|
|
1539
916
|
children: leaving ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tip, {
|
|
1540
917
|
label: "Keep",
|
|
@@ -1780,19 +1157,11 @@ function DraftRow({ draft, existingVersion, disabled, onChange, onRemove }) {
|
|
|
1780
1157
|
]
|
|
1781
1158
|
});
|
|
1782
1159
|
}
|
|
1783
|
-
function ArchivedRow({ number, project, environment, entry, canArchive, canReveal }) {
|
|
1160
|
+
function ArchivedRow({ number, project, environment, entry, canArchive, canReveal, status: state, onRestore, onDismiss }) {
|
|
1784
1161
|
const [historyOpen, setHistoryOpen] = (0, import_react.useState)(false);
|
|
1785
|
-
const coffre = useCoffre();
|
|
1786
|
-
const { pending, error, run } = useAction();
|
|
1787
|
-
function setArchived(archived) {
|
|
1788
|
-
run(() => coffre.secrets.update(`${project}/${environment}/${entry.key}`, { archived }), () => toast.success(archived ? `${entry.key} archived` : `${entry.key} restored`, { action: {
|
|
1789
|
-
label: "Undo",
|
|
1790
|
-
onClick: () => setArchived(!archived)
|
|
1791
|
-
} }));
|
|
1792
|
-
}
|
|
1793
1162
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1794
1163
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
|
|
1795
|
-
className:
|
|
1164
|
+
className: `secret-row is-archived ${rowClass(state)}`,
|
|
1796
1165
|
children: [
|
|
1797
1166
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
1798
1167
|
className: "n",
|
|
@@ -1832,16 +1201,15 @@ function ArchivedRow({ number, project, environment, entry, canArchive, canRevea
|
|
|
1832
1201
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, { size: 15 })
|
|
1833
1202
|
})
|
|
1834
1203
|
})
|
|
1835
|
-
}), canArchive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tip, {
|
|
1204
|
+
}), canArchive && (state.state === "pending" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowPending, { status: state }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tip, {
|
|
1836
1205
|
label: "Restore",
|
|
1837
1206
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1838
1207
|
className: "act act-icon",
|
|
1839
|
-
onClick:
|
|
1840
|
-
disabled: pending,
|
|
1208
|
+
onClick: onRestore,
|
|
1841
1209
|
"aria-label": `Restore ${entry.key}`,
|
|
1842
|
-
children:
|
|
1210
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RotateBack, { size: 14 })
|
|
1843
1211
|
})
|
|
1844
|
-
})]
|
|
1212
|
+
}))]
|
|
1845
1213
|
})
|
|
1846
1214
|
})
|
|
1847
1215
|
]
|
|
@@ -1861,12 +1229,10 @@ function ArchivedRow({ number, project, environment, entry, canArchive, canRevea
|
|
|
1861
1229
|
})
|
|
1862
1230
|
})
|
|
1863
1231
|
}),
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error })
|
|
1869
|
-
})
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowFailure, {
|
|
1233
|
+
status: state,
|
|
1234
|
+
columns: 5,
|
|
1235
|
+
onDismiss: () => state.state === "failed" && onDismiss(state.mutationId)
|
|
1870
1236
|
})
|
|
1871
1237
|
] });
|
|
1872
1238
|
}
|
|
@@ -2005,9 +1371,15 @@ function VersionHistory({ project, environment, secretKey, currentVersion, canWr
|
|
|
2005
1371
|
] }),
|
|
2006
1372
|
confirmLabel: `Roll back to v${version.version}`,
|
|
2007
1373
|
destructive: false,
|
|
2008
|
-
onConfirm: () => run(() => coffre.secrets.restore(`${project}/${environment}/${secretKey}`, version.version),
|
|
2009
|
-
|
|
2010
|
-
|
|
1374
|
+
onConfirm: () => run(() => coffre.secrets.restore(`${project}/${environment}/${secretKey}`, version.version), {
|
|
1375
|
+
affects: affects.secrets({
|
|
1376
|
+
project,
|
|
1377
|
+
environment
|
|
1378
|
+
}),
|
|
1379
|
+
onSuccess: () => {
|
|
1380
|
+
onRolledBack();
|
|
1381
|
+
toast.success(`${secretKey} rolled back to v${version.version}`);
|
|
1382
|
+
}
|
|
2011
1383
|
})
|
|
2012
1384
|
})
|
|
2013
1385
|
})
|
|
@@ -2061,20 +1433,29 @@ function ImportEnv({ project, environment }) {
|
|
|
2061
1433
|
const { pending, error, setError, run } = useAction();
|
|
2062
1434
|
const path = `${project}/${environment}`;
|
|
2063
1435
|
function preview() {
|
|
2064
|
-
run(() => planEnv(coffre, path, content),
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
1436
|
+
run(() => planEnv(coffre, path, content), {
|
|
1437
|
+
affects: [],
|
|
1438
|
+
onSuccess: (result) => {
|
|
1439
|
+
setProblems(result.problems);
|
|
1440
|
+
setPlan({
|
|
1441
|
+
entries: result.plan,
|
|
1442
|
+
changes: result.changes
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
2070
1445
|
});
|
|
2071
1446
|
}
|
|
2072
1447
|
function apply() {
|
|
2073
1448
|
if (plan === null) return;
|
|
2074
1449
|
const written = Object.keys(plan.changes).length;
|
|
2075
|
-
run(() => coffre.secrets.set(path, plan.changes),
|
|
2076
|
-
|
|
2077
|
-
|
|
1450
|
+
run(() => coffre.secrets.set(path, plan.changes), {
|
|
1451
|
+
affects: affects.secrets({
|
|
1452
|
+
project,
|
|
1453
|
+
environment
|
|
1454
|
+
}),
|
|
1455
|
+
onSuccess: () => {
|
|
1456
|
+
toast.success(`Imported ${written} change${written === 1 ? "" : "s"}`);
|
|
1457
|
+
close();
|
|
1458
|
+
}
|
|
2078
1459
|
});
|
|
2079
1460
|
}
|
|
2080
1461
|
function close() {
|