@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,8 +1,21 @@
|
|
|
1
1
|
import { useEffect, useState, type ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
3
|
+
import { createFileRoute, Link, useRouter } from '@tanstack/react-router';
|
|
4
|
+
import { useShell } from '../lib/use-shell';
|
|
3
5
|
import { DropdownMenu } from 'radix-ui';
|
|
4
6
|
import { toast } from 'sonner';
|
|
5
|
-
import {
|
|
7
|
+
import { useCoffre } from '../lib/coffre';
|
|
8
|
+
import {
|
|
9
|
+
archiveEnvironment,
|
|
10
|
+
createEnvironment,
|
|
11
|
+
environmentId,
|
|
12
|
+
grantAccess,
|
|
13
|
+
grantId,
|
|
14
|
+
renameEnvironment,
|
|
15
|
+
} from '../lib/changes';
|
|
16
|
+
import { affects, keys, loadProject, projectOf, queries } from '../lib/queries';
|
|
17
|
+
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
18
|
+
import { ItemFailure, RowPending, rowClass } from '../components/row-state';
|
|
6
19
|
import { useAction } from '../lib/use-action';
|
|
7
20
|
import type { GrantRow, ProjectSummary } from '../shared/models';
|
|
8
21
|
import {
|
|
@@ -19,7 +32,7 @@ import {
|
|
|
19
32
|
Spinner,
|
|
20
33
|
} from '../components/ui';
|
|
21
34
|
import { Card, ClosedDoor, PageHeader } from '../components/page';
|
|
22
|
-
import {
|
|
35
|
+
import { GrantRowView, GrantsTable, RefusedGrants, useRefusedGrants } from '../components/grants';
|
|
23
36
|
import { PrincipalLink } from '../components/principal';
|
|
24
37
|
import { PrincipalPicker } from '../components/principal-picker';
|
|
25
38
|
import {
|
|
@@ -51,7 +64,7 @@ export const Route = createFileRoute('/projects/$project/')({
|
|
|
51
64
|
? search.tab
|
|
52
65
|
: undefined,
|
|
53
66
|
}),
|
|
54
|
-
loader: ({ context: { client }, params }) => loadProject(client, params.project),
|
|
67
|
+
loader: ({ context: { client, queryClient }, params }) => loadProject(queryClient, client, params.project),
|
|
55
68
|
component: ProjectPage,
|
|
56
69
|
});
|
|
57
70
|
|
|
@@ -63,9 +76,9 @@ const TABS: { key: ProjectTab; label: string; icon: ReactNode }[] = [
|
|
|
63
76
|
];
|
|
64
77
|
|
|
65
78
|
function ProjectPage() {
|
|
66
|
-
const result = Route.useLoaderData();
|
|
67
79
|
const { project: projectSlug } = Route.useParams();
|
|
68
|
-
const
|
|
80
|
+
const { data: projects } = useSuspenseQuery(queries.projects(useCoffre()));
|
|
81
|
+
const result = projectOf(projects, projectSlug);
|
|
69
82
|
|
|
70
83
|
if (!result.ok) {
|
|
71
84
|
return (
|
|
@@ -85,7 +98,33 @@ function ProjectPage() {
|
|
|
85
98
|
);
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
|
|
101
|
+
return result.managesAccess ? (
|
|
102
|
+
<ManagedProject project={result.project} />
|
|
103
|
+
) : (
|
|
104
|
+
<ProjectView project={result.project} grants={[]} grantsError={null} />
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A project whose access you manage, with its grants. */
|
|
109
|
+
function ManagedProject({ project }: { project: ProjectSummary }) {
|
|
110
|
+
const { data: result } = useSuspenseQuery(queries.grants(useCoffre(), project.slug));
|
|
111
|
+
return result.ok ? (
|
|
112
|
+
<ProjectView project={project} grants={result.grants} grantsError={null} />
|
|
113
|
+
) : (
|
|
114
|
+
<ProjectView project={project} grants={[]} grantsError={result.error} />
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function ProjectView({
|
|
119
|
+
project,
|
|
120
|
+
grants,
|
|
121
|
+
grantsError,
|
|
122
|
+
}: {
|
|
123
|
+
project: ProjectSummary;
|
|
124
|
+
grants: GrantRow[];
|
|
125
|
+
grantsError: string | null;
|
|
126
|
+
}) {
|
|
127
|
+
const search = Route.useSearch();
|
|
89
128
|
|
|
90
129
|
// Each tab is gated on its own permission, not on one blanket "admin".
|
|
91
130
|
// That is what lets an access manager administer grants without being able
|
|
@@ -194,10 +233,14 @@ function EnvironmentsPanel({
|
|
|
194
233
|
const current = project.environments.filter(
|
|
195
234
|
(environment) => environment.details === null || environment.details.archivedAt === null,
|
|
196
235
|
);
|
|
236
|
+
const { failedAdds, dismiss } = useChangeStatus(keys.projects);
|
|
237
|
+
const refused = failedAdds<{ slug: string; name: string }>(
|
|
238
|
+
project.environments.map((environment) => environmentId(project.slug, environment.slug)),
|
|
239
|
+
).filter(({ ids }) => ids.every((id) => id.startsWith(`${project.slug}/`)));
|
|
197
240
|
|
|
198
241
|
return (
|
|
199
242
|
<>
|
|
200
|
-
{current.length === 0 ? (
|
|
243
|
+
{current.length === 0 && refused.length === 0 ? (
|
|
201
244
|
<div className="card">
|
|
202
245
|
<EmptyState title="No environments yet">
|
|
203
246
|
{canManage
|
|
@@ -216,6 +259,21 @@ function EnvironmentsPanel({
|
|
|
216
259
|
/>
|
|
217
260
|
</li>
|
|
218
261
|
))}
|
|
262
|
+
{refused.map(({ mutationId, vars, status }) => (
|
|
263
|
+
<li key={mutationId}>
|
|
264
|
+
<div className="env-card is-muted is-failed">
|
|
265
|
+
<div className="env-card-text">
|
|
266
|
+
<span className="env-card-name">{vars.name}</span>
|
|
267
|
+
<span className="env-card-meta">
|
|
268
|
+
<span className="mono">{vars.slug}</span>
|
|
269
|
+
</span>
|
|
270
|
+
</div>
|
|
271
|
+
<ItemFailure status={status} onDismiss={() => dismiss(mutationId)}>
|
|
272
|
+
Not added.
|
|
273
|
+
</ItemFailure>
|
|
274
|
+
</div>
|
|
275
|
+
</li>
|
|
276
|
+
))}
|
|
219
277
|
</ul>
|
|
220
278
|
)}
|
|
221
279
|
|
|
@@ -259,20 +317,20 @@ function EnvironmentCard({
|
|
|
259
317
|
const [slug, setSlug] = useState(environment.slug);
|
|
260
318
|
const [name, setName] = useState(environment.name);
|
|
261
319
|
const coffre = useCoffre();
|
|
262
|
-
const
|
|
320
|
+
const rename = useChange(renameEnvironment(coffre, project));
|
|
321
|
+
const archive = useChange(archiveEnvironment(coffre, project));
|
|
322
|
+
const { status, dismiss } = useChangeStatus(keys.projects);
|
|
323
|
+
const state = status(environmentId(project, environment.slug));
|
|
324
|
+
const pending = state.state === 'pending';
|
|
263
325
|
const details = environment.details;
|
|
264
326
|
const isArchived = details !== null && details.archivedAt !== null;
|
|
265
327
|
const secretCount = details?.secretCount ?? null;
|
|
266
|
-
const opens = details !== null && !isArchived && environment.accessible;
|
|
328
|
+
const opens = details !== null && !isArchived && environment.accessible && !pending;
|
|
267
329
|
const manageable = isAdmin && details !== null;
|
|
268
330
|
const slugError = slug === '' ? null : slugProblem(slug);
|
|
269
331
|
|
|
270
|
-
useEffect(() => {
|
|
271
|
-
if (error !== null && !renaming) toast.error(error);
|
|
272
|
-
}, [error, renaming]);
|
|
273
|
-
|
|
274
332
|
return (
|
|
275
|
-
<div className={`env-card${opens ? ' is-link' : ' is-muted'}`}>
|
|
333
|
+
<div className={`env-card${opens ? ' is-link' : ' is-muted'} ${rowClass(state)}`}>
|
|
276
334
|
<div className="env-card-text">
|
|
277
335
|
{opens ? (
|
|
278
336
|
<Link
|
|
@@ -289,7 +347,7 @@ function EnvironmentCard({
|
|
|
289
347
|
<span className="mono">{environment.slug}</span>
|
|
290
348
|
{isArchived ? (
|
|
291
349
|
<span className="tag tag-red">archived</span>
|
|
292
|
-
) : !environment.accessible ? (
|
|
350
|
+
) : !environment.accessible && !pending ? (
|
|
293
351
|
<span className="tag tag-outline">no secret access</span>
|
|
294
352
|
) : (
|
|
295
353
|
secretCount !== null && (
|
|
@@ -301,15 +359,16 @@ function EnvironmentCard({
|
|
|
301
359
|
</span>
|
|
302
360
|
</div>
|
|
303
361
|
|
|
304
|
-
{
|
|
362
|
+
{pending && <RowPending status={state} />}
|
|
363
|
+
|
|
364
|
+
{manageable && !pending && (
|
|
305
365
|
<DropdownMenu.Root>
|
|
306
366
|
<DropdownMenu.Trigger asChild>
|
|
307
367
|
<button
|
|
308
368
|
className="act act-quiet env-card-menu"
|
|
309
369
|
aria-label={`Actions for ${environment.slug}`}
|
|
310
|
-
disabled={pending}
|
|
311
370
|
>
|
|
312
|
-
|
|
371
|
+
<MoreHorizontal size={16} />
|
|
313
372
|
</button>
|
|
314
373
|
</DropdownMenu.Trigger>
|
|
315
374
|
<DropdownMenu.Portal>
|
|
@@ -342,10 +401,7 @@ function EnvironmentCard({
|
|
|
342
401
|
<>
|
|
343
402
|
<Modal
|
|
344
403
|
open={renaming}
|
|
345
|
-
onOpenChange={
|
|
346
|
-
setRenaming(open);
|
|
347
|
-
if (!open) setError(null);
|
|
348
|
-
}}
|
|
404
|
+
onOpenChange={setRenaming}
|
|
349
405
|
title={
|
|
350
406
|
<>
|
|
351
407
|
Rename{' '}
|
|
@@ -359,14 +415,9 @@ function EnvironmentCard({
|
|
|
359
415
|
className="form"
|
|
360
416
|
onSubmit={(event) => {
|
|
361
417
|
event.preventDefault();
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
() => {
|
|
366
|
-
setRenaming(false);
|
|
367
|
-
toast.success('Environment renamed');
|
|
368
|
-
},
|
|
369
|
-
);
|
|
418
|
+
// Shown on the card at once; the card says if the server refuses.
|
|
419
|
+
rename({ from: environment.slug, slug, name: name.trim() });
|
|
420
|
+
setRenaming(false);
|
|
370
421
|
}}
|
|
371
422
|
>
|
|
372
423
|
<label className="field">
|
|
@@ -393,8 +444,6 @@ function EnvironmentCard({
|
|
|
393
444
|
/>
|
|
394
445
|
</label>
|
|
395
446
|
|
|
396
|
-
<ErrorLine error={error} />
|
|
397
|
-
|
|
398
447
|
<div className="dialog-actions">
|
|
399
448
|
<button className="btn" type="button" onClick={() => setRenaming(false)}>
|
|
400
449
|
Cancel
|
|
@@ -402,9 +451,8 @@ function EnvironmentCard({
|
|
|
402
451
|
<button
|
|
403
452
|
className="btn btn-primary"
|
|
404
453
|
type="submit"
|
|
405
|
-
disabled={
|
|
454
|
+
disabled={slug === '' || slugError !== null || name.trim() === ''}
|
|
406
455
|
>
|
|
407
|
-
{pending && <Spinner />}
|
|
408
456
|
Save
|
|
409
457
|
</button>
|
|
410
458
|
</div>
|
|
@@ -448,19 +496,15 @@ function EnvironmentCard({
|
|
|
448
496
|
}
|
|
449
497
|
confirmLabel={isArchived ? 'Restore environment' : 'Archive environment'}
|
|
450
498
|
destructive={!isArchived}
|
|
451
|
-
onConfirm={() =>
|
|
452
|
-
run(
|
|
453
|
-
() =>
|
|
454
|
-
coffre.environments.update(`${project}/${environment.slug}`, { archived: !isArchived }),
|
|
455
|
-
() =>
|
|
456
|
-
toast.success(
|
|
457
|
-
isArchived ? `${environment.slug} restored` : `${environment.slug} archived`,
|
|
458
|
-
),
|
|
459
|
-
)
|
|
460
|
-
}
|
|
499
|
+
onConfirm={() => archive({ slug: environment.slug, archived: !isArchived })}
|
|
461
500
|
/>
|
|
462
501
|
</>
|
|
463
502
|
)}
|
|
503
|
+
|
|
504
|
+
<ItemFailure
|
|
505
|
+
status={state}
|
|
506
|
+
onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
|
|
507
|
+
/>
|
|
464
508
|
</div>
|
|
465
509
|
);
|
|
466
510
|
}
|
|
@@ -469,13 +513,11 @@ function NewEnvironment({ project }: { project: string }) {
|
|
|
469
513
|
const [open, setOpen] = useState(false);
|
|
470
514
|
const [slug, setSlug] = useState('');
|
|
471
515
|
const [name, setName] = useState('');
|
|
472
|
-
const
|
|
473
|
-
const { pending, error, setError, run } = useAction();
|
|
516
|
+
const create = useChange(createEnvironment(useCoffre(), project));
|
|
474
517
|
const slugError = slug === '' ? null : slugProblem(slug);
|
|
475
518
|
|
|
476
519
|
function close() {
|
|
477
520
|
setOpen(false);
|
|
478
|
-
setError(null);
|
|
479
521
|
}
|
|
480
522
|
|
|
481
523
|
return (
|
|
@@ -498,18 +540,11 @@ function NewEnvironment({ project }: { project: string }) {
|
|
|
498
540
|
className="form"
|
|
499
541
|
onSubmit={(event) => {
|
|
500
542
|
event.preventDefault();
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
() => {
|
|
507
|
-
toast.success(`Environment ${slug} added`);
|
|
508
|
-
setSlug('');
|
|
509
|
-
setName('');
|
|
510
|
-
close();
|
|
511
|
-
},
|
|
512
|
-
);
|
|
543
|
+
// Listed at once, as saving; the list says if the server refuses.
|
|
544
|
+
create({ slug, name: name.trim() });
|
|
545
|
+
setSlug('');
|
|
546
|
+
setName('');
|
|
547
|
+
close();
|
|
513
548
|
}}
|
|
514
549
|
>
|
|
515
550
|
<label className="field">
|
|
@@ -546,8 +581,6 @@ function NewEnvironment({ project }: { project: string }) {
|
|
|
546
581
|
/>
|
|
547
582
|
</label>
|
|
548
583
|
|
|
549
|
-
<ErrorLine error={error} />
|
|
550
|
-
|
|
551
584
|
<div className="dialog-actions">
|
|
552
585
|
<button className="btn" type="button" onClick={close}>
|
|
553
586
|
Cancel
|
|
@@ -555,9 +588,8 @@ function NewEnvironment({ project }: { project: string }) {
|
|
|
555
588
|
<button
|
|
556
589
|
className="btn btn-primary"
|
|
557
590
|
type="submit"
|
|
558
|
-
disabled={
|
|
591
|
+
disabled={slug === '' || slugError !== null || name.trim() === ''}
|
|
559
592
|
>
|
|
560
|
-
{pending && <Spinner />}
|
|
561
593
|
Add environment
|
|
562
594
|
</button>
|
|
563
595
|
</div>
|
|
@@ -577,9 +609,10 @@ function AccessPanel({
|
|
|
577
609
|
grants: GrantRow[];
|
|
578
610
|
}) {
|
|
579
611
|
const people = principalType === 'user';
|
|
612
|
+
const refused = useRefusedGrants(project, grants, principalType);
|
|
580
613
|
return (
|
|
581
614
|
<section className="card" aria-label={people ? 'Users with access' : 'Tokens with access'}>
|
|
582
|
-
{grants.length === 0 ? (
|
|
615
|
+
{grants.length === 0 && refused.length === 0 ? (
|
|
583
616
|
<EmptyState title={people ? 'No user has access' : 'No token has access'}>
|
|
584
617
|
Add {people ? 'a user' : 'a token'} with permissions on the whole project or on one
|
|
585
618
|
environment.
|
|
@@ -595,7 +628,7 @@ function AccessPanel({
|
|
|
595
628
|
>
|
|
596
629
|
{grants.map((grant, index) => (
|
|
597
630
|
<GrantRowView
|
|
598
|
-
key={grant
|
|
631
|
+
key={grantId(grant)}
|
|
599
632
|
number={index + 1}
|
|
600
633
|
project={project}
|
|
601
634
|
grant={grant}
|
|
@@ -603,6 +636,7 @@ function AccessPanel({
|
|
|
603
636
|
lead={<PrincipalLink type={grant.principalType} id={grant.principalId} />}
|
|
604
637
|
/>
|
|
605
638
|
))}
|
|
639
|
+
<RefusedGrants refused={refused} />
|
|
606
640
|
</GrantsTable>
|
|
607
641
|
)}
|
|
608
642
|
</section>
|
|
@@ -620,19 +654,17 @@ function NewGrant({
|
|
|
620
654
|
environments: ProjectSummary['environments'];
|
|
621
655
|
grants: GrantRow[];
|
|
622
656
|
}) {
|
|
623
|
-
const { capabilities } =
|
|
657
|
+
const { capabilities } = useShell();
|
|
624
658
|
const [open, setOpen] = useState(false);
|
|
625
659
|
const [principalId, setPrincipalId] = useState('');
|
|
626
660
|
const [permission, setPermission] = useState('viewer:');
|
|
627
661
|
const [expiresAt, setExpiresAt] = useState('');
|
|
628
|
-
const
|
|
629
|
-
const { pending, error, setError, run } = useAction();
|
|
662
|
+
const grant = useChange(grantAccess(useCoffre(), project));
|
|
630
663
|
const permissionOptions = projectAccessOptions(environments);
|
|
631
664
|
const kind = principalType === 'user' ? 'user' : 'token';
|
|
632
665
|
|
|
633
666
|
function close() {
|
|
634
667
|
setOpen(false);
|
|
635
|
-
setError(null);
|
|
636
668
|
}
|
|
637
669
|
|
|
638
670
|
return (
|
|
@@ -658,32 +690,19 @@ function NewGrant({
|
|
|
658
690
|
onSubmit={(event) => {
|
|
659
691
|
event.preventDefault();
|
|
660
692
|
const access = parseProjectAccess(permission);
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
permissionOptions.find((option) => option.value === permission)?.label ??
|
|
675
|
-
'access';
|
|
676
|
-
toast.success(
|
|
677
|
-
existed
|
|
678
|
-
? `${principalId} already has ${label}`
|
|
679
|
-
: `${principalId} granted ${label.toLowerCase()}`,
|
|
680
|
-
);
|
|
681
|
-
setPrincipalId('');
|
|
682
|
-
setExpiresAt('');
|
|
683
|
-
setPermission('viewer:');
|
|
684
|
-
close();
|
|
685
|
-
},
|
|
686
|
-
);
|
|
693
|
+
// Shown in the list at once, marked as saving; the list says if the server refuses.
|
|
694
|
+
grant({
|
|
695
|
+
principalType,
|
|
696
|
+
principalId: principalId.trim(),
|
|
697
|
+
role: access.role,
|
|
698
|
+
roleName: permissionOptions.find((option) => option.value === permission)?.label ?? access.role,
|
|
699
|
+
environmentSlug: access.environmentSlug,
|
|
700
|
+
expiresAt: expiresAt === '' ? null : new Date(`${expiresAt}T23:59:59Z`).toISOString(),
|
|
701
|
+
});
|
|
702
|
+
setPrincipalId('');
|
|
703
|
+
setExpiresAt('');
|
|
704
|
+
setPermission('viewer:');
|
|
705
|
+
close();
|
|
687
706
|
}}
|
|
688
707
|
>
|
|
689
708
|
<PrincipalPicker
|
|
@@ -723,18 +742,11 @@ function NewGrant({
|
|
|
723
742
|
</label>
|
|
724
743
|
</div>
|
|
725
744
|
|
|
726
|
-
<ErrorLine error={error} />
|
|
727
|
-
|
|
728
745
|
<div className="dialog-actions">
|
|
729
746
|
<button className="btn" type="button" onClick={close}>
|
|
730
747
|
Cancel
|
|
731
748
|
</button>
|
|
732
|
-
<button
|
|
733
|
-
className="btn btn-primary"
|
|
734
|
-
type="submit"
|
|
735
|
-
disabled={pending || principalId.trim() === ''}
|
|
736
|
-
>
|
|
737
|
-
{pending && <Spinner />}
|
|
749
|
+
<button className="btn btn-primary" type="submit" disabled={principalId.trim() === ''}>
|
|
738
750
|
Grant access
|
|
739
751
|
</button>
|
|
740
752
|
</div>
|
|
@@ -781,16 +793,19 @@ function GeneralSettings({ project }: { project: ProjectSummary }) {
|
|
|
781
793
|
event.preventDefault();
|
|
782
794
|
run(
|
|
783
795
|
() => coffre.projects.update(project.slug, { slug, name }),
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
796
|
+
{
|
|
797
|
+
affects: affects.places(),
|
|
798
|
+
onSuccess: async () => {
|
|
799
|
+
toast.success('Project renamed');
|
|
800
|
+
// The slug is part of the URL, so a rename has to navigate.
|
|
801
|
+
if (slug !== project.slug) {
|
|
802
|
+
await router.navigate({
|
|
803
|
+
to: '/projects/$project',
|
|
804
|
+
params: { project: slug },
|
|
805
|
+
search: { tab: 'settings' },
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
},
|
|
794
809
|
},
|
|
795
810
|
);
|
|
796
811
|
}}
|
|
@@ -905,10 +920,13 @@ function DangerZone({ project }: { project: ProjectSummary }) {
|
|
|
905
920
|
run(
|
|
906
921
|
() =>
|
|
907
922
|
coffre.projects.update(project.slug, { archived: !isArchived }),
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
923
|
+
{
|
|
924
|
+
affects: affects.places(),
|
|
925
|
+
onSuccess: () =>
|
|
926
|
+
toast.success(
|
|
927
|
+
isArchived ? `${project.slug} restored` : `${project.slug} archived`,
|
|
928
|
+
),
|
|
929
|
+
},
|
|
912
930
|
)
|
|
913
931
|
}
|
|
914
932
|
/>
|