@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,14 +1,17 @@
|
|
|
1
|
-
import type { CoffreClient } from '@coffre/client';
|
|
2
1
|
import { useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
3
|
+
import { createFileRoute, Link } from '@tanstack/react-router';
|
|
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,55 +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,
|
|
69
|
-
const
|
|
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)) : [];
|
|
70
33
|
|
|
71
34
|
if (!result.ok) {
|
|
72
35
|
return (
|
|
@@ -80,7 +43,7 @@ function ProjectsPage() {
|
|
|
80
43
|
</Link>
|
|
81
44
|
) : (
|
|
82
45
|
// An outage, not a sign-out: signing in again would not help, and asking again might.
|
|
83
|
-
<button type="button" className="btn" onClick={() => void
|
|
46
|
+
<button type="button" className="btn" onClick={() => void refetch()}>
|
|
84
47
|
Try again
|
|
85
48
|
</button>
|
|
86
49
|
)
|
|
@@ -99,24 +62,24 @@ function ProjectsPage() {
|
|
|
99
62
|
<PageHeader
|
|
100
63
|
title="Projects"
|
|
101
64
|
actions={
|
|
102
|
-
<RootAdminOnly capabilities={
|
|
65
|
+
<RootAdminOnly capabilities={capabilities}>
|
|
103
66
|
<NewProject />
|
|
104
67
|
</RootAdminOnly>
|
|
105
68
|
}
|
|
106
69
|
/>
|
|
107
70
|
|
|
108
|
-
{active.length === 0 ? (
|
|
71
|
+
{active.length === 0 && refusedProjects.length === 0 ? (
|
|
109
72
|
<div className="card">
|
|
110
73
|
<EmptyState title="Nothing here for you yet">
|
|
111
74
|
<ProjectEmptyStateCopy
|
|
112
|
-
capabilities={
|
|
75
|
+
capabilities={capabilities}
|
|
113
76
|
hasArchivedProjects={archived.length > 0}
|
|
114
77
|
/>
|
|
115
78
|
</EmptyState>
|
|
116
79
|
</div>
|
|
117
80
|
) : (
|
|
118
81
|
<section className="card" aria-label="Projects">
|
|
119
|
-
<ProjectTable projects={active}
|
|
82
|
+
<ProjectTable projects={active} refused />
|
|
120
83
|
</section>
|
|
121
84
|
)}
|
|
122
85
|
|
|
@@ -126,7 +89,7 @@ function ProjectsPage() {
|
|
|
126
89
|
Archived
|
|
127
90
|
</h2>
|
|
128
91
|
<div className="card">
|
|
129
|
-
<ProjectTable projects={archived}
|
|
92
|
+
<ProjectTable projects={archived} />
|
|
130
93
|
</div>
|
|
131
94
|
</section>
|
|
132
95
|
)}
|
|
@@ -134,13 +97,8 @@ function ProjectsPage() {
|
|
|
134
97
|
);
|
|
135
98
|
}
|
|
136
99
|
|
|
137
|
-
function ProjectTable({
|
|
138
|
-
|
|
139
|
-
secrets,
|
|
140
|
-
}: {
|
|
141
|
-
projects: ProjectSummary[];
|
|
142
|
-
secrets: Record<string, number | null>;
|
|
143
|
-
}) {
|
|
100
|
+
function ProjectTable({ projects, refused = false }: { projects: ProjectSummary[]; refused?: boolean }) {
|
|
101
|
+
const { status, failedAdds, dismiss } = useChangeStatus(projectsList.queryKey);
|
|
144
102
|
return (
|
|
145
103
|
<div className="dt-wrap">
|
|
146
104
|
<table className="dt projects stacks">
|
|
@@ -173,9 +131,18 @@ function ProjectTable({
|
|
|
173
131
|
key={project.slug}
|
|
174
132
|
number={index + 1}
|
|
175
133
|
project={project}
|
|
176
|
-
|
|
134
|
+
status={status(project.slug)}
|
|
135
|
+
onDismiss={dismiss}
|
|
177
136
|
/>
|
|
178
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
|
+
)}
|
|
179
146
|
</tbody>
|
|
180
147
|
</table>
|
|
181
148
|
</div>
|
|
@@ -189,12 +156,17 @@ function ProjectTable({
|
|
|
189
156
|
function ProjectRow({
|
|
190
157
|
number,
|
|
191
158
|
project,
|
|
192
|
-
|
|
159
|
+
status,
|
|
160
|
+
onDismiss,
|
|
193
161
|
}: {
|
|
194
162
|
number: number;
|
|
195
163
|
project: ProjectSummary;
|
|
196
|
-
|
|
164
|
+
status: ItemStatus;
|
|
165
|
+
onDismiss: (mutationId: number) => void;
|
|
197
166
|
}) {
|
|
167
|
+
const secrets = project.secretCount;
|
|
168
|
+
// A project on its way has no page yet.
|
|
169
|
+
const pending = status.state === 'pending';
|
|
198
170
|
const isArchived = project.archivedAt !== null;
|
|
199
171
|
const listedEnvironments = project.environments.filter(
|
|
200
172
|
(environment) =>
|
|
@@ -202,67 +174,80 @@ function ProjectRow({
|
|
|
202
174
|
);
|
|
203
175
|
|
|
204
176
|
return (
|
|
205
|
-
|
|
206
|
-
<
|
|
207
|
-
|
|
208
|
-
<
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
>
|
|
216
|
-
{project.name}
|
|
217
|
-
</Link>
|
|
218
|
-
<small className="mono">{project.slug}</small>
|
|
219
|
-
</span>
|
|
220
|
-
</span>
|
|
221
|
-
</td>
|
|
222
|
-
<td className="col-envs" data-label="Environments">
|
|
223
|
-
{isArchived || listedEnvironments.length === 0 ? (
|
|
224
|
-
<span className="cell-muted">
|
|
225
|
-
{listedEnvironments.length === 0
|
|
226
|
-
? 'No environments yet'
|
|
227
|
-
: `${listedEnvironments.length} environment${listedEnvironments.length === 1 ? '' : 's'}`}
|
|
228
|
-
</span>
|
|
229
|
-
) : (
|
|
230
|
-
<span className="env-links" aria-label={`Environments in ${project.slug}`}>
|
|
231
|
-
{listedEnvironments.map((environment) =>
|
|
232
|
-
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
|
+
) : (
|
|
233
187
|
<Link
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
params={{ project: project.slug, environment: environment.slug }}
|
|
188
|
+
className="cell-link stretch"
|
|
189
|
+
to="/projects/$project"
|
|
190
|
+
params={{ project: project.slug }}
|
|
238
191
|
>
|
|
239
|
-
{
|
|
240
|
-
<span className="count">{environment.details.secretCount}</span>
|
|
192
|
+
{project.name}
|
|
241
193
|
</Link>
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
className="env-link"
|
|
246
|
-
title="You can see this environment exists, but not open it"
|
|
247
|
-
>
|
|
248
|
-
{environment.slug}
|
|
249
|
-
</span>
|
|
250
|
-
),
|
|
251
|
-
)}
|
|
194
|
+
)}
|
|
195
|
+
<small className="mono">{project.slug}</small>
|
|
196
|
+
</span>
|
|
252
197
|
</span>
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
</>
|
|
266
251
|
);
|
|
267
252
|
}
|
|
268
253
|
|
|
@@ -270,13 +255,11 @@ function NewProject() {
|
|
|
270
255
|
const [slug, setSlug] = useState('');
|
|
271
256
|
const [name, setName] = useState('');
|
|
272
257
|
const [open, setOpen] = useState(false);
|
|
273
|
-
const
|
|
274
|
-
const { pending, error, setError, run } = useAction();
|
|
258
|
+
const create = useChange(createProject(useCoffre()));
|
|
275
259
|
const slugError = slug === '' ? null : slugProblem(slug);
|
|
276
260
|
|
|
277
261
|
function close() {
|
|
278
262
|
setOpen(false);
|
|
279
|
-
setError(null);
|
|
280
263
|
}
|
|
281
264
|
|
|
282
265
|
return (
|
|
@@ -296,19 +279,11 @@ function NewProject() {
|
|
|
296
279
|
className="form"
|
|
297
280
|
onSubmit={(event) => {
|
|
298
281
|
event.preventDefault();
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
},
|
|
305
|
-
() => {
|
|
306
|
-
toast.success(`Project ${slug} created`);
|
|
307
|
-
setSlug('');
|
|
308
|
-
setName('');
|
|
309
|
-
setOpen(false);
|
|
310
|
-
},
|
|
311
|
-
);
|
|
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();
|
|
312
287
|
}}
|
|
313
288
|
>
|
|
314
289
|
<label className="field">
|
|
@@ -339,8 +314,6 @@ function NewProject() {
|
|
|
339
314
|
/>
|
|
340
315
|
</label>
|
|
341
316
|
|
|
342
|
-
<ErrorLine error={error} />
|
|
343
|
-
|
|
344
317
|
<div className="dialog-actions">
|
|
345
318
|
<button className="btn" type="button" onClick={close}>
|
|
346
319
|
Cancel
|
|
@@ -348,9 +321,8 @@ function NewProject() {
|
|
|
348
321
|
<button
|
|
349
322
|
className="btn btn-primary"
|
|
350
323
|
type="submit"
|
|
351
|
-
disabled={
|
|
324
|
+
disabled={slug === '' || slugError !== null || name.trim() === ''}
|
|
352
325
|
>
|
|
353
|
-
{pending && <Spinner />}
|
|
354
326
|
Create project
|
|
355
327
|
</button>
|
|
356
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;
|