@coffre/ui 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/audit-sentence-BhHmvQX_.js +660 -0
- package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
- package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
- package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
- package/dist/chunks/{directory-CSjWWUQ1.js → directory-zr3ek7Mc.js} +175 -60
- package/dist/chunks/directory-zr3ek7Mc.js.map +1 -0
- package/dist/chunks/folders-DoBmCwOi.js +207 -0
- package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
- package/dist/chunks/grants-Cw1FyGID.js +669 -0
- package/dist/chunks/grants-Cw1FyGID.js.map +1 -0
- package/dist/chunks/offboarding-CE6d7um1.js +305 -0
- package/dist/chunks/offboarding-CE6d7um1.js.map +1 -0
- package/dist/chunks/one-time-DXEl9hbg.js +35 -0
- package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
- package/dist/chunks/page-DvsgZ2Hd.js +391 -0
- package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
- package/dist/chunks/principal-BIN-xwZw.js +42 -0
- package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
- package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-DhjO76GH.js} +245 -251
- package/dist/chunks/principal-page-DhjO76GH.js.map +1 -0
- package/dist/chunks/project-page-SRCtRe2g.js +17 -0
- package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
- package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
- package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
- package/dist/chunks/references-B6pLT1uQ.js +343 -0
- package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
- package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
- package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
- package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
- package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
- package/dist/chunks/tabs-BmwKfUeK.js +22 -0
- package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
- package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
- package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
- package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
- package/dist/chunks/ui-DJje3gST.js.map +1 -0
- package/dist/chunks/{use-change-c6CeLRin.js → use-change-DUiGO19U.js} +52 -21
- package/dist/chunks/use-change-DUiGO19U.js.map +1 -0
- package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
- package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
- package/dist/chunks/validation-D312_NLf.js +87 -0
- package/dist/chunks/validation-D312_NLf.js.map +1 -0
- package/dist/index.d.ts +361 -27
- package/dist/index.js +188 -98
- package/dist/index.js.map +1 -1
- package/dist/pages/account.d.ts +2 -2
- package/dist/pages/account.js +297 -135
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.d.ts +9 -0
- package/dist/pages/approval.js +207 -0
- package/dist/pages/approval.js.map +1 -0
- package/dist/pages/audit.js +17 -542
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -3
- package/dist/pages/device-login.js.map +1 -1
- package/dist/pages/environment.js +647 -257
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +18 -7
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/oauth-authorize.d.ts +10 -0
- package/dist/pages/oauth-authorize.js +249 -0
- package/dist/pages/oauth-authorize.js.map +1 -0
- package/dist/pages/project-access.d.ts +6 -0
- package/dist/pages/project-access.js +370 -0
- package/dist/pages/project-access.js.map +1 -0
- package/dist/pages/project-environments.d.ts +4 -0
- package/dist/pages/project-environments.js +593 -0
- package/dist/pages/project-environments.js.map +1 -0
- package/dist/pages/project-settings.d.ts +4 -0
- package/dist/pages/project-settings.js +242 -0
- package/dist/pages/project-settings.js.map +1 -0
- package/dist/pages/project.d.ts +10 -2
- package/dist/pages/project.js +57 -934
- package/dist/pages/project.js.map +1 -1
- package/dist/pages/projects.js +53 -21
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.d.ts +10 -0
- package/dist/pages/{token.js → service-account.js} +112 -54
- package/dist/pages/service-account.js.map +1 -0
- package/dist/pages/service-accounts.d.ts +3 -0
- package/dist/pages/service-accounts.js +38 -0
- package/dist/pages/service-accounts.js.map +1 -0
- package/dist/pages/settings.d.ts +1 -0
- package/dist/pages/settings.js +104 -42
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -3
- package/dist/pages/unregistered.js.map +1 -1
- package/dist/pages/user.d.ts +6 -1
- package/dist/pages/user.js +18 -6
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +6 -10
- package/dist/pages/users.js.map +1 -1
- package/package.json +3 -3
- package/src/components/actions-log.tsx +117 -0
- package/src/components/audit-sentence.tsx +55 -0
- package/src/components/command-palette.tsx +4 -4
- package/src/components/delete-place.tsx +180 -0
- package/src/components/directory.tsx +259 -110
- package/src/components/every-project.tsx +287 -0
- package/src/components/expiry-field.tsx +42 -0
- package/src/components/folders.tsx +219 -0
- package/src/components/grants.tsx +11 -4
- package/src/components/icons.tsx +2 -0
- package/src/components/missing.tsx +110 -0
- package/src/components/offboarding.tsx +61 -33
- package/src/components/page.tsx +4 -1
- package/src/components/principal-page.tsx +136 -106
- package/src/components/principal-picker.tsx +5 -5
- package/src/components/principal.tsx +4 -4
- package/src/components/references.tsx +323 -0
- package/src/components/service-tokens.tsx +112 -93
- package/src/components/shell.tsx +11 -32
- package/src/components/tabs.tsx +18 -0
- package/src/components/trusted-workloads.tsx +97 -79
- package/src/components/ui.tsx +8 -1
- package/src/index.ts +13 -2
- package/src/layout.tsx +2 -2
- package/src/lib/access-plan.ts +2 -2
- package/src/lib/audit-sentences.ts +161 -77
- package/src/lib/changes.ts +56 -5
- package/src/lib/coffre.ts +3 -2
- package/src/lib/one-time.ts +32 -0
- package/src/lib/project-access.ts +11 -23
- package/src/lib/project-page.ts +14 -0
- package/src/lib/queries.ts +126 -32
- package/src/lib/search.ts +25 -0
- package/src/lib/signin-errors.ts +45 -1
- package/src/lib/validation.ts +14 -0
- package/src/options.ts +187 -35
- package/src/pages/account.tsx +274 -129
- package/src/pages/approval.tsx +197 -0
- package/src/pages/audit.tsx +9 -61
- package/src/pages/environment.tsx +585 -286
- package/src/pages/login.tsx +8 -2
- package/src/pages/oauth-authorize.tsx +233 -0
- package/src/pages/project-access.tsx +219 -0
- package/src/pages/project-environments.tsx +582 -0
- package/src/pages/project-settings.tsx +259 -0
- package/src/pages/project.tsx +52 -879
- package/src/pages/projects.tsx +55 -18
- package/src/pages/service-account.tsx +50 -0
- package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
- package/src/pages/settings.tsx +62 -8
- package/src/pages/user.tsx +16 -4
- package/src/pages/users.tsx +2 -2
- package/src/parity.ts +160 -0
- package/src/register.ts +58 -9
- package/src/router.tsx +4 -0
- package/src/shared/models.ts +6 -2
- package/src/styles/globals.css +536 -31
- package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
- package/dist/chunks/grants-saMQagmG.js +0 -160
- package/dist/chunks/grants-saMQagmG.js.map +0 -1
- package/dist/chunks/icons-D-PfAfnH.js +0 -203
- package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
- package/dist/chunks/offboarding-C6l30DZR.js +0 -263
- package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
- package/dist/chunks/page-C5HcNqf2.js +0 -190
- package/dist/chunks/page-C5HcNqf2.js.map +0 -1
- package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
- package/dist/chunks/queries-CQ81o4so.js.map +0 -1
- package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
- package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
- package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
- package/dist/chunks/use-action-CWsg_YWU.js +0 -49
- package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
- package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
- package/dist/chunks/validation-BQtqPe2V.js +0 -29
- package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
- package/dist/pages/token.d.ts +0 -3
- package/dist/pages/token.js.map +0 -1
- package/dist/pages/tokens.d.ts +0 -3
- package/dist/pages/tokens.js +0 -39
- package/dist/pages/tokens.js.map +0 -1
- package/dist/project-BqIy8gYR.d.ts +0 -5
- package/src/lib/instance.ts +0 -13
- package/src/pages/token.tsx +0 -34
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { useRouter } from '@tanstack/react-router';
|
|
4
|
+
import { useShell } from '../lib/use-shell';
|
|
5
|
+
import { toast } from 'sonner';
|
|
6
|
+
import { useCoffre } from '../lib/coffre';
|
|
7
|
+
import { affects, queries } from '../lib/queries';
|
|
8
|
+
import { useAction } from '../lib/use-action';
|
|
9
|
+
import type { ProjectSummary } from '../shared/models';
|
|
10
|
+
import { ArchiveBlocked, archiveBlockers } from '../components/references';
|
|
11
|
+
import { folderProblem, slugProblem } from '../lib/validation';
|
|
12
|
+
import { ConfirmDialog, ErrorLine, Spinner } from '../components/ui';
|
|
13
|
+
import { Card } from '../components/page';
|
|
14
|
+
import { DeletePlaceDialog } from '../components/delete-place';
|
|
15
|
+
import { Archive, RotateBack, Trash } from '../components/icons';
|
|
16
|
+
import { pageRoute } from '../lib/page-route';
|
|
17
|
+
import { useProject } from '../lib/project-page';
|
|
18
|
+
import type { projectSettings } from '../options';
|
|
19
|
+
|
|
20
|
+
const Route = pageRoute<typeof projectSettings>();
|
|
21
|
+
|
|
22
|
+
/** A project's settings: its slug, name and folder, and archiving or deleting it. */
|
|
23
|
+
export function ProjectSettingsPage() {
|
|
24
|
+
const { project } = useProject(Route.useParams().project);
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<GeneralSettings project={project} />
|
|
28
|
+
<DangerZone project={project} />
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The project's name and slug, as a form on the page.
|
|
35
|
+
*
|
|
36
|
+
* Renaming changes paths other people and scripts use, so it is laid out in
|
|
37
|
+
* plain sight with what it does and does not affect, rather than tucked
|
|
38
|
+
* behind a menu.
|
|
39
|
+
*/
|
|
40
|
+
function GeneralSettings({ project }: { project: ProjectSummary }) {
|
|
41
|
+
const router = useRouter();
|
|
42
|
+
const [slug, setSlug] = useState(project.slug);
|
|
43
|
+
const [name, setName] = useState(project.name);
|
|
44
|
+
const [folder, setFolder] = useState(project.folder ?? '');
|
|
45
|
+
const coffre = useCoffre();
|
|
46
|
+
const { pending, error, run } = useAction();
|
|
47
|
+
const slugError = slug === '' ? null : slugProblem(slug);
|
|
48
|
+
const folderError = folderProblem(folder);
|
|
49
|
+
const nextFolder = folder === '' ? null : folder;
|
|
50
|
+
const dirty = slug !== project.slug || name.trim() !== project.name || nextFolder !== project.folder;
|
|
51
|
+
|
|
52
|
+
// Follow a rename made elsewhere (another tab, another person) rather than
|
|
53
|
+
// keep offering the old values back.
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setSlug(project.slug);
|
|
56
|
+
setName(project.name);
|
|
57
|
+
setFolder(project.folder ?? '');
|
|
58
|
+
}, [project.slug, project.name, project.folder]);
|
|
59
|
+
|
|
60
|
+
// Two fields and their Save need no card: the tab already says what they are.
|
|
61
|
+
return (
|
|
62
|
+
<section className="plain-form" aria-label="General">
|
|
63
|
+
<form
|
|
64
|
+
onSubmit={(event) => {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
run(
|
|
67
|
+
() => coffre.projects.update(project.slug, {
|
|
68
|
+
slug,
|
|
69
|
+
name,
|
|
70
|
+
// Only when it moves: a move is logged, as `project.move`.
|
|
71
|
+
...(nextFolder === project.folder ? {} : { folder: nextFolder }),
|
|
72
|
+
}),
|
|
73
|
+
{
|
|
74
|
+
affects: affects.places(),
|
|
75
|
+
onSuccess: async () => {
|
|
76
|
+
toast.success(slug === project.slug && name.trim() === project.name ? 'Project moved' : 'Project saved');
|
|
77
|
+
// The slug is part of the URL, so a rename has to navigate.
|
|
78
|
+
if (slug !== project.slug) {
|
|
79
|
+
await router.navigate({ to: '/projects/$project/settings', params: { project: slug } });
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<div className="form-row">
|
|
87
|
+
<label className="field">
|
|
88
|
+
<span className="label">Slug</span>
|
|
89
|
+
<input
|
|
90
|
+
className="input input-mono"
|
|
91
|
+
spellCheck={false}
|
|
92
|
+
value={slug}
|
|
93
|
+
aria-invalid={slugError !== null}
|
|
94
|
+
onChange={(event) => setSlug(event.target.value)}
|
|
95
|
+
/>
|
|
96
|
+
<span className={`hint${slugError !== null ? ' edit-note-error' : ''}`}>
|
|
97
|
+
{slugError ?? 'Scripts that name the old slug will need the new one.'}
|
|
98
|
+
</span>
|
|
99
|
+
</label>
|
|
100
|
+
<label className="field">
|
|
101
|
+
<span className="label">Display name</span>
|
|
102
|
+
<input
|
|
103
|
+
className="input"
|
|
104
|
+
value={name}
|
|
105
|
+
onChange={(event) => setName(event.target.value)}
|
|
106
|
+
/>
|
|
107
|
+
</label>
|
|
108
|
+
<label className="field">
|
|
109
|
+
<span className="label">Folder</span>
|
|
110
|
+
<input
|
|
111
|
+
className="input"
|
|
112
|
+
spellCheck={false}
|
|
113
|
+
placeholder="No folder"
|
|
114
|
+
value={folder}
|
|
115
|
+
aria-invalid={folderError !== null}
|
|
116
|
+
onChange={(event) => setFolder(event.target.value)}
|
|
117
|
+
/>
|
|
118
|
+
<span className={`hint${folderError !== null ? ' edit-note-error' : ''}`}>
|
|
119
|
+
{folderError ?? 'Where Projects lists it. Changes nothing else.'}
|
|
120
|
+
</span>
|
|
121
|
+
</label>
|
|
122
|
+
</div>
|
|
123
|
+
<div className="form-actions">
|
|
124
|
+
<button
|
|
125
|
+
className="btn btn-primary"
|
|
126
|
+
type="submit"
|
|
127
|
+
disabled={!dirty || pending || slug === '' || slugError !== null || name.trim() === '' || folderError !== null}
|
|
128
|
+
>
|
|
129
|
+
{pending && <Spinner />}
|
|
130
|
+
Save
|
|
131
|
+
</button>
|
|
132
|
+
{error !== null && (
|
|
133
|
+
<span className="hint">
|
|
134
|
+
<ErrorLine error={error} />
|
|
135
|
+
</span>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
</form>
|
|
139
|
+
</section>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function DangerZone({ project }: { project: ProjectSummary }) {
|
|
144
|
+
const [confirming, setConfirming] = useState(false);
|
|
145
|
+
const [deleting, setDeleting] = useState(false);
|
|
146
|
+
const coffre = useCoffre();
|
|
147
|
+
const router = useRouter();
|
|
148
|
+
const { instanceRole } = useShell();
|
|
149
|
+
const { pending, error, run } = useAction();
|
|
150
|
+
const isArchived = project.archivedAt !== null;
|
|
151
|
+
// What archiving it would stop, asked once the dialog opens (D41); Archive waits for the answer.
|
|
152
|
+
const archiving = confirming && !isArchived;
|
|
153
|
+
const { data: lent } = useQuery({ ...queries.references(coffre, project.slug), enabled: archiving });
|
|
154
|
+
const blockers = archiving && lent?.ok === true ? archiveBlockers(project.slug, lent.references) : [];
|
|
155
|
+
const asking = archiving && lent === undefined;
|
|
156
|
+
// Deleting is for instance owners, and only once the project is archived.
|
|
157
|
+
const canDelete = isArchived && instanceRole !== 'user';
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<Card labelledBy="danger-zone" title="Danger zone" tone="danger">
|
|
161
|
+
<div className="card-row">
|
|
162
|
+
<div>
|
|
163
|
+
<p className="card-row-title">{isArchived ? 'Restore project' : 'Archive project'}</p>
|
|
164
|
+
{/* Restoring needs no warning: the button says what it does. */}
|
|
165
|
+
{!isArchived && (
|
|
166
|
+
<p className="card-row-desc">Stops every read until restored; nothing is deleted.</p>
|
|
167
|
+
)}
|
|
168
|
+
{error !== null && (
|
|
169
|
+
<div style={{ marginTop: '0.5rem' }}>
|
|
170
|
+
<ErrorLine error={error} />
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
<button
|
|
175
|
+
className={`btn ${isArchived ? '' : 'btn-danger-outline'}`}
|
|
176
|
+
onClick={() => setConfirming(true)}
|
|
177
|
+
disabled={pending}
|
|
178
|
+
>
|
|
179
|
+
{pending ? (
|
|
180
|
+
<Spinner />
|
|
181
|
+
) : isArchived ? (
|
|
182
|
+
<RotateBack size={14} />
|
|
183
|
+
) : (
|
|
184
|
+
<Archive size={14} />
|
|
185
|
+
)}
|
|
186
|
+
{isArchived ? `Restore ${project.name}` : `Archive ${project.name}…`}
|
|
187
|
+
</button>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
{canDelete && (
|
|
191
|
+
<div className="card-row">
|
|
192
|
+
<div>
|
|
193
|
+
<p className="card-row-title">Delete project</p>
|
|
194
|
+
<p className="card-row-desc">
|
|
195
|
+
Erases its values for good and frees its name; only names stay, for the audit log.
|
|
196
|
+
</p>
|
|
197
|
+
</div>
|
|
198
|
+
<button className="btn btn-danger-outline" onClick={() => setDeleting(true)}>
|
|
199
|
+
<Trash size={14} />
|
|
200
|
+
{`Delete ${project.name}…`}
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
203
|
+
)}
|
|
204
|
+
{canDelete && (
|
|
205
|
+
<DeletePlaceDialog
|
|
206
|
+
path={project.slug}
|
|
207
|
+
open={deleting}
|
|
208
|
+
onOpenChange={setDeleting}
|
|
209
|
+
onDeleted={async () => {
|
|
210
|
+
toast.success(`${project.slug} deleted, and its name is free`);
|
|
211
|
+
await router.navigate({ to: '/projects' });
|
|
212
|
+
}}
|
|
213
|
+
/>
|
|
214
|
+
)}
|
|
215
|
+
|
|
216
|
+
<ConfirmDialog
|
|
217
|
+
open={confirming}
|
|
218
|
+
onOpenChange={setConfirming}
|
|
219
|
+
title={
|
|
220
|
+
<>
|
|
221
|
+
{isArchived ? 'Restore' : 'Archive'} <span className="mono">{project.slug}</span>?
|
|
222
|
+
</>
|
|
223
|
+
}
|
|
224
|
+
body={
|
|
225
|
+
isArchived ? (
|
|
226
|
+
<>
|
|
227
|
+
The project reappears in listings and its environments start serving reads
|
|
228
|
+
again, for everyone who holds a grant on it.
|
|
229
|
+
</>
|
|
230
|
+
) : (
|
|
231
|
+
<>
|
|
232
|
+
Every environment in <span className="mono">{project.slug}</span> stops serving
|
|
233
|
+
reads, including to machine callers already running. Nothing is deleted: values,
|
|
234
|
+
versions and the audit trail over them stay intact, and you can restore it here
|
|
235
|
+
at any time.
|
|
236
|
+
</>
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
detail={<ArchiveBlocked references={blockers} />}
|
|
240
|
+
confirmLabel={isArchived ? `Restore ${project.name}` : `Archive ${project.name}`}
|
|
241
|
+
confirmDisabled={asking || blockers.length > 0}
|
|
242
|
+
destructive={!isArchived}
|
|
243
|
+
onConfirm={() =>
|
|
244
|
+
run(
|
|
245
|
+
() =>
|
|
246
|
+
coffre.projects.update(project.slug, { archived: !isArchived }),
|
|
247
|
+
{
|
|
248
|
+
affects: affects.places(),
|
|
249
|
+
onSuccess: () =>
|
|
250
|
+
toast.success(
|
|
251
|
+
isArchived ? `${project.slug} restored` : `${project.slug} archived`,
|
|
252
|
+
),
|
|
253
|
+
},
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
/>
|
|
257
|
+
</Card>
|
|
258
|
+
);
|
|
259
|
+
}
|