@coffre/ui 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{audit-sentence-CUUMshIp.js → audit-sentence-BVv_9_nq.js} +2 -2
- package/dist/chunks/{audit-sentence-CUUMshIp.js.map → audit-sentence-BVv_9_nq.js.map} +1 -1
- package/dist/chunks/{connected-apps-DTpatjge.js → connected-apps-rBF9XUob.js} +4 -4
- package/dist/chunks/{connected-apps-DTpatjge.js.map → connected-apps-rBF9XUob.js.map} +1 -1
- package/dist/chunks/{delete-place-SOOYVt6A.js → delete-place-CkGezx5R.js} +4 -4
- package/dist/chunks/{delete-place-SOOYVt6A.js.map → delete-place-CkGezx5R.js.map} +1 -1
- package/dist/chunks/{directory-DrtdKny2.js → directory-SRN01yP6.js} +21 -19
- package/dist/chunks/directory-SRN01yP6.js.map +1 -0
- package/dist/chunks/{folders-hR2Lnk0k.js → folders-Dw240WMJ.js} +2 -2
- package/dist/chunks/{folders-hR2Lnk0k.js.map → folders-Dw240WMJ.js.map} +1 -1
- package/dist/chunks/{grants-DDBui9YD.js → grants-1E1vqkM0.js} +5 -5
- package/dist/chunks/{grants-DDBui9YD.js.map → grants-1E1vqkM0.js.map} +1 -1
- package/dist/chunks/multi-combobox-CsIXihuc.js +99 -0
- package/dist/chunks/multi-combobox-CsIXihuc.js.map +1 -0
- package/dist/chunks/{offboarding-C7ECW5o0.js → offboarding-Bt7KSixm.js} +3 -3
- package/dist/chunks/{offboarding-C7ECW5o0.js.map → offboarding-Bt7KSixm.js.map} +1 -1
- package/dist/chunks/{principal-page-CB6dAABC.js → principal-page-Cbx2l6XL.js} +21 -24
- package/dist/chunks/principal-page-Cbx2l6XL.js.map +1 -0
- package/dist/chunks/{project-page-BHNUvr2L.js → project-page-DKo2AFYg.js} +2 -2
- package/dist/chunks/{project-page-BHNUvr2L.js.map → project-page-DKo2AFYg.js.map} +1 -1
- package/dist/chunks/{queries-DgQo3mC-.js → queries-BvSw1xBN.js} +85 -14
- package/dist/chunks/queries-BvSw1xBN.js.map +1 -0
- package/dist/chunks/{references-BQc35Q9g.js → references-DCoSPtvw.js} +4 -4
- package/dist/chunks/{references-BQc35Q9g.js.map → references-DCoSPtvw.js.map} +1 -1
- package/dist/chunks/{role-field-BfWRCqzl.js → role-field-D98CvNEg.js} +2 -2
- package/dist/chunks/{role-field-BfWRCqzl.js.map → role-field-D98CvNEg.js.map} +1 -1
- package/dist/chunks/{row-state-Zf3kZVhd.js → row-state-BsIHspy4.js} +2 -2
- package/dist/chunks/{row-state-Zf3kZVhd.js.map → row-state-BsIHspy4.js.map} +1 -1
- package/dist/chunks/{theme-B6-V9JvY.js → theme-3b4DnCow.js} +2 -2
- package/dist/chunks/{theme-B6-V9JvY.js.map → theme-3b4DnCow.js.map} +1 -1
- package/dist/chunks/{ui-Br-dNUTc.js → ui-2kwXXfrX.js} +95 -22
- package/dist/chunks/ui-2kwXXfrX.js.map +1 -0
- package/dist/chunks/{use-action-DthL5hL8.js → use-action-Bv7yQ0DW.js} +2 -2
- package/dist/chunks/{use-action-DthL5hL8.js.map → use-action-Bv7yQ0DW.js.map} +1 -1
- package/dist/chunks/{use-change-By4cG8bT.js → use-change-DIQTGXER.js} +58 -17
- package/dist/chunks/use-change-DIQTGXER.js.map +1 -0
- package/dist/chunks/{use-shell-D6kjSPls.js → use-shell-DhFoHjDS.js} +2 -2
- package/dist/chunks/{use-shell-D6kjSPls.js.map → use-shell-DhFoHjDS.js.map} +1 -1
- package/dist/index.d.ts +13 -164
- package/dist/index.js +141 -128
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +8 -8
- package/dist/pages/approval.js +1 -1
- package/dist/pages/audit.js +46 -60
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +1 -1
- package/dist/pages/environment.js +444 -235
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +2 -2
- package/dist/pages/oauth-authorize.js +1 -1
- package/dist/pages/project-access.js +8 -8
- package/dist/pages/project-environments.js +19 -58
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.d.ts +1 -1
- package/dist/pages/project-settings.js +54 -75
- package/dist/pages/project-settings.js.map +1 -1
- package/dist/pages/project.js +3 -7
- package/dist/pages/project.js.map +1 -1
- package/dist/pages/projects.js +50 -77
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.js +11 -136
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +4 -4
- package/dist/pages/settings.js +5 -5
- package/dist/pages/unregistered.js +1 -1
- package/dist/pages/user.js +5 -5
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/actions-log.tsx +1 -1
- package/src/components/command-palette.tsx +4 -5
- package/src/components/directory.tsx +6 -14
- package/src/components/missing.tsx +63 -67
- package/src/components/principal-page.tsx +10 -14
- package/src/components/service-tokens.tsx +2 -11
- package/src/components/shell.tsx +79 -75
- package/src/components/trusted-workloads.tsx +2 -11
- package/src/components/ui.tsx +35 -25
- package/src/lib/changes.ts +63 -12
- package/src/lib/clipboard.ts +40 -0
- package/src/lib/copy-attempts.ts +103 -0
- package/src/lib/dismissal.ts +24 -0
- package/src/lib/optimistic.ts +3 -1
- package/src/lib/queries.ts +106 -13
- package/src/lib/row-reads.ts +64 -0
- package/src/options.ts +38 -50
- package/src/pages/audit.tsx +15 -24
- package/src/pages/environment.tsx +307 -91
- package/src/pages/project-environments.tsx +8 -34
- package/src/pages/project-settings.tsx +9 -20
- package/src/pages/project.tsx +1 -5
- package/src/pages/projects.tsx +13 -28
- package/src/parity.ts +3 -3
- package/src/styles/globals.css +87 -128
- package/dist/chunks/directory-DrtdKny2.js.map +0 -1
- package/dist/chunks/principal-page-CB6dAABC.js.map +0 -1
- package/dist/chunks/project-environments-lEzFHUt4.js +0 -11
- package/dist/chunks/project-environments-lEzFHUt4.js.map +0 -1
- package/dist/chunks/queries-DgQo3mC-.js.map +0 -1
- package/dist/chunks/ui-Br-dNUTc.js.map +0 -1
- package/dist/chunks/use-change-By4cG8bT.js.map +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ErrorLine, c as Notice, d as Tip,
|
|
1
|
+
import { E as isActiveAccessibleEnvironment, i as keys, t as affects, v as queries, w as canRevealSecrets } from "../chunks/queries-BvSw1xBN.js";
|
|
2
|
+
import { a as ErrorLine, c as Notice, d as Tip, g as createCopier, h as breakAfterUnderscores, i as EmptyState, l as Spinner, n as ConfirmDialog, o as MenuPopup, r as CopyButton, s as Modal, t as ConfirmButton, u as Timestamp } from "../chunks/ui-2kwXXfrX.js";
|
|
3
3
|
import { i as SecretReadOnly } from "../chunks/affordances-Dtyha68j.js";
|
|
4
4
|
import { $ as SlashCircle, A as History, D as Generate, E as Folder, G as Plus, H as MoreHorizontal, J as Search, L as Lock, M as Key, S as Clock, T as EyeOff, W as Pencil, Z as Shuffle, _ as Check, g as ArrowRight, h as Archive, i as PageHeader, k as Hash, n as ClosedDoor, o as failureMessage, p as AlertCircle, q as RotateBack, rt as Upload, st as X, t as Card, tt as Terminal, u as useCoffre, w as Eye, x as ChevronsUpDown, y as ChevronDown } from "../chunks/page-JTORvh-N.js";
|
|
5
|
-
import { a as rowClass, i as RowPending, r as RowFailure } from "../chunks/row-state-
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import { i as secretKeyProblem } from "../chunks/validation-DiHIwZRA.js";
|
|
5
|
+
import { a as rowClass, i as RowPending, r as RowFailure } from "../chunks/row-state-BsIHspy4.js";
|
|
6
|
+
import { t as useShell } from "../chunks/use-shell-DhFoHjDS.js";
|
|
7
|
+
import { A as saveSecrets, D as restoreSecret, E as restoreMissing, M as companionsOf, N as hasSecretEditConflict, P as secretChangeFor, a as UnsavedEdits, b as missingList, i as changeOptions, m as dismissMissing, n as useChangeStatus, r as changeKey, s as archiveSecret, t as useChange, x as moveSecret } from "../chunks/use-change-DIQTGXER.js";
|
|
8
|
+
import { i as secretKeyProblem, n as folderProblem } from "../chunks/validation-DiHIwZRA.js";
|
|
10
9
|
import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
|
|
11
|
-
import { t as useAction } from "../chunks/use-action-
|
|
12
|
-
import { n as FolderRow, r as MoveToFolder, t as FolderMenu } from "../chunks/folders-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { t as useAction } from "../chunks/use-action-Bv7yQ0DW.js";
|
|
11
|
+
import { n as FolderRow, r as MoveToFolder, t as FolderMenu } from "../chunks/folders-Dw240WMJ.js";
|
|
12
|
+
import { t as MultiCombobox } from "../chunks/multi-combobox-CsIXihuc.js";
|
|
13
|
+
import { i as ReferenceValue, n as LentReferences, o as archiveBlockers, r as MakeReference, t as ArchiveBlocked } from "../chunks/references-DCoSPtvw.js";
|
|
14
|
+
import { useEffect, useId, useReducer, useRef, useState } from "react";
|
|
15
15
|
import { Link } from "@tanstack/react-router";
|
|
16
16
|
import { toast } from "sonner";
|
|
17
17
|
import { Menu } from "@base-ui/react/menu";
|
|
18
18
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
-
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|
19
|
+
import { useMutation, useQuery, useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
|
20
20
|
import { CoffreError, ageInDays, byFolder, foldersOf, olderThan, planImport, shownMember } from "@coffre/client";
|
|
21
21
|
import { parseDotenv } from "@coffre/core/dotenv";
|
|
22
22
|
//#region src/lib/reveal.ts
|
|
@@ -24,6 +24,54 @@ function revealIsCurrent(reveal, currentVersion) {
|
|
|
24
24
|
return reveal !== null && reveal.version === currentVersion;
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
|
+
//#region src/lib/row-reads.ts
|
|
28
|
+
var noReads = {
|
|
29
|
+
reveal: null,
|
|
30
|
+
revealing: false,
|
|
31
|
+
error: null,
|
|
32
|
+
copyError: null
|
|
33
|
+
};
|
|
34
|
+
function rowReads(state, action) {
|
|
35
|
+
switch (action.type) {
|
|
36
|
+
case "set-reveal": return {
|
|
37
|
+
...state,
|
|
38
|
+
reveal: action.reveal
|
|
39
|
+
};
|
|
40
|
+
case "read-started": return {
|
|
41
|
+
...state,
|
|
42
|
+
revealing: true
|
|
43
|
+
};
|
|
44
|
+
case "read-succeeded": return {
|
|
45
|
+
...state,
|
|
46
|
+
revealing: false,
|
|
47
|
+
error: null,
|
|
48
|
+
reveal: action.reveal ?? state.reveal
|
|
49
|
+
};
|
|
50
|
+
case "read-failed": return {
|
|
51
|
+
...state,
|
|
52
|
+
revealing: false,
|
|
53
|
+
error: action.message
|
|
54
|
+
};
|
|
55
|
+
case "copy-started":
|
|
56
|
+
case "copy-succeeded": return {
|
|
57
|
+
...state,
|
|
58
|
+
copyError: null
|
|
59
|
+
};
|
|
60
|
+
case "copy-failed": return {
|
|
61
|
+
...state,
|
|
62
|
+
copyError: action.message
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Whether the eye button is out of reach: while a read is on its way and there
|
|
68
|
+
* is nothing on screen yet. Once a value is shown, Hide is always available,
|
|
69
|
+
* whatever else is being read.
|
|
70
|
+
*/
|
|
71
|
+
function revealToggleDisabled(state, shown) {
|
|
72
|
+
return shown === null && state.revealing;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
27
75
|
//#region src/lib/secret-order.ts
|
|
28
76
|
/**
|
|
29
77
|
* The keys in `sort`'s order, from the listing's, by name. By age, those
|
|
@@ -579,13 +627,33 @@ function NamedValue({ label, format, name, onName, value, describedBy }) {
|
|
|
579
627
|
});
|
|
580
628
|
}
|
|
581
629
|
//#endregion
|
|
630
|
+
//#region src/lib/dismissal.ts
|
|
631
|
+
/**
|
|
632
|
+
* Dismiss missing keys, and say so at once in a toast with Undo. A refused
|
|
633
|
+
* dismissal turns that toast into why it was refused, so the reason shows
|
|
634
|
+
* whatever the list does next: when reading it again fails too, the panel
|
|
635
|
+
* has no rows left to say it beneath.
|
|
636
|
+
*/
|
|
637
|
+
function dismissWithUndo(entries, { dismiss, restore }) {
|
|
638
|
+
const said = toast.success(entries.length === 1 ? `${entries[0].key} dismissed` : `${entries.length} keys dismissed`, { action: {
|
|
639
|
+
label: "Undo",
|
|
640
|
+
onClick: () => void restore(entries).catch((error) => toast.error(`Not restored. ${failureMessage(error)}`))
|
|
641
|
+
} });
|
|
642
|
+
dismiss(entries).catch((error) => toast.error(`Not dismissed. ${failureMessage(error)}`, {
|
|
643
|
+
id: said,
|
|
644
|
+
action: void 0
|
|
645
|
+
}));
|
|
646
|
+
return said;
|
|
647
|
+
}
|
|
648
|
+
//#endregion
|
|
582
649
|
//#region src/components/missing.tsx
|
|
583
650
|
/**
|
|
584
651
|
* Keys the environment's siblings have and it lacks, by name, whether you
|
|
585
|
-
* read them or not (docs/design/environments.md): each with Add, which opens
|
|
586
|
-
* its name, and Dismiss, which the whole team then sees, and
|
|
587
|
-
* Dismiss all
|
|
588
|
-
*
|
|
652
|
+
* read them or not (docs/design/environments.md): each with Add, which opens
|
|
653
|
+
* a new row with its name, and Dismiss, which the whole team then sees, and
|
|
654
|
+
* below them Dismiss all. Nothing shows when nothing is missing, dismissed
|
|
655
|
+
* keys included: they are restored from the CLI (`coffre missing
|
|
656
|
+
* --dismissed`), or by Undo right after dismissing.
|
|
589
657
|
*/
|
|
590
658
|
function MissingKeys({ project, environment, canWrite, onAdd }) {
|
|
591
659
|
const coffre = useCoffre();
|
|
@@ -594,118 +662,84 @@ function MissingKeys({ project, environment, canWrite, onAdd }) {
|
|
|
594
662
|
environment
|
|
595
663
|
};
|
|
596
664
|
const { data } = useQuery(queries.missing(coffre, place));
|
|
597
|
-
const
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
const
|
|
602
|
-
const
|
|
603
|
-
|
|
665
|
+
const queryClient = useQueryClient();
|
|
666
|
+
const dismissKeys = useMutation(changeOptions(queryClient, dismissMissing(coffre, place))).mutateAsync;
|
|
667
|
+
const restoreKeys = useMutation(changeOptions(queryClient, restoreMissing(coffre, place))).mutateAsync;
|
|
668
|
+
const list = missingList(place);
|
|
669
|
+
const { status, dismiss: forget } = useChangeStatus(list.queryKey);
|
|
670
|
+
const missing = data === void 0 ? [] : list.items(data);
|
|
671
|
+
if (missing.length === 0) return null;
|
|
672
|
+
const columns = canWrite ? 3 : 2;
|
|
673
|
+
const dismiss = (entries) => void dismissWithUndo(entries, {
|
|
674
|
+
dismiss: dismissKeys,
|
|
675
|
+
restore: restoreKeys
|
|
676
|
+
});
|
|
677
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Card, {
|
|
604
678
|
wide: true,
|
|
605
679
|
labelledBy: "missing-keys",
|
|
606
|
-
title:
|
|
680
|
+
title: `${missing.length} ${missing.length === 1 ? "key" : "keys"} from other environments ${missing.length === 1 ? "isn't" : "aren't"} here`,
|
|
607
681
|
description: "Compared with every other environment of the project, by key name.",
|
|
608
|
-
children:
|
|
682
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
609
683
|
className: "dt-wrap",
|
|
610
684
|
children: /* @__PURE__ */ jsx("table", {
|
|
611
685
|
className: "dt stacks missing-keys",
|
|
612
|
-
children: /* @__PURE__ */
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
"
|
|
627
|
-
entry.
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
className: "
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
showDismissed && dismissed.length > 0 && /* @__PURE__ */ jsx("tr", {
|
|
652
|
-
className: "folder-row",
|
|
653
|
-
children: /* @__PURE__ */ jsx("th", {
|
|
654
|
-
colSpan: canWrite ? 3 : 2,
|
|
655
|
-
scope: "rowgroup",
|
|
656
|
-
children: "Dismissed"
|
|
657
|
-
})
|
|
658
|
-
}),
|
|
659
|
-
showDismissed && dismissed.map((entry) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
660
|
-
/* @__PURE__ */ jsx("td", {
|
|
661
|
-
className: "mono",
|
|
662
|
-
"data-label": "Key",
|
|
663
|
-
children: entry.key
|
|
664
|
-
}),
|
|
665
|
-
/* @__PURE__ */ jsxs("td", {
|
|
666
|
-
className: "cell-muted",
|
|
667
|
-
"data-label": "Dismissed",
|
|
668
|
-
children: [
|
|
669
|
-
"By ",
|
|
670
|
-
entry.dismissedBy,
|
|
671
|
-
" ",
|
|
672
|
-
/* @__PURE__ */ jsx(Timestamp, {
|
|
673
|
-
iso: entry.dismissedAt,
|
|
674
|
-
display: "relative"
|
|
675
|
-
}),
|
|
676
|
-
"; in ",
|
|
677
|
-
entry.in.join(", ")
|
|
678
|
-
]
|
|
679
|
-
}),
|
|
680
|
-
canWrite && /* @__PURE__ */ jsx("td", {
|
|
681
|
-
className: "col-actions",
|
|
682
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
683
|
-
type: "button",
|
|
684
|
-
className: "btn btn-sm",
|
|
685
|
-
disabled: pending,
|
|
686
|
-
onClick: () => dismiss({ [entry.key]: null }),
|
|
687
|
-
children: "Restore"
|
|
686
|
+
children: /* @__PURE__ */ jsx("tbody", { children: missing.map((entry) => {
|
|
687
|
+
const state = status(entry.key);
|
|
688
|
+
return [/* @__PURE__ */ jsxs("tr", {
|
|
689
|
+
className: rowClass(state),
|
|
690
|
+
children: [
|
|
691
|
+
/* @__PURE__ */ jsx("td", {
|
|
692
|
+
className: "mono",
|
|
693
|
+
"data-label": "Key",
|
|
694
|
+
children: entry.key
|
|
695
|
+
}),
|
|
696
|
+
/* @__PURE__ */ jsxs("td", {
|
|
697
|
+
className: "cell-muted",
|
|
698
|
+
"data-label": "In",
|
|
699
|
+
children: [
|
|
700
|
+
"In ",
|
|
701
|
+
entry.in.join(", "),
|
|
702
|
+
entry.folder !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
703
|
+
", in ",
|
|
704
|
+
entry.folder,
|
|
705
|
+
"/"
|
|
706
|
+
] })
|
|
707
|
+
]
|
|
708
|
+
}),
|
|
709
|
+
canWrite && /* @__PURE__ */ jsx("td", {
|
|
710
|
+
className: "col-actions",
|
|
711
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
712
|
+
className: "acts",
|
|
713
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
714
|
+
type: "button",
|
|
715
|
+
className: "btn btn-sm",
|
|
716
|
+
onClick: () => onAdd(entry.key),
|
|
717
|
+
children: "Add"
|
|
718
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
719
|
+
type: "button",
|
|
720
|
+
className: "btn btn-sm btn-quiet",
|
|
721
|
+
onClick: () => dismiss([entry]),
|
|
722
|
+
children: "Dismiss"
|
|
723
|
+
})]
|
|
724
|
+
})
|
|
688
725
|
})
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
726
|
+
]
|
|
727
|
+
}, entry.key), /* @__PURE__ */ jsx(RowFailure, {
|
|
728
|
+
status: state,
|
|
729
|
+
columns,
|
|
730
|
+
onDismiss: () => state.state === "failed" && forget(state.mutationId)
|
|
731
|
+
}, `failure:${entry.key}`)];
|
|
732
|
+
}) })
|
|
692
733
|
})
|
|
693
|
-
})
|
|
694
|
-
}), /* @__PURE__ */
|
|
734
|
+
})
|
|
735
|
+
}), canWrite && missing.length > 1 && /* @__PURE__ */ jsx("div", {
|
|
695
736
|
className: "table-actions",
|
|
696
|
-
children:
|
|
737
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
697
738
|
type: "button",
|
|
698
739
|
className: "btn",
|
|
699
|
-
|
|
700
|
-
onClick: () => dismiss(Object.fromEntries(missing.map((entry) => [entry.key, true]))),
|
|
740
|
+
onClick: () => dismiss(missing),
|
|
701
741
|
children: "Dismiss all"
|
|
702
|
-
})
|
|
703
|
-
type: "button",
|
|
704
|
-
className: "btn btn-quiet",
|
|
705
|
-
"aria-expanded": showDismissed,
|
|
706
|
-
onClick: () => setShowDismissed((open) => !open),
|
|
707
|
-
children: showDismissed ? "Hide dismissed" : `Dismissed (${dismissed.length})`
|
|
708
|
-
})]
|
|
742
|
+
})
|
|
709
743
|
})] });
|
|
710
744
|
}
|
|
711
745
|
//#endregion
|
|
@@ -719,6 +753,10 @@ var Route = pageRoute();
|
|
|
719
753
|
* already logged, and re-revealing writes a second, honest audit row.
|
|
720
754
|
*/
|
|
721
755
|
var REVEAL_TTL_SECONDS = 45;
|
|
756
|
+
/** Why a read of a secret's value failed, as the row says it. */
|
|
757
|
+
function readFailureMessage(failure) {
|
|
758
|
+
return failure instanceof CoffreError ? failureMessage(failure) : "The request could not be sent. Nothing was read.";
|
|
759
|
+
}
|
|
722
760
|
function EnvironmentPage() {
|
|
723
761
|
const { project, environment } = Route.useParams();
|
|
724
762
|
const { data: result } = useSuspenseQuery(queries.secrets(useCoffre(), {
|
|
@@ -754,6 +792,7 @@ function EnvironmentPage() {
|
|
|
754
792
|
}
|
|
755
793
|
function EnvironmentLedger({ project, environment, permissions, keys: keys$1, rotateAfterDays }) {
|
|
756
794
|
const coffre = useCoffre();
|
|
795
|
+
const queryClient = useQueryClient();
|
|
757
796
|
const { principal } = useShell();
|
|
758
797
|
const save = useChange(saveSecrets(coffre, {
|
|
759
798
|
project,
|
|
@@ -796,12 +835,14 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
796
835
|
by,
|
|
797
836
|
descending: current.by === by && !current.descending
|
|
798
837
|
}));
|
|
838
|
+
const [addingFolder, setAddingFolder] = useState(false);
|
|
799
839
|
const nextDraftId = useRef(0);
|
|
800
840
|
const canWrite = permissions.includes("secret.write");
|
|
801
841
|
const canArchive = permissions.includes("secret.archive");
|
|
802
842
|
const canReveal = canRevealSecrets(permissions);
|
|
803
843
|
const active = byFolder(keys$1.filter((entry) => !entry.archived)).flatMap(([, entries]) => entries);
|
|
804
844
|
const folders = foldersOf(active);
|
|
845
|
+
const settled = active.filter((entry) => status(entry.key).state !== "pending" && secretChangeFor(changes, entry.key) === void 0);
|
|
805
846
|
const refile = useAction();
|
|
806
847
|
const place = `${project}/${environment}`;
|
|
807
848
|
const folderMenu = (folder, count) => canWrite && /* @__PURE__ */ jsx(FolderMenu, {
|
|
@@ -893,6 +934,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
893
934
|
function sendAlone(batch) {
|
|
894
935
|
setSaveError(null);
|
|
895
936
|
save(batch, { onError: (error) => {
|
|
937
|
+
forgetRefusal(batch);
|
|
896
938
|
const left = error instanceof UnsavedEdits ? error.outcome : batch;
|
|
897
939
|
setDrafts((rows) => [...rows, ...left.drafts]);
|
|
898
940
|
setChanges((current) => ({
|
|
@@ -925,17 +967,25 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
925
967
|
setChanges({});
|
|
926
968
|
setEditing(/* @__PURE__ */ new Set());
|
|
927
969
|
setSaveError(null);
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* A refused save leaves its rows no failure of their own: its edits come
|
|
973
|
+
* back on them, and the bar under the table says why. Every other refused
|
|
974
|
+
* change, a move for one, says why beneath its row.
|
|
975
|
+
*/
|
|
976
|
+
function forgetRefusal(batch) {
|
|
977
|
+
const saves = queryClient.getMutationCache().findAll({ mutationKey: changeKey(keys.secrets({
|
|
978
|
+
project,
|
|
979
|
+
environment
|
|
980
|
+
})) });
|
|
981
|
+
for (const each of saves) if (each.state.variables === batch) dismiss(each.mutationId);
|
|
932
982
|
}
|
|
933
983
|
/**
|
|
934
984
|
* Write every pending edit (`saveSecrets`): renames one by one, then the
|
|
935
985
|
* rest as one patch that lands whole or not at all. The edits show in the
|
|
936
986
|
* list at once, each row marked as saving; whatever did not land comes
|
|
937
987
|
* back as pending, so pressing save again retries exactly that, and the
|
|
938
|
-
*
|
|
988
|
+
* bar under the table says why.
|
|
939
989
|
*/
|
|
940
990
|
function saveChanges() {
|
|
941
991
|
if (!ready) return;
|
|
@@ -949,6 +999,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
949
999
|
setEditing(/* @__PURE__ */ new Set());
|
|
950
1000
|
setSaveError(null);
|
|
951
1001
|
save(batch, { onError: (error) => {
|
|
1002
|
+
forgetRefusal(batch);
|
|
952
1003
|
const left = error instanceof UnsavedEdits ? error.outcome : batch;
|
|
953
1004
|
setDrafts(left.drafts);
|
|
954
1005
|
setChanges(left.changes);
|
|
@@ -1011,11 +1062,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
1011
1062
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1012
1063
|
/* @__PURE__ */ jsx(PageHeader, {
|
|
1013
1064
|
tile: project,
|
|
1014
|
-
title: environment
|
|
1015
|
-
aside: /* @__PURE__ */ jsx(EnvironmentName, {
|
|
1016
|
-
project,
|
|
1017
|
-
environment
|
|
1018
|
-
})
|
|
1065
|
+
title: environment
|
|
1019
1066
|
}),
|
|
1020
1067
|
(active.length > 0 || drafts.length > 0) && /* @__PURE__ */ jsxs("div", {
|
|
1021
1068
|
className: "toolbar",
|
|
@@ -1069,10 +1116,10 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
1069
1116
|
onAdd: addDraft
|
|
1070
1117
|
}),
|
|
1071
1118
|
refile.error !== null && /* @__PURE__ */ jsx(ErrorLine, { error: refile.error }),
|
|
1072
|
-
/* @__PURE__ */
|
|
1119
|
+
/* @__PURE__ */ jsxs("section", {
|
|
1073
1120
|
className: "card card-wide",
|
|
1074
1121
|
"aria-label": "Secrets",
|
|
1075
|
-
children: active.length === 0 && drafts.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
1122
|
+
children: [active.length === 0 && drafts.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
1076
1123
|
title: "No secrets yet",
|
|
1077
1124
|
children: canWrite ? "Add them one by one, or import a .env file." : "Adding secrets here needs secret.write."
|
|
1078
1125
|
}) : /* @__PURE__ */ jsx("div", {
|
|
@@ -1156,6 +1203,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
1156
1203
|
environments: readable,
|
|
1157
1204
|
status: state,
|
|
1158
1205
|
disabled: state.state === "pending",
|
|
1206
|
+
onDismiss: dismiss,
|
|
1159
1207
|
columns,
|
|
1160
1208
|
onEdit: () => setEditing((current) => new Set(current).add(entry.key)),
|
|
1161
1209
|
onPatch: (patch) => patchChange(entry, patch),
|
|
@@ -1205,18 +1253,39 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
1205
1253
|
}, draft.id))
|
|
1206
1254
|
] })]
|
|
1207
1255
|
})
|
|
1208
|
-
})
|
|
1256
|
+
}), pendingCount > 0 && /* @__PURE__ */ jsx(PendingBar, {
|
|
1257
|
+
pending,
|
|
1258
|
+
ready,
|
|
1259
|
+
error: saveError ?? problem,
|
|
1260
|
+
onDiscard: discardAll,
|
|
1261
|
+
onSave: saveChanges
|
|
1262
|
+
})]
|
|
1209
1263
|
}),
|
|
1210
1264
|
canWrite && /* @__PURE__ */ jsxs("div", {
|
|
1211
1265
|
className: "table-actions",
|
|
1212
|
-
children: [
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1266
|
+
children: [
|
|
1267
|
+
/* @__PURE__ */ jsx(AddButton, {
|
|
1268
|
+
onAddSecret: () => addDraft(),
|
|
1269
|
+
onAddFolder: () => setAddingFolder(true),
|
|
1270
|
+
canAddFolder: settled.length > 0
|
|
1271
|
+
}),
|
|
1272
|
+
canReveal && /* @__PURE__ */ jsx(ImportEnv, {
|
|
1273
|
+
project,
|
|
1274
|
+
environment
|
|
1275
|
+
}),
|
|
1276
|
+
/* @__PURE__ */ jsx(AddFolder, {
|
|
1277
|
+
open: addingFolder,
|
|
1278
|
+
onOpenChange: setAddingFolder,
|
|
1279
|
+
keys: settled.map((entry) => entry.key),
|
|
1280
|
+
folders,
|
|
1281
|
+
onAdd: (folder, keys) => {
|
|
1282
|
+
for (const entry of settled) if (keys.includes(entry.key) && entry.folder !== folder) move({
|
|
1283
|
+
key: entry.key,
|
|
1284
|
+
folder
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
})
|
|
1288
|
+
]
|
|
1220
1289
|
}),
|
|
1221
1290
|
archived.length > 0 && /* @__PURE__ */ jsx(Card, {
|
|
1222
1291
|
wide: true,
|
|
@@ -1273,68 +1342,180 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
|
|
|
1273
1342
|
}, entry.key)) })]
|
|
1274
1343
|
})
|
|
1275
1344
|
})
|
|
1276
|
-
})
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1345
|
+
})
|
|
1346
|
+
] });
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* The pending edits, at the foot of the table they are made in: what they
|
|
1350
|
+
* are, Discard and Save. It sticks to the bottom of the window while the
|
|
1351
|
+
* table runs past it, so Save stays in reach of any row.
|
|
1352
|
+
*/
|
|
1353
|
+
function PendingBar({ pending, ready, error, onDiscard, onSave }) {
|
|
1354
|
+
const count = pending.length;
|
|
1355
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1356
|
+
className: "pending-bar",
|
|
1357
|
+
role: "region",
|
|
1358
|
+
"aria-label": "Unsaved changes",
|
|
1359
|
+
children: [
|
|
1360
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1361
|
+
className: "pending-count",
|
|
1283
1362
|
children: [
|
|
1284
|
-
/* @__PURE__ */
|
|
1285
|
-
className: "
|
|
1286
|
-
|
|
1287
|
-
/* @__PURE__ */ jsx("span", {
|
|
1288
|
-
className: "dot",
|
|
1289
|
-
"aria-hidden": true
|
|
1290
|
-
}),
|
|
1291
|
-
pendingCount,
|
|
1292
|
-
" unsaved change",
|
|
1293
|
-
pendingCount === 1 ? "" : "s"
|
|
1294
|
-
]
|
|
1295
|
-
}),
|
|
1296
|
-
/* @__PURE__ */ jsxs("span", {
|
|
1297
|
-
className: "savebar-summary",
|
|
1298
|
-
children: [pending.slice(0, 3).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [
|
|
1299
|
-
index > 0 && " · ",
|
|
1300
|
-
/* @__PURE__ */ jsx("span", {
|
|
1301
|
-
className: "mono",
|
|
1302
|
-
children: item.key
|
|
1303
|
-
}),
|
|
1304
|
-
" ",
|
|
1305
|
-
item.what
|
|
1306
|
-
] }, `${item.key}:${index}`)), pending.length > 3 && ` · and ${pending.length - 3} more`]
|
|
1363
|
+
/* @__PURE__ */ jsx("span", {
|
|
1364
|
+
className: "dot",
|
|
1365
|
+
"aria-hidden": true
|
|
1307
1366
|
}),
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
children: ["Save ", pendingCount === 1 ? "change" : `${pendingCount} changes`]
|
|
1321
|
-
})]
|
|
1367
|
+
count,
|
|
1368
|
+
" unsaved change",
|
|
1369
|
+
count === 1 ? "" : "s"
|
|
1370
|
+
]
|
|
1371
|
+
}),
|
|
1372
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1373
|
+
className: "pending-summary",
|
|
1374
|
+
children: [pending.slice(0, 3).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [
|
|
1375
|
+
index > 0 && " · ",
|
|
1376
|
+
/* @__PURE__ */ jsx("span", {
|
|
1377
|
+
className: "mono",
|
|
1378
|
+
children: item.key
|
|
1322
1379
|
}),
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1380
|
+
" ",
|
|
1381
|
+
item.what
|
|
1382
|
+
] }, `${item.key}:${index}`)), count > 3 && ` · and ${count - 3} more`]
|
|
1383
|
+
}),
|
|
1384
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1385
|
+
className: "pending-actions",
|
|
1386
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1387
|
+
className: "btn btn-sm",
|
|
1388
|
+
onClick: onDiscard,
|
|
1389
|
+
children: "Discard"
|
|
1390
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
1391
|
+
className: "btn btn-sm btn-primary",
|
|
1392
|
+
onClick: onSave,
|
|
1393
|
+
disabled: !ready,
|
|
1394
|
+
title: "Save (⌘ Enter or Ctrl Enter)",
|
|
1395
|
+
"aria-keyshortcuts": "Meta+Enter Control+Enter",
|
|
1396
|
+
children: ["Save ", count === 1 ? "change" : `${count} changes`]
|
|
1397
|
+
})]
|
|
1398
|
+
}),
|
|
1399
|
+
error !== null && /* @__PURE__ */ jsxs("p", {
|
|
1400
|
+
className: "pending-error",
|
|
1401
|
+
role: "alert",
|
|
1402
|
+
children: [/* @__PURE__ */ jsx(AlertCircle, { size: 14 }), /* @__PURE__ */ jsx("span", { children: error })]
|
|
1403
|
+
})
|
|
1404
|
+
]
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Add secret, and beside it a menu of the other things to add: a folder.
|
|
1409
|
+
* One button in look, two to the keyboard and to a screen reader, the
|
|
1410
|
+
* second a menu button.
|
|
1411
|
+
*/
|
|
1412
|
+
function AddButton({ onAddSecret, onAddFolder, canAddFolder }) {
|
|
1413
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1414
|
+
className: "split-button",
|
|
1415
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
1416
|
+
className: "btn btn-primary",
|
|
1417
|
+
onClick: onAddSecret,
|
|
1418
|
+
children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "Add secret"]
|
|
1419
|
+
}), /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
|
|
1420
|
+
className: "btn btn-primary btn-icon",
|
|
1421
|
+
"aria-label": "More to add",
|
|
1422
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { size: 14 })
|
|
1423
|
+
}), /* @__PURE__ */ jsx(MenuPopup, {
|
|
1424
|
+
align: "start",
|
|
1425
|
+
children: /* @__PURE__ */ jsxs(Menu.Item, {
|
|
1426
|
+
className: "menu-item",
|
|
1427
|
+
onClick: onAddFolder,
|
|
1428
|
+
disabled: !canAddFolder,
|
|
1429
|
+
children: [
|
|
1430
|
+
/* @__PURE__ */ jsx(Folder, { size: 14 }),
|
|
1431
|
+
"Add folder…",
|
|
1432
|
+
!canAddFolder && /* @__PURE__ */ jsx("span", {
|
|
1433
|
+
className: "menu-hint",
|
|
1434
|
+
children: "after a secret"
|
|
1327
1435
|
})
|
|
1328
1436
|
]
|
|
1329
1437
|
})
|
|
1330
|
-
})
|
|
1331
|
-
|
|
1438
|
+
})] })]
|
|
1439
|
+
});
|
|
1332
1440
|
}
|
|
1333
|
-
/**
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1441
|
+
/**
|
|
1442
|
+
* A new folder, and the secrets filed in it. A folder is a name on what it
|
|
1443
|
+
* holds (docs/design/environments.md), so it is made with its first
|
|
1444
|
+
* secrets: one with nothing in it would not be there to see.
|
|
1445
|
+
*/
|
|
1446
|
+
function AddFolder({ open, onOpenChange, keys, folders, onAdd }) {
|
|
1447
|
+
const [name, setName] = useState("");
|
|
1448
|
+
const [chosen, setChosen] = useState([]);
|
|
1449
|
+
useEffect(() => {
|
|
1450
|
+
if (!open) return;
|
|
1451
|
+
setName("");
|
|
1452
|
+
setChosen([]);
|
|
1453
|
+
}, [open]);
|
|
1454
|
+
const problem = folderProblem(name);
|
|
1455
|
+
const joins = folders.includes(name);
|
|
1456
|
+
const ready = name !== "" && problem === null && chosen.length > 0;
|
|
1457
|
+
return /* @__PURE__ */ jsx(Modal, {
|
|
1458
|
+
open,
|
|
1459
|
+
onOpenChange,
|
|
1460
|
+
title: "Add a folder",
|
|
1461
|
+
description: "Folders only arrange the list: names, values and access stay as they are.",
|
|
1462
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
1463
|
+
className: "form",
|
|
1464
|
+
onSubmit: (event) => {
|
|
1465
|
+
event.preventDefault();
|
|
1466
|
+
if (!ready) return;
|
|
1467
|
+
onAdd(name, chosen);
|
|
1468
|
+
onOpenChange(false);
|
|
1469
|
+
},
|
|
1470
|
+
children: [
|
|
1471
|
+
/* @__PURE__ */ jsxs("label", {
|
|
1472
|
+
className: "field",
|
|
1473
|
+
children: [
|
|
1474
|
+
/* @__PURE__ */ jsx("span", {
|
|
1475
|
+
className: "label",
|
|
1476
|
+
children: "Name"
|
|
1477
|
+
}),
|
|
1478
|
+
/* @__PURE__ */ jsx("input", {
|
|
1479
|
+
className: "input",
|
|
1480
|
+
autoFocus: true,
|
|
1481
|
+
spellCheck: false,
|
|
1482
|
+
autoComplete: "off",
|
|
1483
|
+
value: name,
|
|
1484
|
+
"aria-invalid": problem !== null,
|
|
1485
|
+
onChange: (event) => setName(event.target.value)
|
|
1486
|
+
}),
|
|
1487
|
+
/* @__PURE__ */ jsx("span", {
|
|
1488
|
+
className: `hint${problem !== null ? " edit-note-error" : ""}`,
|
|
1489
|
+
children: problem ?? (joins ? `${name} is in use: the secrets join it.` : "One level: no slash.")
|
|
1490
|
+
})
|
|
1491
|
+
]
|
|
1492
|
+
}),
|
|
1493
|
+
/* @__PURE__ */ jsx(MultiCombobox, {
|
|
1494
|
+
label: "Secrets in it",
|
|
1495
|
+
options: keys,
|
|
1496
|
+
value: chosen,
|
|
1497
|
+
onChange: setChosen,
|
|
1498
|
+
placeholder: "Pick one or more…",
|
|
1499
|
+
hint: "A folder holds at least one secret.",
|
|
1500
|
+
mono: true
|
|
1501
|
+
}),
|
|
1502
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1503
|
+
className: "dialog-actions",
|
|
1504
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1505
|
+
className: "btn",
|
|
1506
|
+
type: "button",
|
|
1507
|
+
onClick: () => onOpenChange(false),
|
|
1508
|
+
children: "Cancel"
|
|
1509
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1510
|
+
className: "btn btn-primary",
|
|
1511
|
+
type: "submit",
|
|
1512
|
+
disabled: !ready,
|
|
1513
|
+
children: "Add folder"
|
|
1514
|
+
})]
|
|
1515
|
+
})
|
|
1516
|
+
]
|
|
1517
|
+
})
|
|
1518
|
+
});
|
|
1338
1519
|
}
|
|
1339
1520
|
var lineCount = (text) => text.split("\n").length;
|
|
1340
1521
|
function ValueField({ label, value, start = "", onChange, placeholder, disabled, autoFocus, onEscape, generate }) {
|
|
@@ -1447,10 +1628,14 @@ function useSecondsLeft(reveal) {
|
|
|
1447
1628
|
if (reveal === null) return 0;
|
|
1448
1629
|
return Math.max(0, Math.ceil(REVEAL_TTL_SECONDS - (now - reveal.at) / 1e3));
|
|
1449
1630
|
}
|
|
1450
|
-
function SecretRow({ number, project, environment, entry, rotateAfterDays, change, editing, canWrite, canArchive, canReveal, folders, onMove, lent, environments, status, disabled, columns, onEdit, onPatch, onUndo, onSave, versionOf, saveReady, onMarkArchive }) {
|
|
1451
|
-
const [
|
|
1631
|
+
function SecretRow({ number, project, environment, entry, rotateAfterDays, change, editing, canWrite, canArchive, canReveal, folders, onMove, lent, environments, status, disabled, onDismiss, columns, onEdit, onPatch, onUndo, onSave, versionOf, saveReady, onMarkArchive }) {
|
|
1632
|
+
const [reads, dispatch] = useReducer(rowReads, noReads);
|
|
1633
|
+
const { reveal, revealing, error, copyError } = reads;
|
|
1634
|
+
const setReveal = (next) => dispatch({
|
|
1635
|
+
type: "set-reveal",
|
|
1636
|
+
reveal: next
|
|
1637
|
+
});
|
|
1452
1638
|
const coffre = useCoffre();
|
|
1453
|
-
const [revealing, setRevealing] = useState(false);
|
|
1454
1639
|
const [historyOpen, setHistoryOpen] = useState(false);
|
|
1455
1640
|
const [moving, setMoving] = useState(false);
|
|
1456
1641
|
const [referring, setReferring] = useState(false);
|
|
@@ -1462,7 +1647,6 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
|
|
|
1462
1647
|
const { reference } = entry;
|
|
1463
1648
|
const readVersion = reference === null ? entry.version : reference.version;
|
|
1464
1649
|
const holderPath = `${project}/${environment}/${entry.key}`;
|
|
1465
|
-
const [error, setError] = useState(null);
|
|
1466
1650
|
const [base, setBase] = useState(null);
|
|
1467
1651
|
const shown = revealIsCurrent(reveal, readVersion) ? reveal : null;
|
|
1468
1652
|
useEffect(() => {
|
|
@@ -1480,28 +1664,51 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
|
|
|
1480
1664
|
}, [editing]);
|
|
1481
1665
|
async function readValue({ show = true } = {}) {
|
|
1482
1666
|
if (shown !== null) return shown.value;
|
|
1483
|
-
|
|
1667
|
+
dispatch({ type: "read-started" });
|
|
1484
1668
|
try {
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1669
|
+
const value = await fetchValue();
|
|
1670
|
+
dispatch({
|
|
1671
|
+
type: "read-succeeded",
|
|
1672
|
+
reveal: show ? {
|
|
1673
|
+
value,
|
|
1674
|
+
version: readVersion,
|
|
1675
|
+
at: Date.now()
|
|
1676
|
+
} : null
|
|
1492
1677
|
});
|
|
1493
1678
|
return value;
|
|
1494
1679
|
} catch (failure) {
|
|
1495
|
-
|
|
1680
|
+
dispatch({
|
|
1681
|
+
type: "read-failed",
|
|
1682
|
+
message: readFailureMessage(failure)
|
|
1683
|
+
});
|
|
1496
1684
|
return null;
|
|
1497
|
-
} finally {
|
|
1498
|
-
setRevealing(false);
|
|
1499
1685
|
}
|
|
1500
1686
|
}
|
|
1687
|
+
async function fetchValue() {
|
|
1688
|
+
const { values } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
|
|
1689
|
+
return values[entry.key];
|
|
1690
|
+
}
|
|
1501
1691
|
function toggleReveal() {
|
|
1502
1692
|
if (shown !== null) setReveal(null);
|
|
1503
1693
|
else readValue();
|
|
1504
1694
|
}
|
|
1695
|
+
const [copier] = useState(() => createCopier());
|
|
1696
|
+
function copyValue() {
|
|
1697
|
+
dispatch({ type: "copy-started" });
|
|
1698
|
+
const read = { failed: false };
|
|
1699
|
+
const text = shown !== null ? shown.value : fetchValue().catch((failure) => {
|
|
1700
|
+
read.failed = true;
|
|
1701
|
+
read.failure = failure;
|
|
1702
|
+
throw failure;
|
|
1703
|
+
});
|
|
1704
|
+
copier.run(text).then((result) => {
|
|
1705
|
+
if (result.outcome === "superseded") return;
|
|
1706
|
+
dispatch(result.outcome === "copied" ? { type: "copy-succeeded" } : {
|
|
1707
|
+
type: "copy-failed",
|
|
1708
|
+
message: read.failed ? readFailureMessage(read.failure) : "The browser did not allow copying to the clipboard. Reveal the value and copy it by hand."
|
|
1709
|
+
});
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1505
1712
|
const [opening, setOpening] = useState(false);
|
|
1506
1713
|
const [focusName, setFocusName] = useState(false);
|
|
1507
1714
|
async function startEdit({ name = false } = {}) {
|
|
@@ -1670,36 +1877,33 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
|
|
|
1670
1877
|
"aria-label": leaving ? `Keep ${entry.key}` : `Cancel editing ${entry.key}`,
|
|
1671
1878
|
children: /* @__PURE__ */ jsx(X, { size: 15 })
|
|
1672
1879
|
})
|
|
1673
|
-
})] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1674
|
-
|
|
1880
|
+
})] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(SecretReadOnly, {
|
|
1881
|
+
canReveal,
|
|
1882
|
+
children: [/* @__PURE__ */ jsx(CopyButton, {
|
|
1675
1883
|
variant: "act",
|
|
1676
|
-
|
|
1884
|
+
copier,
|
|
1885
|
+
onCopy: copyValue,
|
|
1677
1886
|
label: `Copy ${entry.key}`
|
|
1678
|
-
}),
|
|
1679
|
-
|
|
1680
|
-
canReveal,
|
|
1681
|
-
children: /* @__PURE__ */ jsx(Tip, {
|
|
1682
|
-
label: shown === null ? "Reveal" : "Hide",
|
|
1683
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
1684
|
-
className: "act act-icon act-accent",
|
|
1685
|
-
onClick: toggleReveal,
|
|
1686
|
-
disabled: revealing,
|
|
1687
|
-
"aria-label": `${shown === null ? "Reveal" : "Hide"} ${entry.key}`,
|
|
1688
|
-
children: revealing && !opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : shown === null ? /* @__PURE__ */ jsx(Eye, { size: 15 }) : /* @__PURE__ */ jsx(EyeOff, { size: 15 })
|
|
1689
|
-
})
|
|
1690
|
-
})
|
|
1691
|
-
}),
|
|
1692
|
-
canWrite && /* @__PURE__ */ jsx(Tip, {
|
|
1693
|
-
label: "Edit",
|
|
1887
|
+
}), /* @__PURE__ */ jsx(Tip, {
|
|
1888
|
+
label: shown === null ? "Reveal" : "Hide",
|
|
1694
1889
|
children: /* @__PURE__ */ jsx("button", {
|
|
1695
|
-
className: "act act-icon",
|
|
1696
|
-
onClick:
|
|
1697
|
-
disabled:
|
|
1698
|
-
"aria-label":
|
|
1699
|
-
children: opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : /* @__PURE__ */ jsx(
|
|
1890
|
+
className: "act act-icon act-accent",
|
|
1891
|
+
onClick: toggleReveal,
|
|
1892
|
+
disabled: revealToggleDisabled(reads, shown),
|
|
1893
|
+
"aria-label": `${shown === null ? "Reveal" : "Hide"} ${entry.key}`,
|
|
1894
|
+
children: revealing && !opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : shown === null ? /* @__PURE__ */ jsx(Eye, { size: 15 }) : /* @__PURE__ */ jsx(EyeOff, { size: 15 })
|
|
1700
1895
|
})
|
|
1896
|
+
})]
|
|
1897
|
+
}), canWrite && /* @__PURE__ */ jsx(Tip, {
|
|
1898
|
+
label: "Edit",
|
|
1899
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1900
|
+
className: "act act-icon",
|
|
1901
|
+
onClick: () => void startEdit(),
|
|
1902
|
+
disabled: disabled || revealing,
|
|
1903
|
+
"aria-label": `Edit ${entry.key}`,
|
|
1904
|
+
children: opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : /* @__PURE__ */ jsx(Pencil, { size: 14 })
|
|
1701
1905
|
})
|
|
1702
|
-
] })
|
|
1906
|
+
})] })
|
|
1703
1907
|
})]
|
|
1704
1908
|
})
|
|
1705
1909
|
}),
|
|
@@ -1867,12 +2071,17 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
|
|
|
1867
2071
|
})
|
|
1868
2072
|
})
|
|
1869
2073
|
}),
|
|
1870
|
-
(error ?? actError) !== null
|
|
2074
|
+
(error ?? actError) !== null || copyError !== null ? /* @__PURE__ */ jsx("tr", {
|
|
1871
2075
|
className: "row-error",
|
|
1872
|
-
children: /* @__PURE__ */
|
|
2076
|
+
children: /* @__PURE__ */ jsxs("td", {
|
|
1873
2077
|
colSpan: columns,
|
|
1874
|
-
children: /* @__PURE__ */ jsx(ErrorLine, { error: error ?? actError })
|
|
2078
|
+
children: [/* @__PURE__ */ jsx(ErrorLine, { error: error ?? actError }), /* @__PURE__ */ jsx(ErrorLine, { error: copyError })]
|
|
1875
2079
|
})
|
|
2080
|
+
}) : null,
|
|
2081
|
+
/* @__PURE__ */ jsx(RowFailure, {
|
|
2082
|
+
status,
|
|
2083
|
+
columns,
|
|
2084
|
+
onDismiss: () => status.state === "failed" && onDismiss(status.mutationId)
|
|
1876
2085
|
})
|
|
1877
2086
|
] });
|
|
1878
2087
|
}
|