@coffre/ui 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/_coffre/assets/account-BJAdDvZf.js +2 -0
- package/dist/client/_coffre/assets/account-D0jLpk5c.js +1 -0
- package/dist/client/_coffre/assets/affordances-Bq2-oUB5.js +1 -0
- package/dist/client/_coffre/assets/audit-C-pcBgKe.js +2 -0
- package/dist/client/_coffre/assets/audit-CHGlDeBB.js +1 -0
- package/dist/client/_coffre/assets/{auth.device-BP5FY0K1.js → auth.device-BndOUjse.js} +1 -1
- package/dist/client/_coffre/assets/auth.device-CWHNQn9W.js +2 -0
- package/dist/client/_coffre/assets/directory-nDExpkAz.js +1 -0
- package/dist/client/_coffre/assets/dist-QVHMLatb.js +1 -0
- package/dist/client/_coffre/assets/globals-CKBoTlyH.css +1 -0
- package/dist/client/_coffre/assets/grants-CjoOnxzz.js +1 -0
- package/dist/client/_coffre/assets/icons-BQ27Ds9u.js +1 -0
- package/dist/client/_coffre/assets/index-CUGytaO3.js +12 -0
- package/dist/client/_coffre/assets/link-DP8SVWon.js +1 -0
- package/dist/client/_coffre/assets/login-CeaxDMcr.js +2 -0
- package/dist/client/_coffre/assets/login-DrMgvqZn.js +1 -0
- package/dist/client/_coffre/assets/offboarding-CNr_1tnl.js +1 -0
- package/dist/client/_coffre/assets/page-CGmvjSy4.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-ClBkJ19f.js +1 -0
- package/dist/client/_coffre/assets/principal-page-DNLb_q_e.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CHzbboGp.js +3 -0
- package/dist/client/_coffre/assets/projects._project._environment-DDxu_HHD.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-CIAsjvg6.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DZ9l6d-1.js +1 -0
- package/dist/client/_coffre/assets/projects.index-4eUXreE_.js +1 -0
- package/dist/client/_coffre/assets/row-state-ByET1OKX.js +1 -0
- package/dist/client/_coffre/assets/settings-D2zp1Ssu.js +1 -0
- package/dist/client/_coffre/assets/suspense-C7KwSnTG.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-DWmbqzNk.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-Dui_4KfS.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-CSi5Wxwf.js +1 -0
- package/dist/client/_coffre/assets/ui-BdipqGpP.js +46 -0
- package/dist/client/_coffre/assets/unregistered-CA7B4C1m.js +1 -0
- package/dist/client/_coffre/assets/use-action-DRm9yVhV.js +1 -0
- package/dist/client/_coffre/assets/use-change-BRRMJocl.js +1 -0
- package/dist/client/_coffre/assets/use-shell-BMGlJ25Q.js +1 -0
- package/dist/client/_coffre/assets/useQuery-D__2KBOs.js +1 -0
- package/dist/client/_coffre/assets/useSuspenseQuery-CSXyDALB.js +1 -0
- package/dist/client/_coffre/assets/users._user-BkNrX7Qf.js +1 -0
- package/dist/client/_coffre/assets/users._user-jbSvtdOg.js +2 -0
- package/dist/client/_coffre/assets/users.index-CKnQ1G76.js +1 -0
- package/dist/server/.vite/manifest.json +343 -246
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-Dx-c3XVk.js +162 -0
- package/dist/server/_coffre/assets/{account-CUQYGCYh.js → account-BocTPU1J.js} +150 -117
- package/dist/server/_coffre/assets/{account-DMlUoBxQ.js → account-CL8hOGhO.js} +10 -24
- package/dist/server/_coffre/assets/{affordances-BNaXjMOb.js → affordances-CKANXDTG.js} +2 -22
- package/dist/server/_coffre/assets/{async-local-storage-C0cwgkEr.js → async-local-storage-C10uQtMM.js} +3 -2
- package/dist/server/_coffre/assets/{audit-CCdSLmvK.js → audit-Bcka4vA6.js} +46 -16
- package/dist/server/_coffre/assets/audit-CSRQYIhu.js +31 -0
- package/dist/server/_coffre/assets/{auth.device-C05u5ROO.js → auth.device-CMcUISZY.js} +7 -5
- package/dist/server/_coffre/assets/{auth.device-BoFM1jcf.js → auth.device-DqO0T-rU.js} +5 -5
- package/dist/server/_coffre/assets/{directory-GsnYkse0.js → directory-CyYx6Jx1.js} +87 -112
- package/dist/server/_coffre/assets/{use-action-DwEmf58L.js → dist-CnnV3t2g.js} +3 -48
- package/dist/server/_coffre/assets/globals-CKBoTlyH.css +1 -0
- package/dist/server/_coffre/assets/grants-CRijabX0.js +158 -0
- package/dist/server/_coffre/assets/{page-BdnhpwvH.js → icons-Dy-5ccDF.js} +3 -196
- package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +480 -0
- package/dist/server/_coffre/assets/link-42ZWdjzZ.js +422 -0
- package/dist/server/_coffre/assets/{login-DUtCQju5.js → login-BI9tzJEy.js} +7 -5
- package/dist/server/_coffre/assets/{login-B2njIq_o.js → login-C-v88YwP.js} +2 -2
- package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +56 -0
- package/dist/server/_coffre/assets/{offboarding-8yMa7ViM.js → offboarding-1H0LavTd.js} +6 -4
- package/dist/server/_coffre/assets/page-D_mO0-sn.js +3592 -0
- package/dist/server/_coffre/assets/{principal-page-B8zPcS2b.js → principal-page-DQDoXute.js} +51 -42
- package/dist/server/_coffre/assets/{projects._project._environment-BZ5Z80V8.js → projects._project._environment-C-yVwC92.js} +168 -248
- package/dist/server/_coffre/assets/{projects._project._environment-DdIOc7wx.js → projects._project._environment-D_5R40of.js} +4 -11
- package/dist/server/_coffre/assets/{projects._project.index-CuEAUwGn.js → projects._project.index-A2BImFIT.js} +134 -96
- package/dist/server/_coffre/assets/{projects._project.index-DvbcU1kh.js → projects._project.index-BPPKxKrt.js} +5 -4
- package/dist/server/_coffre/assets/{projects.index-5HI0wOuG.js → projects.index-543IsPzY.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-CM3vK8QO.js} +376 -92
- package/dist/server/_coffre/assets/row-state-XBtDoIA4.js +117 -0
- package/dist/server/_coffre/assets/{settings-BVz78wjP.js → settings-BLVU74ym.js} +8 -6
- package/dist/server/_coffre/assets/suspense-CzYTwxOj.js +602 -0
- package/dist/server/_coffre/assets/tokens._token-B-hBgwBW.js +10 -0
- package/dist/server/_coffre/assets/{tokens._token-CWs3Mtki.js → tokens._token-aubAUonP.js} +97 -79
- package/dist/server/_coffre/assets/{tokens.index-Ck0LN7aC.js → tokens.index-4D3jwp5v.js} +9 -6
- package/dist/server/_coffre/assets/{ui-D_slKpSF.js → ui-BI3Bf72q.js} +7 -836
- package/dist/server/_coffre/assets/{unregistered-Z17da4Rc.js → unregistered-CagDxMyw.js} +5 -3
- package/dist/server/_coffre/assets/use-action-tzBZvjjQ.js +47 -0
- package/dist/server/_coffre/assets/use-change-Dggqxy5y.js +1212 -0
- package/dist/server/_coffre/assets/use-shell-CwStDfzX.js +462 -0
- package/dist/server/_coffre/assets/useQuery-C6_dBjem.js +8 -0
- package/dist/server/_coffre/assets/{useStore-DWGPqzXR.js → useRouter-CaUSUNsw.js} +1 -420
- package/dist/server/_coffre/assets/useSuspenseQuery-BuapQt_P.js +117 -0
- package/dist/server/_coffre/assets/{users._user-CMwj-VI9.js → users._user-137WNyxn.js} +4 -5
- package/dist/server/_coffre/assets/users._user-C252Iilj.js +10 -0
- package/dist/server/_coffre/assets/{users.index-fWHv6A30.js → users.index-DQHsfnal.js} +9 -6
- package/dist/server/index.js +6 -5
- package/package.json +5 -3
- package/src/components/directory.tsx +75 -104
- package/src/components/grants.tsx +60 -112
- package/src/components/principal-page.tsx +54 -67
- package/src/components/principal-picker.tsx +7 -16
- package/src/components/row-state.tsx +95 -0
- package/src/components/service-tokens.tsx +75 -64
- package/src/components/shell.tsx +1 -1
- package/src/components/syncs.tsx +42 -26
- package/src/lib/announce.ts +36 -0
- package/src/lib/changes.ts +498 -0
- package/src/lib/optimistic.ts +233 -0
- package/src/lib/queries.ts +393 -0
- package/src/lib/use-action.ts +20 -15
- package/src/lib/use-change.ts +42 -0
- package/src/lib/use-shell.ts +17 -0
- package/src/router.tsx +17 -9
- package/src/routes/__root.tsx +8 -38
- package/src/routes/account.tsx +163 -154
- package/src/routes/audit.tsx +51 -72
- package/src/routes/auth.device.tsx +4 -2
- package/src/routes/login.tsx +3 -2
- package/src/routes/projects.$project.$environment.tsx +226 -231
- package/src/routes/projects.$project.index.tsx +136 -118
- package/src/routes/projects.index.tsx +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/styles/globals.css +78 -1
- 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-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
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useId, useState } from 'react';
|
|
2
3
|
import { Link } from '@tanstack/react-router';
|
|
3
4
|
import { useCoffre } from '../lib/coffre';
|
|
5
|
+
import { queries } from '../lib/queries';
|
|
4
6
|
import { projectAccessLabel } from '../lib/project-access';
|
|
5
7
|
import type { DirectoryPrincipal, GrantRow } from '../shared/models';
|
|
6
|
-
import { KIND
|
|
8
|
+
import { KIND } from './directory';
|
|
7
9
|
import { PrincipalAvatar } from './principal';
|
|
8
10
|
import { Spinner } from './ui';
|
|
9
11
|
import { Check, Search } from './icons';
|
|
10
12
|
|
|
11
13
|
type PrincipalType = DirectoryPrincipal['principalType'];
|
|
12
|
-
type Directory = Awaited<ReturnType<typeof loadDirectory>>;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Who a grant is for: picked from the registered users or tokens, each shown
|
|
@@ -19,7 +20,8 @@ type Directory = Awaited<ReturnType<typeof loadDirectory>>;
|
|
|
19
20
|
* Only instance owners may list the directory. Asking on anyone else's behalf
|
|
20
21
|
* would write a refusal to the audit log in their name, so they get a text
|
|
21
22
|
* field and the server's answer instead. The list is asked for when the
|
|
22
|
-
* dialog opens rather than with the page, since most visits never open it
|
|
23
|
+
* dialog opens rather than with the page, since most visits never open it,
|
|
24
|
+
* and shared with the Users and Tokens pages through the cache.
|
|
23
25
|
*/
|
|
24
26
|
export function PrincipalPicker({
|
|
25
27
|
principalType,
|
|
@@ -37,23 +39,12 @@ export function PrincipalPicker({
|
|
|
37
39
|
onChange: (principalId: string) => void;
|
|
38
40
|
}) {
|
|
39
41
|
const coffre = useCoffre();
|
|
40
|
-
const
|
|
42
|
+
const directory = useQuery(queries.directory(coffre, canList)).data ?? null;
|
|
41
43
|
const [query, setQuery] = useState('');
|
|
42
44
|
const name = useId();
|
|
43
45
|
const kind = KIND[principalType];
|
|
44
46
|
const label = principalType === 'user' ? 'User' : 'Token';
|
|
45
47
|
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (!canList) return;
|
|
48
|
-
let live = true;
|
|
49
|
-
void loadDirectory(coffre, true).then((result) => {
|
|
50
|
-
if (live) setDirectory(result);
|
|
51
|
-
});
|
|
52
|
-
return () => {
|
|
53
|
-
live = false;
|
|
54
|
-
};
|
|
55
|
-
}, [canList, coffre]);
|
|
56
|
-
|
|
57
48
|
if (!canList || directory?.ok === false) {
|
|
58
49
|
return (
|
|
59
50
|
<label className="field">
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useSyncExternalStore, type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { announcements, serverAnnouncements, subscribeAnnouncements } from '../lib/announce';
|
|
4
|
+
import type { ItemStatus } from '../lib/optimistic';
|
|
5
|
+
import { Spinner } from './ui';
|
|
6
|
+
import { AlertCircle, X } from './icons';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* How a row looks while a change to it is on its way, or after the server
|
|
10
|
+
* refused it. Never colour alone: a waiting row is quieter and says what it
|
|
11
|
+
* waits for, a row being removed is struck through as well, and a refused
|
|
12
|
+
* change says so in words beneath its row.
|
|
13
|
+
*/
|
|
14
|
+
export function rowClass(status: ItemStatus): string {
|
|
15
|
+
if (status.state === 'pending') return status.kind === 'removing' ? 'is-removing' : 'is-saving';
|
|
16
|
+
if (status.state === 'failed') return 'is-failed';
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** In place of a row's actions while its change is on its way. */
|
|
21
|
+
export function RowPending({ status }: { status: ItemStatus }) {
|
|
22
|
+
if (status.state !== 'pending') return null;
|
|
23
|
+
return (
|
|
24
|
+
<span className="row-pending">
|
|
25
|
+
<Spinner size={13} />
|
|
26
|
+
{status.words.pending}
|
|
27
|
+
</span>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Beneath a row whose change the server refused: why, until dismissed. */
|
|
32
|
+
export function RowFailure({
|
|
33
|
+
status,
|
|
34
|
+
columns,
|
|
35
|
+
onDismiss,
|
|
36
|
+
children,
|
|
37
|
+
}: {
|
|
38
|
+
status: ItemStatus;
|
|
39
|
+
columns: number;
|
|
40
|
+
onDismiss: () => void;
|
|
41
|
+
/** Said before the reason; by default, what did not happen. */
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
}) {
|
|
44
|
+
if (status.state !== 'failed') return null;
|
|
45
|
+
return (
|
|
46
|
+
<tr className="row-error row-failure">
|
|
47
|
+
<td colSpan={columns}>
|
|
48
|
+
<ItemFailure status={status} onDismiss={onDismiss}>
|
|
49
|
+
{children}
|
|
50
|
+
</ItemFailure>
|
|
51
|
+
</td>
|
|
52
|
+
</tr>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Why the server refused a change, where it shows: under a row, or in a card. */
|
|
57
|
+
export function ItemFailure({
|
|
58
|
+
status,
|
|
59
|
+
onDismiss,
|
|
60
|
+
children,
|
|
61
|
+
}: {
|
|
62
|
+
status: ItemStatus;
|
|
63
|
+
onDismiss: () => void;
|
|
64
|
+
children?: ReactNode;
|
|
65
|
+
}) {
|
|
66
|
+
if (status.state !== 'failed') return null;
|
|
67
|
+
return (
|
|
68
|
+
<div className="row-failure-line">
|
|
69
|
+
<p className="error-line">
|
|
70
|
+
<AlertCircle size={14} />
|
|
71
|
+
<span>
|
|
72
|
+
<strong>{children ?? status.words.failed}</strong> {status.error}
|
|
73
|
+
</span>
|
|
74
|
+
</p>
|
|
75
|
+
<button type="button" className="act act-quiet" onClick={onDismiss} aria-label="Dismiss">
|
|
76
|
+
<X size={13} />
|
|
77
|
+
</button>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Where changes are announced to screen readers (`lib/announce.ts`). */
|
|
83
|
+
export function LiveRegion() {
|
|
84
|
+
const { polite, urgent } = useSyncExternalStore(subscribeAnnouncements, announcements, serverAnnouncements);
|
|
85
|
+
return (
|
|
86
|
+
<>
|
|
87
|
+
<div className="visually-hidden" role="status" aria-live="polite" aria-atomic="true">
|
|
88
|
+
{polite !== null && <span key={polite.id}>{polite.text}</span>}
|
|
89
|
+
</div>
|
|
90
|
+
<div className="visually-hidden" role="alert" aria-live="assertive" aria-atomic="true">
|
|
91
|
+
{urgent !== null && <span key={urgent.id}>{urgent.text}</span>}
|
|
92
|
+
</div>
|
|
93
|
+
</>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ServiceTokenRow } from '@coffre/client';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import {
|
|
2
|
+
import { Fragment, useState } from 'react';
|
|
3
|
+
import { revokeCredential } from '../lib/changes';
|
|
4
4
|
import { memberRef, useCoffre } from '../lib/coffre';
|
|
5
|
+
import { affects } from '../lib/queries';
|
|
5
6
|
import { useAction } from '../lib/use-action';
|
|
7
|
+
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
8
|
+
import { RowFailure, RowPending, rowClass } from './row-state';
|
|
6
9
|
import { Card } from './page';
|
|
7
10
|
import { ConfirmButton, CopyButton, EmptyState, ErrorLine, Modal, Notice, Spinner, Timestamp } from './ui';
|
|
8
11
|
import { Key, Plus, X } from './icons';
|
|
@@ -14,8 +17,9 @@ const LIFETIMES = [30, 90, 180, 365] as const;
|
|
|
14
17
|
* one place, this dialog, for as long as it stays open: coffre keeps a hash.
|
|
15
18
|
*/
|
|
16
19
|
export function ServiceTokens({ serviceId, tokens }: { serviceId: string; tokens: ServiceTokenRow[] }) {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
20
|
+
const change = revokeCredential(useCoffre(), serviceId);
|
|
21
|
+
const revoke = useChange(change);
|
|
22
|
+
const { status, dismiss } = useChangeStatus(change.list.queryKey);
|
|
19
23
|
|
|
20
24
|
return (
|
|
21
25
|
<Card
|
|
@@ -24,11 +28,6 @@ export function ServiceTokens({ serviceId, tokens }: { serviceId: string; tokens
|
|
|
24
28
|
description="Bearer tokens this service presents to the API. Each is shown once, when it is issued; coffre keeps only a hash."
|
|
25
29
|
actions={<IssueToken serviceId={serviceId} />}
|
|
26
30
|
>
|
|
27
|
-
{error !== null && (
|
|
28
|
-
<div className="card-body">
|
|
29
|
-
<ErrorLine error={error} />
|
|
30
|
-
</div>
|
|
31
|
-
)}
|
|
32
31
|
{tokens.length === 0 ? (
|
|
33
32
|
<EmptyState title="No live credentials">
|
|
34
33
|
Nothing can act as this service until a token is issued.
|
|
@@ -48,61 +47,70 @@ export function ServiceTokens({ serviceId, tokens }: { serviceId: string; tokens
|
|
|
48
47
|
</tr>
|
|
49
48
|
</thead>
|
|
50
49
|
<tbody>
|
|
51
|
-
{tokens.map((token) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
<span
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
50
|
+
{tokens.map((token) => {
|
|
51
|
+
const state = status(token.id);
|
|
52
|
+
return (
|
|
53
|
+
<Fragment key={token.id}>
|
|
54
|
+
<tr className={rowClass(state)}>
|
|
55
|
+
<td>
|
|
56
|
+
<span className="cell-account">
|
|
57
|
+
<Key size={15} />
|
|
58
|
+
<span className="cell-stack">
|
|
59
|
+
<span>{token.label ?? 'Unlabelled'}</span>
|
|
60
|
+
<small className="mono">{token.hint}</small>
|
|
61
|
+
</span>
|
|
62
|
+
</span>
|
|
63
|
+
</td>
|
|
64
|
+
<td className="nowrap">
|
|
65
|
+
<span className="cell-stack">
|
|
66
|
+
<Timestamp iso={token.createdAt} />
|
|
67
|
+
<small>by {token.createdBy}</small>
|
|
68
|
+
</span>
|
|
69
|
+
</td>
|
|
70
|
+
<td className="nowrap cell-muted">
|
|
71
|
+
{token.lastUsedAt === null ? (
|
|
72
|
+
'Never'
|
|
73
|
+
) : (
|
|
74
|
+
<span className="cell-stack">
|
|
75
|
+
<Timestamp iso={token.lastUsedAt} display="relative" />
|
|
76
|
+
{token.lastUsedIp !== null && <small className="mono">{token.lastUsedIp}</small>}
|
|
77
|
+
</span>
|
|
78
|
+
)}
|
|
79
|
+
</td>
|
|
80
|
+
<td className="nowrap cell-muted">
|
|
81
|
+
<Timestamp iso={token.expiresAt} display="relative" />
|
|
82
|
+
</td>
|
|
83
|
+
<td className="col-actions">
|
|
84
|
+
{state.state === 'pending' ? (
|
|
85
|
+
<RowPending status={state} />
|
|
86
|
+
) : (
|
|
87
|
+
<ConfirmButton
|
|
88
|
+
trigger={
|
|
89
|
+
<button className="act">
|
|
90
|
+
<X size={13} />
|
|
91
|
+
Revoke
|
|
92
|
+
</button>
|
|
93
|
+
}
|
|
94
|
+
title={
|
|
95
|
+
<>
|
|
96
|
+
Revoke <span className="mono">{token.hint}</span>?
|
|
97
|
+
</>
|
|
98
|
+
}
|
|
99
|
+
body="Whatever uses it is refused from its next request. Issue a new token first if the service should keep working."
|
|
100
|
+
confirmLabel="Revoke token"
|
|
101
|
+
onConfirm={() => revoke(token)}
|
|
102
|
+
/>
|
|
103
|
+
)}
|
|
104
|
+
</td>
|
|
105
|
+
</tr>
|
|
106
|
+
<RowFailure
|
|
107
|
+
status={state}
|
|
108
|
+
columns={5}
|
|
109
|
+
onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
|
|
102
110
|
/>
|
|
103
|
-
</
|
|
104
|
-
|
|
105
|
-
)
|
|
111
|
+
</Fragment>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
106
114
|
</tbody>
|
|
107
115
|
</table>
|
|
108
116
|
</div>
|
|
@@ -148,7 +156,10 @@ function IssueToken({ serviceId }: { serviceId: string }) {
|
|
|
148
156
|
label: label.trim() === '' ? null : label.trim(),
|
|
149
157
|
expiresInDays: days,
|
|
150
158
|
}),
|
|
151
|
-
|
|
159
|
+
{
|
|
160
|
+
affects: affects.credentials(memberRef('service', serviceId)),
|
|
161
|
+
onSuccess: (credential) => setIssued(credential),
|
|
162
|
+
},
|
|
152
163
|
);
|
|
153
164
|
}}
|
|
154
165
|
>
|
package/src/components/shell.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState, type ReactNode } from 'react';
|
|
2
|
-
import { Link,
|
|
2
|
+
import { Link, useNavigate, useRouterState } from '@tanstack/react-router';
|
|
3
3
|
import { Dialog, DropdownMenu } from 'radix-ui';
|
|
4
4
|
import type { ProjectSummary } from '../shared/models';
|
|
5
5
|
import type { UiCapabilities } from '../lib/capabilities';
|
package/src/components/syncs.tsx
CHANGED
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
type FormValues,
|
|
8
8
|
type SyncProviderInfo,
|
|
9
9
|
} from '@coffre/client';
|
|
10
|
+
import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
|
|
10
11
|
import { Fragment, useEffect, useState, type ReactNode } from 'react';
|
|
11
|
-
import { useRouter } from '@tanstack/react-router';
|
|
12
12
|
import { DropdownMenu } from 'radix-ui';
|
|
13
13
|
import { toast } from 'sonner';
|
|
14
14
|
import { uiResult, useCoffre } from '../lib/coffre';
|
|
15
|
+
import { affects, queries, refresh } from '../lib/queries';
|
|
15
16
|
import { useAction } from '../lib/use-action';
|
|
16
17
|
import type { RunOutcome, SyncView } from '../shared/models';
|
|
17
18
|
import { Card } from './page';
|
|
@@ -23,8 +24,6 @@ const RUNNING_POLL_MS = 2000;
|
|
|
23
24
|
/** How long a new sync's toast waits for its first push to end. */
|
|
24
25
|
const FIRST_RUN_WAIT_MS = 60_000;
|
|
25
26
|
|
|
26
|
-
type SyncsResult = { ok: true; syncs: SyncView[]; canManage: boolean } | { ok: false; error: string };
|
|
27
|
-
|
|
28
27
|
/**
|
|
29
28
|
* Where this environment's secrets are pushed.
|
|
30
29
|
*
|
|
@@ -34,23 +33,19 @@ type SyncsResult = { ok: true; syncs: SyncView[]; canManage: boolean } | { ok: f
|
|
|
34
33
|
export function Syncs({
|
|
35
34
|
project,
|
|
36
35
|
environment,
|
|
37
|
-
result,
|
|
38
36
|
canRun,
|
|
39
37
|
}: {
|
|
40
38
|
project: string;
|
|
41
39
|
environment: string;
|
|
42
|
-
result: SyncsResult;
|
|
43
40
|
canRun: boolean;
|
|
44
41
|
}) {
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return () => clearInterval(timer);
|
|
53
|
-
}, [running, router]);
|
|
42
|
+
const place = { project, environment };
|
|
43
|
+
const { data: result } = useSuspenseQuery({
|
|
44
|
+
...queries.syncs(useCoffre(), place),
|
|
45
|
+
// A save starts a run in the background; watch it land.
|
|
46
|
+
refetchInterval: (query) =>
|
|
47
|
+
query.state.data?.ok === true && query.state.data.syncs.some((sync) => sync.running) ? RUNNING_POLL_MS : false,
|
|
48
|
+
});
|
|
54
49
|
|
|
55
50
|
if (result.ok && result.syncs.length === 0 && !result.canManage) return null;
|
|
56
51
|
const canManage = result.ok && result.canManage;
|
|
@@ -86,7 +81,7 @@ export function Syncs({
|
|
|
86
81
|
</thead>
|
|
87
82
|
<tbody>
|
|
88
83
|
{result.syncs.map((sync) => (
|
|
89
|
-
<SyncRow key={sync.id} sync={sync} canRun={canRun} canManage={canManage} />
|
|
84
|
+
<SyncRow key={sync.id} place={place} sync={sync} canRun={canRun} canManage={canManage} />
|
|
90
85
|
))}
|
|
91
86
|
</tbody>
|
|
92
87
|
</table>
|
|
@@ -96,7 +91,17 @@ export function Syncs({
|
|
|
96
91
|
);
|
|
97
92
|
}
|
|
98
93
|
|
|
99
|
-
function SyncRow({
|
|
94
|
+
function SyncRow({
|
|
95
|
+
place,
|
|
96
|
+
sync,
|
|
97
|
+
canRun,
|
|
98
|
+
canManage,
|
|
99
|
+
}: {
|
|
100
|
+
place: { project: string; environment: string };
|
|
101
|
+
sync: SyncView;
|
|
102
|
+
canRun: boolean;
|
|
103
|
+
canManage: boolean;
|
|
104
|
+
}) {
|
|
100
105
|
const [removing, setRemoving] = useState(false);
|
|
101
106
|
const coffre = useCoffre();
|
|
102
107
|
// Apart, so pausing does not spin the Run now button.
|
|
@@ -108,17 +113,20 @@ function SyncRow({ sync, canRun, canManage }: { sync: SyncView; canRun: boolean;
|
|
|
108
113
|
function runNow() {
|
|
109
114
|
pushing.run(
|
|
110
115
|
() => coffre.syncs.run(sync.id),
|
|
111
|
-
(result) => announce(sync, result.outcome),
|
|
116
|
+
{ affects: affects.syncs(place), onSuccess: (result) => announce(sync, result.outcome) },
|
|
112
117
|
);
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
function setPaused(paused: boolean) {
|
|
116
121
|
managing.run(
|
|
117
122
|
() => coffre.syncs.update(sync.id, { paused }),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
{
|
|
124
|
+
affects: affects.syncs(place),
|
|
125
|
+
onSuccess: () =>
|
|
126
|
+
toast.success(paused ? `Paused ${sync.destination}` : `Resumed ${sync.destination}`, {
|
|
127
|
+
action: { label: 'Undo', onClick: () => setPaused(!paused) },
|
|
128
|
+
}),
|
|
129
|
+
},
|
|
122
130
|
);
|
|
123
131
|
}
|
|
124
132
|
|
|
@@ -207,7 +215,10 @@ function SyncRow({ sync, canRun, canManage }: { sync: SyncView; canRun: boolean;
|
|
|
207
215
|
onConfirm={() =>
|
|
208
216
|
managing.run(
|
|
209
217
|
() => coffre.syncs.remove(sync.id),
|
|
210
|
-
|
|
218
|
+
{
|
|
219
|
+
affects: affects.syncs(place),
|
|
220
|
+
onSuccess: () => toast.success(`No longer syncing to ${sync.destination}`),
|
|
221
|
+
},
|
|
211
222
|
)
|
|
212
223
|
}
|
|
213
224
|
/>
|
|
@@ -437,7 +448,7 @@ function AddSyncForm({
|
|
|
437
448
|
const [values, setValues] = useState<FormValues>(() => initialValues(providers[0]));
|
|
438
449
|
const [credential, setCredential] = useState('');
|
|
439
450
|
const coffre = useCoffre();
|
|
440
|
-
const
|
|
451
|
+
const queryClient = useQueryClient();
|
|
441
452
|
const { pending, error, setError, run } = useAction();
|
|
442
453
|
const missing = firstMissing(provider, values);
|
|
443
454
|
|
|
@@ -464,9 +475,14 @@ function AddSyncForm({
|
|
|
464
475
|
config: configFromForm(provider, values),
|
|
465
476
|
credential: credential.trim(),
|
|
466
477
|
}),
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
478
|
+
{
|
|
479
|
+
affects: affects.syncs({ project, environment }),
|
|
480
|
+
onSuccess: (sync) => {
|
|
481
|
+
onDone();
|
|
482
|
+
void followFirstRun(coffre, `${project}/${environment}`, sync, () =>
|
|
483
|
+
refresh(queryClient, affects.syncs({ project, environment })),
|
|
484
|
+
);
|
|
485
|
+
},
|
|
470
486
|
},
|
|
471
487
|
);
|
|
472
488
|
}}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a screen reader hears of a change: that it is on its way, that it
|
|
3
|
+
* landed, or why it did not. Changes show on screen as dimmed or struck-out
|
|
4
|
+
* rows; this says the same in words, through two live regions in the shell
|
|
5
|
+
* (`LiveRegion`), one polite and one for failures, which interrupts.
|
|
6
|
+
*/
|
|
7
|
+
export type Announcement = { text: string; id: number };
|
|
8
|
+
|
|
9
|
+
type Heard = { polite: Announcement | null; urgent: Announcement | null };
|
|
10
|
+
|
|
11
|
+
let heard: Heard = { polite: null, urgent: null };
|
|
12
|
+
let next = 0;
|
|
13
|
+
const listeners = new Set<() => void>();
|
|
14
|
+
|
|
15
|
+
export function announce(text: string, { urgent = false }: { urgent?: boolean } = {}): void {
|
|
16
|
+
// A fresh id, so the same words said twice are heard twice.
|
|
17
|
+
const said = { text, id: next++ };
|
|
18
|
+
heard = urgent ? { ...heard, urgent: said } : { ...heard, polite: said };
|
|
19
|
+
for (const listener of listeners) listener();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function subscribeAnnouncements(listener: () => void): () => void {
|
|
23
|
+
listeners.add(listener);
|
|
24
|
+
return () => listeners.delete(listener);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function announcements(): Heard {
|
|
28
|
+
return heard;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const nobody: Heard = { polite: null, urgent: null };
|
|
32
|
+
|
|
33
|
+
/** On the server nothing has been said yet. */
|
|
34
|
+
export function serverAnnouncements(): Heard {
|
|
35
|
+
return nobody;
|
|
36
|
+
}
|