@coffre/ui 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/_coffre/assets/account-BJAdDvZf.js +2 -0
- package/dist/client/_coffre/assets/account-D0jLpk5c.js +1 -0
- package/dist/client/_coffre/assets/affordances-Bq2-oUB5.js +1 -0
- package/dist/client/_coffre/assets/audit-C-pcBgKe.js +2 -0
- package/dist/client/_coffre/assets/audit-CHGlDeBB.js +1 -0
- package/dist/client/_coffre/assets/{auth.device--rDR2F8w.js → auth.device-BndOUjse.js} +1 -1
- package/dist/client/_coffre/assets/auth.device-CWHNQn9W.js +2 -0
- package/dist/client/_coffre/assets/directory-nDExpkAz.js +1 -0
- package/dist/client/_coffre/assets/dist-QVHMLatb.js +1 -0
- package/dist/client/_coffre/assets/globals-CKBoTlyH.css +1 -0
- package/dist/client/_coffre/assets/grants-CjoOnxzz.js +1 -0
- package/dist/client/_coffre/assets/icons-BQ27Ds9u.js +1 -0
- package/dist/client/_coffre/assets/index-CUGytaO3.js +12 -0
- package/dist/client/_coffre/assets/link-DP8SVWon.js +1 -0
- package/dist/client/_coffre/assets/login-CeaxDMcr.js +2 -0
- package/dist/client/_coffre/assets/login-DrMgvqZn.js +1 -0
- package/dist/client/_coffre/assets/offboarding-CNr_1tnl.js +1 -0
- package/dist/client/_coffre/assets/page-CGmvjSy4.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-ClBkJ19f.js +1 -0
- package/dist/client/_coffre/assets/principal-page-DNLb_q_e.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CHzbboGp.js +3 -0
- package/dist/client/_coffre/assets/projects._project._environment-DDxu_HHD.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-CIAsjvg6.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DZ9l6d-1.js +1 -0
- package/dist/client/_coffre/assets/projects.index-4eUXreE_.js +1 -0
- package/dist/client/_coffre/assets/row-state-ByET1OKX.js +1 -0
- package/dist/client/_coffre/assets/settings-D2zp1Ssu.js +1 -0
- package/dist/client/_coffre/assets/suspense-C7KwSnTG.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-DWmbqzNk.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-Dui_4KfS.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-CSi5Wxwf.js +1 -0
- package/dist/client/_coffre/assets/ui-BdipqGpP.js +46 -0
- package/dist/client/_coffre/assets/unregistered-CA7B4C1m.js +1 -0
- package/dist/client/_coffre/assets/use-action-DRm9yVhV.js +1 -0
- package/dist/client/_coffre/assets/use-change-BRRMJocl.js +1 -0
- package/dist/client/_coffre/assets/use-shell-BMGlJ25Q.js +1 -0
- package/dist/client/_coffre/assets/useQuery-D__2KBOs.js +1 -0
- package/dist/client/_coffre/assets/useSuspenseQuery-CSXyDALB.js +1 -0
- package/dist/client/_coffre/assets/users._user-BkNrX7Qf.js +1 -0
- package/dist/client/_coffre/assets/users._user-jbSvtdOg.js +2 -0
- package/dist/client/_coffre/assets/users.index-CKnQ1G76.js +1 -0
- package/dist/server/.vite/manifest.json +343 -246
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-Dx-c3XVk.js +162 -0
- package/dist/server/_coffre/assets/{account-CZgVVZTf.js → account-BocTPU1J.js} +150 -117
- package/dist/server/_coffre/assets/{account-D7-ZAE2T.js → account-CL8hOGhO.js} +10 -24
- package/dist/server/_coffre/assets/{affordances-BNaXjMOb.js → affordances-CKANXDTG.js} +2 -22
- package/dist/server/_coffre/assets/{async-local-storage-C0cwgkEr.js → async-local-storage-C10uQtMM.js} +3 -2
- package/dist/server/_coffre/assets/{audit-BEbhtsEp.js → audit-Bcka4vA6.js} +46 -16
- package/dist/server/_coffre/assets/audit-CSRQYIhu.js +31 -0
- package/dist/server/_coffre/assets/{auth.device-w9N3FlNk.js → auth.device-CMcUISZY.js} +7 -5
- package/dist/server/_coffre/assets/{auth.device-CMR3csAI.js → auth.device-DqO0T-rU.js} +5 -5
- package/dist/server/_coffre/assets/{directory-Dr5X9TB5.js → directory-CyYx6Jx1.js} +87 -112
- package/dist/server/_coffre/assets/{use-action-DQUmeH-5.js → dist-CnnV3t2g.js} +3 -48
- package/dist/server/_coffre/assets/globals-CKBoTlyH.css +1 -0
- package/dist/server/_coffre/assets/grants-CRijabX0.js +158 -0
- package/dist/server/_coffre/assets/{page-BdnhpwvH.js → icons-Dy-5ccDF.js} +3 -196
- package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +480 -0
- package/dist/server/_coffre/assets/link-42ZWdjzZ.js +422 -0
- package/dist/server/_coffre/assets/{login-DUtCQju5.js → login-BI9tzJEy.js} +7 -5
- package/dist/server/_coffre/assets/{login-B2njIq_o.js → login-C-v88YwP.js} +2 -2
- package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +56 -0
- package/dist/server/_coffre/assets/{offboarding-DY5MarpG.js → offboarding-1H0LavTd.js} +6 -4
- package/dist/server/_coffre/assets/page-D_mO0-sn.js +3592 -0
- package/dist/server/_coffre/assets/{principal-page-SdG8_zcu.js → principal-page-DQDoXute.js} +51 -42
- package/dist/server/_coffre/assets/{projects._project._environment-CUS0VFUe.js → projects._project._environment-C-yVwC92.js} +168 -248
- package/dist/server/_coffre/assets/{projects._project._environment-BQIrmE3r.js → projects._project._environment-D_5R40of.js} +4 -11
- package/dist/server/_coffre/assets/{projects._project.index-D1NxvBtZ.js → projects._project.index-A2BImFIT.js} +134 -96
- package/dist/server/_coffre/assets/{projects._project.index-BjNdR4KC.js → projects._project.index-BPPKxKrt.js} +5 -4
- package/dist/server/_coffre/assets/{projects.index-BQDuuh6t.js → projects.index-543IsPzY.js} +62 -54
- package/dist/server/_coffre/assets/{react-dom-qCTiwGGR.js → react-dom-bBoJXlK2.js} +417 -51
- package/dist/server/_coffre/assets/{router-BUwZOXEH.js → router-CM3vK8QO.js} +376 -92
- package/dist/server/_coffre/assets/row-state-XBtDoIA4.js +117 -0
- package/dist/server/_coffre/assets/{settings-HOErM3pd.js → settings-BLVU74ym.js} +8 -6
- package/dist/server/_coffre/assets/suspense-CzYTwxOj.js +602 -0
- package/dist/server/_coffre/assets/tokens._token-B-hBgwBW.js +10 -0
- package/dist/server/_coffre/assets/{tokens._token-BZUArbzi.js → tokens._token-aubAUonP.js} +97 -79
- package/dist/server/_coffre/assets/{tokens.index-BReCgoV9.js → tokens.index-4D3jwp5v.js} +9 -6
- package/dist/server/_coffre/assets/{ui-D_slKpSF.js → ui-BI3Bf72q.js} +7 -836
- package/dist/server/_coffre/assets/{unregistered-Z17da4Rc.js → unregistered-CagDxMyw.js} +5 -3
- package/dist/server/_coffre/assets/use-action-tzBZvjjQ.js +47 -0
- package/dist/server/_coffre/assets/use-change-Dggqxy5y.js +1212 -0
- package/dist/server/_coffre/assets/use-shell-CwStDfzX.js +462 -0
- package/dist/server/_coffre/assets/useQuery-C6_dBjem.js +8 -0
- package/dist/server/_coffre/assets/{useStore-DWGPqzXR.js → useRouter-CaUSUNsw.js} +1 -420
- package/dist/server/_coffre/assets/useSuspenseQuery-BuapQt_P.js +117 -0
- package/dist/server/_coffre/assets/{users._user-DHTNhQ9o.js → users._user-137WNyxn.js} +4 -5
- package/dist/server/_coffre/assets/users._user-C252Iilj.js +10 -0
- package/dist/server/_coffre/assets/{users.index-Cfo3ODpX.js → users.index-DQHsfnal.js} +9 -6
- package/dist/server/index.js +6 -5
- package/package.json +5 -3
- package/src/components/directory.tsx +75 -104
- package/src/components/grants.tsx +60 -112
- package/src/components/principal-page.tsx +54 -67
- package/src/components/principal-picker.tsx +7 -16
- package/src/components/row-state.tsx +95 -0
- package/src/components/service-tokens.tsx +75 -64
- package/src/components/shell.tsx +1 -1
- package/src/components/syncs.tsx +42 -26
- package/src/lib/announce.ts +36 -0
- package/src/lib/changes.ts +498 -0
- package/src/lib/coffre.ts +3 -2
- package/src/lib/optimistic.ts +233 -0
- package/src/lib/queries.ts +393 -0
- package/src/lib/use-action.ts +20 -15
- package/src/lib/use-change.ts +42 -0
- package/src/lib/use-shell.ts +17 -0
- package/src/router.tsx +17 -9
- package/src/routes/__root.tsx +8 -38
- package/src/routes/account.tsx +163 -154
- package/src/routes/audit.tsx +51 -72
- package/src/routes/auth.device.tsx +4 -2
- package/src/routes/login.tsx +3 -2
- package/src/routes/projects.$project.$environment.tsx +226 -231
- package/src/routes/projects.$project.index.tsx +136 -118
- package/src/routes/projects.index.tsx +125 -145
- package/src/routes/settings.tsx +7 -7
- package/src/routes/tokens.$token.tsx +14 -17
- package/src/routes/tokens.index.tsx +8 -4
- package/src/routes/unregistered.tsx +3 -2
- package/src/routes/users.$user.tsx +4 -4
- package/src/routes/users.index.tsx +8 -4
- package/src/styles/globals.css +78 -1
- package/dist/client/_coffre/assets/account-C3rBPdu6.js +0 -2
- package/dist/client/_coffre/assets/account-J194gi6l.js +0 -1
- package/dist/client/_coffre/assets/affordances-CmoY-8Xf.js +0 -1
- package/dist/client/_coffre/assets/audit-BtI9em7Q.js +0 -2
- package/dist/client/_coffre/assets/audit-jURfT8Km.js +0 -1
- package/dist/client/_coffre/assets/auth.device-viDUwZRT.js +0 -2
- package/dist/client/_coffre/assets/coffre-CXkp3Efg.js +0 -1
- package/dist/client/_coffre/assets/directory-PEjdb8PS.js +0 -1
- package/dist/client/_coffre/assets/globals-Bh2x1gBM.css +0 -1
- package/dist/client/_coffre/assets/grants-4mSkXPU4.js +0 -1
- package/dist/client/_coffre/assets/index-CD7bvUCb.js +0 -12
- package/dist/client/_coffre/assets/login-C-wTm_t1.js +0 -2
- package/dist/client/_coffre/assets/login-CLLv1om9.js +0 -1
- package/dist/client/_coffre/assets/offboarding-DQ-56W0H.js +0 -1
- package/dist/client/_coffre/assets/page-DbSS7pYH.js +0 -1
- package/dist/client/_coffre/assets/preload-helper-DduCCcmc.js +0 -46
- package/dist/client/_coffre/assets/principal-page-DjH1cUyz.js +0 -1
- package/dist/client/_coffre/assets/projects._project._environment-BZnNvENc.js +0 -3
- package/dist/client/_coffre/assets/projects._project._environment-CLUpTvi-.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-CWXRo307.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-Dzgf95zv.js +0 -1
- package/dist/client/_coffre/assets/projects.index-BG8W91BX.js +0 -2
- package/dist/client/_coffre/assets/projects.index-N_kCFBMq.js +0 -1
- package/dist/client/_coffre/assets/settings-CNIY0--5.js +0 -1
- package/dist/client/_coffre/assets/settings-EimGqlQL.js +0 -2
- package/dist/client/_coffre/assets/tokens._token-CkU4dCwo.js +0 -1
- package/dist/client/_coffre/assets/tokens._token-Df2R8TF_.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-CSf5Mlz8.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-DtiWrKVq.js +0 -1
- package/dist/client/_coffre/assets/unregistered-D5go1AfR.js +0 -1
- package/dist/client/_coffre/assets/use-action-CUvWPRTx.js +0 -1
- package/dist/client/_coffre/assets/users._user-CImGVpYj.js +0 -1
- package/dist/client/_coffre/assets/users._user-D0JK911L.js +0 -2
- package/dist/client/_coffre/assets/users.index-B-7o0KBD.js +0 -1
- package/dist/client/_coffre/assets/users.index-BoFWF3mF.js +0 -2
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-CrnrBINO.js +0 -133
- package/dist/server/_coffre/assets/audit-wjpo1BWg.js +0 -74
- package/dist/server/_coffre/assets/coffre-DMs96kfX.js +0 -280
- package/dist/server/_coffre/assets/globals-Bh2x1gBM.css +0 -1
- package/dist/server/_coffre/assets/grants-C6UmWE8b.js +0 -243
- package/dist/server/_coffre/assets/projects.index-ha7jO4nC.js +0 -54
- package/dist/server/_coffre/assets/settings-Cy__khNA.js +0 -18
- package/dist/server/_coffre/assets/tokens._token-CmpmtfB_.js +0 -18
- package/dist/server/_coffre/assets/tokens.index-B5-4dD4C.js +0 -10
- package/dist/server/_coffre/assets/users._user-BKdSQhIg.js +0 -10
- package/dist/server/_coffre/assets/users.index-dMn0tlmc.js +0 -10
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import type { CoffreClient } from '@coffre/client';
|
|
2
1
|
import { useState } from 'react';
|
|
2
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
3
3
|
import { createFileRoute, Link } from '@tanstack/react-router';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { createProject, projectsList } from '../lib/changes';
|
|
5
|
+
import { useCoffre } from '../lib/coffre';
|
|
6
|
+
import type { ItemStatus } from '../lib/optimistic';
|
|
7
|
+
import { queries } from '../lib/queries';
|
|
8
|
+
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
9
|
+
import { useShell } from '../lib/use-shell';
|
|
8
10
|
import type { ProjectSummary } from '../shared/models';
|
|
9
11
|
import { isActiveAccessibleEnvironment } from '../lib/project-environments';
|
|
10
12
|
import { slugProblem } from '../lib/validation';
|
|
11
|
-
import {
|
|
13
|
+
import { RowFailure, RowPending, rowClass } from '../components/row-state';
|
|
14
|
+
import { EmptyState, Modal } from '../components/ui';
|
|
12
15
|
import { ClosedDoor, PageHeader } from '../components/page';
|
|
13
16
|
import { Tile } from '../components/tile';
|
|
14
17
|
import { AlertTriangle, Folder, Hash, Layers, Plus } from '../components/icons';
|
|
@@ -18,54 +21,15 @@ import {
|
|
|
18
21
|
} from '../components/affordances';
|
|
19
22
|
|
|
20
23
|
export const Route = createFileRoute('/projects/')({
|
|
21
|
-
loader:
|
|
22
|
-
const result = await uiResult(async () => {
|
|
23
|
-
const [me, { projects }] = await Promise.all([client.me(), client.projects.list()]);
|
|
24
|
-
return { projects, capabilities: deriveUiCapabilities(me, projects) };
|
|
25
|
-
});
|
|
26
|
-
return { result, secrets: result.ok ? await countSecrets(client, result.projects) : {} };
|
|
27
|
-
},
|
|
24
|
+
loader: ({ context: { client, queryClient } }) => queryClient.fetchQuery(queries.projects(client)),
|
|
28
25
|
component: ProjectsPage,
|
|
29
26
|
});
|
|
30
27
|
|
|
31
|
-
/**
|
|
32
|
-
* Distinct secret names per project, across the environments you can open.
|
|
33
|
-
*
|
|
34
|
-
* The project summary only counts secrets per environment, and the same key
|
|
35
|
-
* in dev and prod is one secret, not two. So this lists the keys of every
|
|
36
|
-
* environment you can open and counts the names. Listing keys reads no value
|
|
37
|
-
* and writes no audit row. Environments you cannot open are not asked: the
|
|
38
|
-
* refusal would be audited.
|
|
39
|
-
*
|
|
40
|
-
* A project whose keys could not all be listed gets no count rather than a
|
|
41
|
-
* short one.
|
|
42
|
-
*/
|
|
43
|
-
async function countSecrets(
|
|
44
|
-
client: CoffreClient,
|
|
45
|
-
projects: ProjectSummary[],
|
|
46
|
-
): Promise<Record<string, number | null>> {
|
|
47
|
-
const counts = await Promise.all(
|
|
48
|
-
projects
|
|
49
|
-
.filter((project) => project.archivedAt === null)
|
|
50
|
-
.map(async (project) => {
|
|
51
|
-
const environments = project.environments.filter(isActiveAccessibleEnvironment);
|
|
52
|
-
if (environments.length === 0) return [project.slug, null] as const;
|
|
53
|
-
const lists = await Promise.all(
|
|
54
|
-
environments.map((environment) => uiResult(() => client.secrets.list(`${project.slug}/${environment.slug}`))),
|
|
55
|
-
);
|
|
56
|
-
const names = new Set<string>();
|
|
57
|
-
for (const list of lists) {
|
|
58
|
-
if (!list.ok) return [project.slug, null] as const;
|
|
59
|
-
for (const key of list.keys) if (!key.archived) names.add(key.key);
|
|
60
|
-
}
|
|
61
|
-
return [project.slug, names.size] as const;
|
|
62
|
-
}),
|
|
63
|
-
);
|
|
64
|
-
return Object.fromEntries(counts);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
28
|
function ProjectsPage() {
|
|
68
|
-
const { result,
|
|
29
|
+
const { data: result, refetch } = useSuspenseQuery(queries.projects(useCoffre()));
|
|
30
|
+
const { capabilities } = useShell();
|
|
31
|
+
const { failedAdds } = useChangeStatus(projectsList.queryKey);
|
|
32
|
+
const refusedProjects = result.ok ? failedAdds(result.projects.map((project) => project.slug)) : [];
|
|
69
33
|
|
|
70
34
|
if (!result.ok) {
|
|
71
35
|
return (
|
|
@@ -73,9 +37,16 @@ function ProjectsPage() {
|
|
|
73
37
|
icon={<AlertTriangle size={18} />}
|
|
74
38
|
title="Projects could not be listed"
|
|
75
39
|
actions={
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
40
|
+
result.signedOut ? (
|
|
41
|
+
<Link className="btn" to="/login">
|
|
42
|
+
Sign in again
|
|
43
|
+
</Link>
|
|
44
|
+
) : (
|
|
45
|
+
// An outage, not a sign-out: signing in again would not help, and asking again might.
|
|
46
|
+
<button type="button" className="btn" onClick={() => void refetch()}>
|
|
47
|
+
Try again
|
|
48
|
+
</button>
|
|
49
|
+
)
|
|
79
50
|
}
|
|
80
51
|
>
|
|
81
52
|
{result.error}
|
|
@@ -91,24 +62,24 @@ function ProjectsPage() {
|
|
|
91
62
|
<PageHeader
|
|
92
63
|
title="Projects"
|
|
93
64
|
actions={
|
|
94
|
-
<RootAdminOnly capabilities={
|
|
65
|
+
<RootAdminOnly capabilities={capabilities}>
|
|
95
66
|
<NewProject />
|
|
96
67
|
</RootAdminOnly>
|
|
97
68
|
}
|
|
98
69
|
/>
|
|
99
70
|
|
|
100
|
-
{active.length === 0 ? (
|
|
71
|
+
{active.length === 0 && refusedProjects.length === 0 ? (
|
|
101
72
|
<div className="card">
|
|
102
73
|
<EmptyState title="Nothing here for you yet">
|
|
103
74
|
<ProjectEmptyStateCopy
|
|
104
|
-
capabilities={
|
|
75
|
+
capabilities={capabilities}
|
|
105
76
|
hasArchivedProjects={archived.length > 0}
|
|
106
77
|
/>
|
|
107
78
|
</EmptyState>
|
|
108
79
|
</div>
|
|
109
80
|
) : (
|
|
110
81
|
<section className="card" aria-label="Projects">
|
|
111
|
-
<ProjectTable projects={active}
|
|
82
|
+
<ProjectTable projects={active} refused />
|
|
112
83
|
</section>
|
|
113
84
|
)}
|
|
114
85
|
|
|
@@ -118,7 +89,7 @@ function ProjectsPage() {
|
|
|
118
89
|
Archived
|
|
119
90
|
</h2>
|
|
120
91
|
<div className="card">
|
|
121
|
-
<ProjectTable projects={archived}
|
|
92
|
+
<ProjectTable projects={archived} />
|
|
122
93
|
</div>
|
|
123
94
|
</section>
|
|
124
95
|
)}
|
|
@@ -126,13 +97,8 @@ function ProjectsPage() {
|
|
|
126
97
|
);
|
|
127
98
|
}
|
|
128
99
|
|
|
129
|
-
function ProjectTable({
|
|
130
|
-
|
|
131
|
-
secrets,
|
|
132
|
-
}: {
|
|
133
|
-
projects: ProjectSummary[];
|
|
134
|
-
secrets: Record<string, number | null>;
|
|
135
|
-
}) {
|
|
100
|
+
function ProjectTable({ projects, refused = false }: { projects: ProjectSummary[]; refused?: boolean }) {
|
|
101
|
+
const { status, failedAdds, dismiss } = useChangeStatus(projectsList.queryKey);
|
|
136
102
|
return (
|
|
137
103
|
<div className="dt-wrap">
|
|
138
104
|
<table className="dt projects stacks">
|
|
@@ -165,9 +131,18 @@ function ProjectTable({
|
|
|
165
131
|
key={project.slug}
|
|
166
132
|
number={index + 1}
|
|
167
133
|
project={project}
|
|
168
|
-
|
|
134
|
+
status={status(project.slug)}
|
|
135
|
+
onDismiss={dismiss}
|
|
169
136
|
/>
|
|
170
137
|
))}
|
|
138
|
+
{refused &&
|
|
139
|
+
failedAdds<{ slug: string }>(projects.map((project) => project.slug)).map(
|
|
140
|
+
({ mutationId, vars, status: failed }) => (
|
|
141
|
+
<RowFailure key={mutationId} status={failed} columns={4} onDismiss={() => dismiss(mutationId)}>
|
|
142
|
+
Project {vars.slug} was not created.
|
|
143
|
+
</RowFailure>
|
|
144
|
+
),
|
|
145
|
+
)}
|
|
171
146
|
</tbody>
|
|
172
147
|
</table>
|
|
173
148
|
</div>
|
|
@@ -181,12 +156,17 @@ function ProjectTable({
|
|
|
181
156
|
function ProjectRow({
|
|
182
157
|
number,
|
|
183
158
|
project,
|
|
184
|
-
|
|
159
|
+
status,
|
|
160
|
+
onDismiss,
|
|
185
161
|
}: {
|
|
186
162
|
number: number;
|
|
187
163
|
project: ProjectSummary;
|
|
188
|
-
|
|
164
|
+
status: ItemStatus;
|
|
165
|
+
onDismiss: (mutationId: number) => void;
|
|
189
166
|
}) {
|
|
167
|
+
const secrets = project.secretCount;
|
|
168
|
+
// A project on its way has no page yet.
|
|
169
|
+
const pending = status.state === 'pending';
|
|
190
170
|
const isArchived = project.archivedAt !== null;
|
|
191
171
|
const listedEnvironments = project.environments.filter(
|
|
192
172
|
(environment) =>
|
|
@@ -194,67 +174,80 @@ function ProjectRow({
|
|
|
194
174
|
);
|
|
195
175
|
|
|
196
176
|
return (
|
|
197
|
-
|
|
198
|
-
<
|
|
199
|
-
|
|
200
|
-
<
|
|
201
|
-
<
|
|
202
|
-
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
>
|
|
208
|
-
{project.name}
|
|
209
|
-
</Link>
|
|
210
|
-
<small className="mono">{project.slug}</small>
|
|
211
|
-
</span>
|
|
212
|
-
</span>
|
|
213
|
-
</td>
|
|
214
|
-
<td className="col-envs" data-label="Environments">
|
|
215
|
-
{isArchived || listedEnvironments.length === 0 ? (
|
|
216
|
-
<span className="cell-muted">
|
|
217
|
-
{listedEnvironments.length === 0
|
|
218
|
-
? 'No environments yet'
|
|
219
|
-
: `${listedEnvironments.length} environment${listedEnvironments.length === 1 ? '' : 's'}`}
|
|
220
|
-
</span>
|
|
221
|
-
) : (
|
|
222
|
-
<span className="env-links" aria-label={`Environments in ${project.slug}`}>
|
|
223
|
-
{listedEnvironments.map((environment) =>
|
|
224
|
-
isActiveAccessibleEnvironment(environment) ? (
|
|
177
|
+
<>
|
|
178
|
+
<tr className={`row-link ${rowClass(status)}`}>
|
|
179
|
+
<td className="n">{number}</td>
|
|
180
|
+
<td className="col-project">
|
|
181
|
+
<span className="cell-project">
|
|
182
|
+
<Tile name={project.slug} />
|
|
183
|
+
<span className="cell-stack">
|
|
184
|
+
{pending ? (
|
|
185
|
+
<span>{project.name}</span>
|
|
186
|
+
) : (
|
|
225
187
|
<Link
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
params={{ project: project.slug, environment: environment.slug }}
|
|
188
|
+
className="cell-link stretch"
|
|
189
|
+
to="/projects/$project"
|
|
190
|
+
params={{ project: project.slug }}
|
|
230
191
|
>
|
|
231
|
-
{
|
|
232
|
-
<span className="count">{environment.details.secretCount}</span>
|
|
192
|
+
{project.name}
|
|
233
193
|
</Link>
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
className="env-link"
|
|
238
|
-
title="You can see this environment exists, but not open it"
|
|
239
|
-
>
|
|
240
|
-
{environment.slug}
|
|
241
|
-
</span>
|
|
242
|
-
),
|
|
243
|
-
)}
|
|
194
|
+
)}
|
|
195
|
+
<small className="mono">{project.slug}</small>
|
|
196
|
+
</span>
|
|
244
197
|
</span>
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
198
|
+
</td>
|
|
199
|
+
<td className="col-envs" data-label="Environments">
|
|
200
|
+
{isArchived || listedEnvironments.length === 0 ? (
|
|
201
|
+
<span className="cell-muted">
|
|
202
|
+
{listedEnvironments.length === 0
|
|
203
|
+
? 'No environments yet'
|
|
204
|
+
: `${listedEnvironments.length} environment${listedEnvironments.length === 1 ? '' : 's'}`}
|
|
205
|
+
</span>
|
|
206
|
+
) : (
|
|
207
|
+
<span className="env-links" aria-label={`Environments in ${project.slug}`}>
|
|
208
|
+
{listedEnvironments.map((environment) =>
|
|
209
|
+
isActiveAccessibleEnvironment(environment) ? (
|
|
210
|
+
<Link
|
|
211
|
+
key={environment.slug}
|
|
212
|
+
className="env-link"
|
|
213
|
+
to="/projects/$project/$environment"
|
|
214
|
+
params={{ project: project.slug, environment: environment.slug }}
|
|
215
|
+
>
|
|
216
|
+
{environment.slug}
|
|
217
|
+
<span className="count">{environment.details.secretCount}</span>
|
|
218
|
+
</Link>
|
|
219
|
+
) : (
|
|
220
|
+
<span
|
|
221
|
+
key={environment.slug}
|
|
222
|
+
className="env-link"
|
|
223
|
+
title="You can see this environment exists, but not open it"
|
|
224
|
+
>
|
|
225
|
+
{environment.slug}
|
|
226
|
+
</span>
|
|
227
|
+
),
|
|
228
|
+
)}
|
|
229
|
+
</span>
|
|
230
|
+
)}
|
|
231
|
+
</td>
|
|
232
|
+
<td className="col-secrets num nowrap">
|
|
233
|
+
{pending ? (
|
|
234
|
+
<RowPending status={status} />
|
|
235
|
+
) : secrets !== null && !isArchived ? (
|
|
236
|
+
<>
|
|
237
|
+
{secrets}
|
|
238
|
+
<span className="narrow-only"> secret{secrets === 1 ? '' : 's'}</span>
|
|
239
|
+
</>
|
|
240
|
+
) : (
|
|
241
|
+
<span className="cell-muted wide-only">—</span>
|
|
242
|
+
)}
|
|
243
|
+
</td>
|
|
244
|
+
</tr>
|
|
245
|
+
<RowFailure
|
|
246
|
+
status={status}
|
|
247
|
+
columns={4}
|
|
248
|
+
onDismiss={() => status.state === 'failed' && onDismiss(status.mutationId)}
|
|
249
|
+
/>
|
|
250
|
+
</>
|
|
258
251
|
);
|
|
259
252
|
}
|
|
260
253
|
|
|
@@ -262,13 +255,11 @@ function NewProject() {
|
|
|
262
255
|
const [slug, setSlug] = useState('');
|
|
263
256
|
const [name, setName] = useState('');
|
|
264
257
|
const [open, setOpen] = useState(false);
|
|
265
|
-
const
|
|
266
|
-
const { pending, error, setError, run } = useAction();
|
|
258
|
+
const create = useChange(createProject(useCoffre()));
|
|
267
259
|
const slugError = slug === '' ? null : slugProblem(slug);
|
|
268
260
|
|
|
269
261
|
function close() {
|
|
270
262
|
setOpen(false);
|
|
271
|
-
setError(null);
|
|
272
263
|
}
|
|
273
264
|
|
|
274
265
|
return (
|
|
@@ -288,19 +279,11 @@ function NewProject() {
|
|
|
288
279
|
className="form"
|
|
289
280
|
onSubmit={(event) => {
|
|
290
281
|
event.preventDefault();
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
},
|
|
297
|
-
() => {
|
|
298
|
-
toast.success(`Project ${slug} created`);
|
|
299
|
-
setSlug('');
|
|
300
|
-
setName('');
|
|
301
|
-
setOpen(false);
|
|
302
|
-
},
|
|
303
|
-
);
|
|
282
|
+
// Listed at once, as saving; the list says if the server refuses.
|
|
283
|
+
create({ slug, name: name.trim() });
|
|
284
|
+
setSlug('');
|
|
285
|
+
setName('');
|
|
286
|
+
close();
|
|
304
287
|
}}
|
|
305
288
|
>
|
|
306
289
|
<label className="field">
|
|
@@ -331,8 +314,6 @@ function NewProject() {
|
|
|
331
314
|
/>
|
|
332
315
|
</label>
|
|
333
316
|
|
|
334
|
-
<ErrorLine error={error} />
|
|
335
|
-
|
|
336
317
|
<div className="dialog-actions">
|
|
337
318
|
<button className="btn" type="button" onClick={close}>
|
|
338
319
|
Cancel
|
|
@@ -340,9 +321,8 @@ function NewProject() {
|
|
|
340
321
|
<button
|
|
341
322
|
className="btn btn-primary"
|
|
342
323
|
type="submit"
|
|
343
|
-
disabled={
|
|
324
|
+
disabled={slug === '' || slugError !== null || name.trim() === ''}
|
|
344
325
|
>
|
|
345
|
-
{pending && <Spinner />}
|
|
346
326
|
Create project
|
|
347
327
|
</button>
|
|
348
328
|
</div>
|
package/src/routes/settings.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
1
2
|
import { createFileRoute, Link } from '@tanstack/react-router';
|
|
2
|
-
import {
|
|
3
|
+
import { useCoffre } from '../lib/coffre';
|
|
4
|
+
import { loadDirectory, queries } from '../lib/queries';
|
|
5
|
+
import { useShell } from '../lib/use-shell';
|
|
3
6
|
import { Card, Fact, PageHeader } from '../components/page';
|
|
4
7
|
|
|
5
8
|
/** The instance's settings. Your own are under Account, at the sidebar's foot. */
|
|
@@ -7,18 +10,15 @@ export const Route = createFileRoute('/settings')({
|
|
|
7
10
|
// Instance facts come from the directory, which only owners may list.
|
|
8
11
|
// Asking on everyone's behalf would write a refusal to the audit log for
|
|
9
12
|
// every user who opens the page, so it is only asked for them.
|
|
10
|
-
loader:
|
|
11
|
-
const root = (await parentMatchPromise).loaderData;
|
|
12
|
-
const canManage = root?.capabilities.canManageGrants ?? false;
|
|
13
|
-
return { auth: root?.auth, directory: canManage ? await loadDirectory(client, true) : null };
|
|
14
|
-
},
|
|
13
|
+
loader: ({ context: { client, queryClient } }) => loadDirectory(queryClient, client),
|
|
15
14
|
component: SettingsPage,
|
|
16
15
|
});
|
|
17
16
|
|
|
18
17
|
const listFormat = new Intl.ListFormat('en', { type: 'disjunction' });
|
|
19
18
|
|
|
20
19
|
function SettingsPage() {
|
|
21
|
-
const { auth,
|
|
20
|
+
const { auth, capabilities } = useShell();
|
|
21
|
+
const { data: directory } = useSuspenseQuery(queries.directory(useCoffre(), capabilities.canManageGrants));
|
|
22
22
|
const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
|
|
23
23
|
|
|
24
24
|
const principals = directory?.ok === true ? directory.principals : null;
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
1
2
|
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
-
import {
|
|
3
|
+
import { PrincipalPage } from '../components/principal-page';
|
|
3
4
|
import { ServiceTokens } from '../components/service-tokens';
|
|
4
|
-
import { memberRef,
|
|
5
|
+
import { memberRef, useCoffre } from '../lib/coffre';
|
|
6
|
+
import { loadPrincipal, queries } from '../lib/queries';
|
|
7
|
+
import { useShell } from '../lib/use-shell';
|
|
5
8
|
|
|
6
9
|
export const Route = createFileRoute('/tokens/$token')({
|
|
7
|
-
loader:
|
|
8
|
-
const root = (await parentMatchPromise).loaderData;
|
|
9
|
-
// Only owners issue and see credentials; asking as anyone else would
|
|
10
|
-
// only earn a refusal. Only coffre's own sign-in issues any.
|
|
11
|
-
const [page, credentials] = await Promise.all([
|
|
12
|
-
loadPrincipalPage(client, 'service', params.token, root),
|
|
13
|
-
root?.capabilities.canManageGrants && root.auth.signin !== null
|
|
14
|
-
? uiResult(() => client.tokens.list(memberRef('service', params.token)))
|
|
15
|
-
: Promise.resolve(null),
|
|
16
|
-
]);
|
|
17
|
-
return { page, credentials };
|
|
18
|
-
},
|
|
10
|
+
loader: ({ context: { client, queryClient }, params }) => loadPrincipal(queryClient, client, 'service', params.token),
|
|
19
11
|
component: TokenPage,
|
|
20
12
|
});
|
|
21
13
|
|
|
22
14
|
function TokenPage() {
|
|
23
15
|
const { token } = Route.useParams();
|
|
24
|
-
const
|
|
16
|
+
const client = useCoffre();
|
|
17
|
+
const { auth, capabilities } = useShell();
|
|
18
|
+
const member = memberRef('service', token);
|
|
19
|
+
const owner = capabilities.canManageGrants;
|
|
20
|
+
const { data: report } = useSuspenseQuery(queries.report(client, member, owner));
|
|
21
|
+
const { data: credentials } = useSuspenseQuery(queries.credentials(client, member, owner && auth.signin !== null));
|
|
25
22
|
// A removed service can be issued nothing; its page shows what it left behind.
|
|
26
|
-
const active =
|
|
23
|
+
const active = report?.ok === true && report.report?.status === 'active';
|
|
27
24
|
return (
|
|
28
25
|
<>
|
|
29
|
-
<PrincipalPage principalType="service" principalId={token}
|
|
26
|
+
<PrincipalPage principalType="service" principalId={token} />
|
|
30
27
|
{active && credentials?.ok === true && (
|
|
31
28
|
<ServiceTokens serviceId={token} tokens={credentials.tokens} />
|
|
32
29
|
)}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
1
2
|
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
-
import { AddPrincipal, DirectoryTable
|
|
3
|
+
import { AddPrincipal, DirectoryTable } from '../components/directory';
|
|
4
|
+
import { useCoffre } from '../lib/coffre';
|
|
5
|
+
import { loadDirectory, queries } from '../lib/queries';
|
|
6
|
+
import { useShell } from '../lib/use-shell';
|
|
3
7
|
import { ClosedDoor, PageHeader } from '../components/page';
|
|
4
8
|
import { RemovedList } from '../components/offboarding';
|
|
5
9
|
import { Key } from '../components/icons';
|
|
6
10
|
|
|
7
11
|
export const Route = createFileRoute('/tokens/')({
|
|
8
|
-
loader:
|
|
9
|
-
loadDirectory(client, (await parentMatchPromise).loaderData?.capabilities.canManageGrants ?? false),
|
|
12
|
+
loader: ({ context: { client, queryClient } }) => loadDirectory(queryClient, client),
|
|
10
13
|
component: TokensPage,
|
|
11
14
|
});
|
|
12
15
|
|
|
13
16
|
function TokensPage() {
|
|
14
|
-
const
|
|
17
|
+
const { capabilities } = useShell();
|
|
18
|
+
const { data: result } = useSuspenseQuery(queries.directory(useCoffre(), capabilities.canManageGrants));
|
|
15
19
|
|
|
16
20
|
if (!result.ok) {
|
|
17
21
|
return (
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createFileRoute
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
import { useShell } from '../lib/use-shell';
|
|
2
3
|
|
|
3
4
|
import { ClosedDoor } from '../components/page';
|
|
4
5
|
import { User } from '../components/icons';
|
|
@@ -13,7 +14,7 @@ export const Route = createFileRoute('/unregistered')({
|
|
|
13
14
|
* an owner decision, not a self-service privilege escalation path.
|
|
14
15
|
*/
|
|
15
16
|
function UnregisteredPage() {
|
|
16
|
-
const { principal, accessTampered } =
|
|
17
|
+
const { principal, accessTampered } = useShell();
|
|
17
18
|
|
|
18
19
|
if (accessTampered) {
|
|
19
20
|
return (
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
-
import {
|
|
2
|
+
import { PrincipalPage } from '../components/principal-page';
|
|
3
|
+
import { loadPrincipal } from '../lib/queries';
|
|
3
4
|
|
|
4
5
|
export const Route = createFileRoute('/users/$user')({
|
|
5
|
-
loader:
|
|
6
|
-
loadPrincipalPage(client, 'user', params.user, (await parentMatchPromise).loaderData),
|
|
6
|
+
loader: ({ context: { client, queryClient }, params }) => loadPrincipal(queryClient, client, 'user', params.user),
|
|
7
7
|
component: UserPage,
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
function UserPage() {
|
|
11
11
|
const { user } = Route.useParams();
|
|
12
|
-
return <PrincipalPage principalType="user" principalId={user}
|
|
12
|
+
return <PrincipalPage principalType="user" principalId={user} />;
|
|
13
13
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
1
2
|
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
-
import { AddPrincipal, DirectoryTable
|
|
3
|
+
import { AddPrincipal, DirectoryTable } from '../components/directory';
|
|
4
|
+
import { useCoffre } from '../lib/coffre';
|
|
5
|
+
import { loadDirectory, queries } from '../lib/queries';
|
|
6
|
+
import { useShell } from '../lib/use-shell';
|
|
3
7
|
import { ClosedDoor, PageHeader } from '../components/page';
|
|
4
8
|
import { RemovedList } from '../components/offboarding';
|
|
5
9
|
import { Users } from '../components/icons';
|
|
6
10
|
|
|
7
11
|
export const Route = createFileRoute('/users/')({
|
|
8
|
-
loader:
|
|
9
|
-
loadDirectory(client, (await parentMatchPromise).loaderData?.capabilities.canManageGrants ?? false),
|
|
12
|
+
loader: ({ context: { client, queryClient } }) => loadDirectory(queryClient, client),
|
|
10
13
|
component: UsersPage,
|
|
11
14
|
});
|
|
12
15
|
|
|
13
16
|
function UsersPage() {
|
|
14
|
-
const
|
|
17
|
+
const { capabilities } = useShell();
|
|
18
|
+
const { data: result } = useSuspenseQuery(queries.directory(useCoffre(), capabilities.canManageGrants));
|
|
15
19
|
|
|
16
20
|
if (!result.ok) {
|
|
17
21
|
return (
|
package/src/styles/globals.css
CHANGED
|
@@ -1756,7 +1756,7 @@ a.crumb-link:hover {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
|
|
1758
1758
|
.directory .col-actions {
|
|
1759
|
-
width:
|
|
1759
|
+
width: 6.5rem;
|
|
1760
1760
|
}
|
|
1761
1761
|
|
|
1762
1762
|
/* A person or token: avatar and name, the name cut short rather than
|
|
@@ -2069,6 +2069,77 @@ a.crumb-link:hover {
|
|
|
2069
2069
|
padding-top: 0.25rem;
|
|
2070
2070
|
}
|
|
2071
2071
|
|
|
2072
|
+
/* A change on its way (lib/optimistic.ts): the row as it will be, quieter,
|
|
2073
|
+
saying what it waits for; one being removed is struck through too, and
|
|
2074
|
+
stays until the server confirms. Quieter is --ink-3, which holds its
|
|
2075
|
+
contrast on both themes, rather than an opacity that would not. */
|
|
2076
|
+
tr.is-saving > td,
|
|
2077
|
+
tr.is-removing > td {
|
|
2078
|
+
color: var(--ink-3);
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
tr.is-saving > td :is(a, .mono, code),
|
|
2082
|
+
tr.is-removing > td :is(a, .mono, code) {
|
|
2083
|
+
color: inherit;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
tr.is-removing > td:not(.col-actions, .n),
|
|
2087
|
+
tr.is-removing > td:not(.col-actions, .n) :not(.avatar, .tile) {
|
|
2088
|
+
text-decoration: line-through;
|
|
2089
|
+
text-decoration-thickness: 1px;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
.row-pending {
|
|
2093
|
+
display: inline-flex;
|
|
2094
|
+
align-items: center;
|
|
2095
|
+
gap: 0.375rem;
|
|
2096
|
+
color: var(--ink-3);
|
|
2097
|
+
font-size: 0.8125rem;
|
|
2098
|
+
white-space: nowrap;
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
/* A refused change: a red rule down the row, and why beneath it. */
|
|
2102
|
+
tr.is-failed > td:first-child {
|
|
2103
|
+
box-shadow: inset 2px 0 var(--red);
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
tr.row-failure > td:first-child {
|
|
2107
|
+
box-shadow: inset 2px 0 var(--red);
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
/* The same, on an environment's card. */
|
|
2111
|
+
.env-card.is-saving,
|
|
2112
|
+
.env-card.is-removing {
|
|
2113
|
+
color: var(--ink-3);
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
.env-card.is-saving .env-card-name,
|
|
2117
|
+
.env-card.is-removing .env-card-name {
|
|
2118
|
+
color: inherit;
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
.env-card.is-removing :is(.env-card-name, .env-card-meta) {
|
|
2122
|
+
text-decoration: line-through;
|
|
2123
|
+
text-decoration-thickness: 1px;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
.env-card.is-failed {
|
|
2127
|
+
flex-wrap: wrap;
|
|
2128
|
+
box-shadow: inset 2px 0 var(--red);
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
.env-card .row-failure-line {
|
|
2132
|
+
flex-basis: 100%;
|
|
2133
|
+
margin-top: 0.5rem;
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
.row-failure-line {
|
|
2137
|
+
display: flex;
|
|
2138
|
+
align-items: flex-start;
|
|
2139
|
+
justify-content: space-between;
|
|
2140
|
+
gap: 0.75rem;
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2072
2143
|
/* A row that opens a page, said at its end. */
|
|
2073
2144
|
.col-open {
|
|
2074
2145
|
vertical-align: middle;
|
|
@@ -2645,6 +2716,12 @@ a.env-card-name:hover {
|
|
|
2645
2716
|
/* Audit */
|
|
2646
2717
|
/* ========================================================================== */
|
|
2647
2718
|
|
|
2719
|
+
/* The badge's live region, which stays while the badge changes. */
|
|
2720
|
+
.chain-live {
|
|
2721
|
+
display: flex;
|
|
2722
|
+
align-items: center;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2648
2725
|
.chain {
|
|
2649
2726
|
display: flex;
|
|
2650
2727
|
align-items: center;
|