@coffre/ui 0.14.4 → 0.15.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-JgJEwQEC.js → actions-log-DupYCEyV.js} +186 -21
- package/dist/chunks/actions-log-DupYCEyV.js.map +1 -0
- package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-CGUQlFMx.js} +5 -5
- package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-CGUQlFMx.js.map} +1 -1
- package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-CswZ-meh.js} +5 -5
- package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-CswZ-meh.js.map} +1 -1
- package/dist/chunks/{directory-BM8yoiJN.js → directory-DrswWQLT.js} +15 -15
- package/dist/chunks/directory-DrswWQLT.js.map +1 -0
- package/dist/chunks/environment-actions-8rL9Cw6X.js +576 -0
- package/dist/chunks/environment-actions-8rL9Cw6X.js.map +1 -0
- package/dist/chunks/{folders-D3A1NGpt.js → folders-A6sbR_PG.js} +3 -3
- package/dist/chunks/{folders-D3A1NGpt.js.map → folders-A6sbR_PG.js.map} +1 -1
- package/dist/chunks/{grants-CjVmOgb2.js → grants-C0cb2oii.js} +8 -8
- package/dist/chunks/grants-C0cb2oii.js.map +1 -0
- package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-B3SEv1gq.js} +3 -3
- package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-B3SEv1gq.js.map} +1 -1
- package/dist/chunks/{offboarding-DbozhPym.js → offboarding-C1jbG_dk.js} +72 -67
- package/dist/chunks/offboarding-C1jbG_dk.js.map +1 -0
- package/dist/chunks/{page-JTORvh-N.js → page-CfhC9Hp1.js} +11 -6
- package/dist/chunks/page-CfhC9Hp1.js.map +1 -0
- package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-xC9wulhg.js} +5 -5
- package/dist/chunks/{personal-tokens-zWZOzLIC.js.map → personal-tokens-xC9wulhg.js.map} +1 -1
- package/dist/chunks/{principal-DFBswTBr.js → principal-CI17XK13.js} +2 -2
- package/dist/chunks/{principal-DFBswTBr.js.map → principal-CI17XK13.js.map} +1 -1
- package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-CdSeftGD.js} +17 -127
- package/dist/chunks/principal-page-CdSeftGD.js.map +1 -0
- package/dist/chunks/{project-page-BjwEoXfU.js → project-page-CHxjBE97.js} +3 -3
- package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-CHxjBE97.js.map} +1 -1
- package/dist/chunks/{queries-2jdgTwfZ.js → queries-D1JuimTu.js} +82 -26
- package/dist/chunks/queries-D1JuimTu.js.map +1 -0
- package/dist/chunks/{references-CRT2BsOS.js → references-D5llUGQL.js} +5 -5
- package/dist/chunks/{references-CRT2BsOS.js.map → references-D5llUGQL.js.map} +1 -1
- package/dist/chunks/{role-field-DswIpPqY.js → role-field-CoCv8wse.js} +5 -5
- package/dist/chunks/role-field-CoCv8wse.js.map +1 -0
- package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYH7kZHl.js} +3 -3
- package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYH7kZHl.js.map} +1 -1
- package/dist/chunks/{theme-Ck45wzWB.js → theme-rF44Wbmm.js} +3 -3
- package/dist/chunks/{theme-Ck45wzWB.js.map → theme-rF44Wbmm.js.map} +1 -1
- package/dist/chunks/{ui-D-blFWfx.js → ui-CGdORVzW.js} +2 -2
- package/dist/chunks/{ui-D-blFWfx.js.map → ui-CGdORVzW.js.map} +1 -1
- package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BxrHTBZw.js} +3 -3
- package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BxrHTBZw.js.map} +1 -1
- package/dist/chunks/{use-change-BC4xo02c.js → use-change-BorW2R6C.js} +4 -4
- package/dist/chunks/{use-change-BC4xo02c.js.map → use-change-BorW2R6C.js.map} +1 -1
- package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-BZnJ9Cq0.js} +56 -13
- package/dist/chunks/use-roles-BZnJ9Cq0.js.map +1 -0
- package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-CPskgi1k.js} +3 -3
- package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-CPskgi1k.js.map} +1 -1
- package/dist/index.d.ts +46 -2
- package/dist/index.js +30 -11
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +11 -11
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.js +2 -2
- package/dist/pages/audit.js +55 -21
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -2
- package/dist/pages/environment.js +228 -389
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +3 -3
- package/dist/pages/oauth-authorize.js +2 -2
- package/dist/pages/project-access.js +11 -11
- package/dist/pages/project-environments.js +28 -359
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +8 -8
- package/dist/pages/project.js +3 -3
- package/dist/pages/projects.js +8 -8
- package/dist/pages/service-account.js +11 -10
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +7 -6
- package/dist/pages/service-accounts.js.map +1 -1
- package/dist/pages/settings.d.ts +6 -1
- package/dist/pages/settings.js +284 -164
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -2
- package/dist/pages/user.js +7 -6
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +7 -6
- package/dist/pages/users.js.map +1 -1
- package/package.json +3 -3
- package/src/components/actions-log.tsx +61 -8
- package/src/components/directory.tsx +5 -5
- package/src/components/environment-actions.tsx +508 -0
- package/src/components/grants.tsx +2 -2
- package/src/components/icons.tsx +2 -0
- package/src/components/offboarding.tsx +7 -0
- package/src/components/page.tsx +3 -2
- package/src/components/principal-page.tsx +1 -1
- package/src/components/protected.tsx +52 -39
- package/src/components/role-editor.tsx +99 -68
- package/src/components/role-field.tsx +1 -1
- package/src/lib/audit-sentences.ts +24 -19
- package/src/lib/queries.ts +85 -21
- package/src/lib/roles.ts +36 -10
- package/src/options.ts +19 -3
- package/src/pages/account.tsx +1 -1
- package/src/pages/audit.tsx +56 -16
- package/src/pages/environment.tsx +227 -352
- package/src/pages/project-environments.tsx +20 -322
- package/src/pages/service-accounts.tsx +1 -1
- package/src/pages/settings.tsx +129 -48
- package/src/pages/users.tsx +1 -1
- package/src/parity.ts +18 -11
- package/src/styles/globals.css +271 -89
- package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
- package/dist/chunks/directory-BM8yoiJN.js.map +0 -1
- package/dist/chunks/grants-CjVmOgb2.js.map +0 -1
- package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
- package/dist/chunks/page-JTORvh-N.js.map +0 -1
- package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
- package/dist/chunks/protected-y7KVhtHd.js +0 -77
- package/dist/chunks/protected-y7KVhtHd.js.map +0 -1
- package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
- package/dist/chunks/role-field-DswIpPqY.js.map +0 -1
- package/dist/chunks/use-roles-DswiNxBk.js.map +0 -1
|
@@ -3,23 +3,20 @@ import type { PersonalConfig } from '@coffre/client';
|
|
|
3
3
|
import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
|
|
4
4
|
import { Link } from '@tanstack/react-router';
|
|
5
5
|
import { useShell } from '../lib/use-shell';
|
|
6
|
-
import { Menu } from '@base-ui/react/menu';
|
|
7
6
|
import { toast } from 'sonner';
|
|
8
7
|
import { useCoffre } from '../lib/coffre';
|
|
9
|
-
import {
|
|
8
|
+
import { environmentId } from '../lib/changes';
|
|
10
9
|
import { affects, keys, queries } from '../lib/queries';
|
|
11
|
-
import {
|
|
10
|
+
import { useChangeStatus } from '../lib/use-change';
|
|
12
11
|
import { ItemFailure, RowPending, rowClass } from '../components/row-state';
|
|
13
12
|
import type { GrantRow, ProjectSummary } from '../shared/models';
|
|
14
|
-
import {
|
|
13
|
+
import { EnvironmentMenu, NewEnvironment } from '../components/environment-actions';
|
|
15
14
|
import { hasEnvironmentDetails, isActiveAccessibleEnvironment, type ProjectEnvironment } from '../lib/project-environments';
|
|
16
|
-
import {
|
|
17
|
-
import { ConfirmDialog, EmptyState, ErrorLine, MenuPopup, Modal, Notice, Timestamp } from '../components/ui';
|
|
15
|
+
import { ConfirmDialog, EmptyState, ErrorLine, Timestamp } from '../components/ui';
|
|
18
16
|
import { Card } from '../components/page';
|
|
19
17
|
import { useAction } from '../lib/use-action';
|
|
20
|
-
import { DeletePlaceDialog } from '../components/delete-place';
|
|
21
18
|
import { PrincipalAvatar } from '../components/principal';
|
|
22
|
-
import {
|
|
19
|
+
import { ChevronRight, Plus, Trash } from '../components/icons';
|
|
23
20
|
import { Protection } from '../components/protected';
|
|
24
21
|
import { pageRoute } from '../lib/page-route';
|
|
25
22
|
import { useProject } from '../lib/project-page';
|
|
@@ -83,7 +80,6 @@ function EnvironmentsPanel({
|
|
|
83
80
|
<EnvironmentCard
|
|
84
81
|
project={project.slug}
|
|
85
82
|
environment={environment}
|
|
86
|
-
isAdmin={canManage}
|
|
87
83
|
grants={grants}
|
|
88
84
|
/>
|
|
89
85
|
</li>
|
|
@@ -105,12 +101,7 @@ function EnvironmentsPanel({
|
|
|
105
101
|
|
|
106
102
|
{canManage && (
|
|
107
103
|
<div className="table-actions">
|
|
108
|
-
<
|
|
109
|
-
project={project.slug}
|
|
110
|
-
// Your personal config is nobody's source: its values are yours alone.
|
|
111
|
-
sources={current.filter((environment) => isActiveAccessibleEnvironment(environment) && !environment.personal).map((environment) => environment.slug)}
|
|
112
|
-
guarded={current.filter((environment) => environment.protected).map((environment) => environment.slug)}
|
|
113
|
-
/>
|
|
104
|
+
<AddEnvironment project={project.slug} />
|
|
114
105
|
</div>
|
|
115
106
|
)}
|
|
116
107
|
|
|
@@ -127,7 +118,6 @@ function EnvironmentsPanel({
|
|
|
127
118
|
<EnvironmentCard
|
|
128
119
|
project={project.slug}
|
|
129
120
|
environment={environment}
|
|
130
|
-
isAdmin={canManage}
|
|
131
121
|
grants={grants}
|
|
132
122
|
/>
|
|
133
123
|
</li>
|
|
@@ -174,28 +164,13 @@ const SHOWN_HOLDERS = 4;
|
|
|
174
164
|
function EnvironmentCard({
|
|
175
165
|
project,
|
|
176
166
|
environment,
|
|
177
|
-
isAdmin,
|
|
178
167
|
grants,
|
|
179
168
|
}: {
|
|
180
169
|
project: string;
|
|
181
170
|
environment: ProjectEnvironment;
|
|
182
|
-
isAdmin: boolean;
|
|
183
171
|
grants: GrantRow[];
|
|
184
172
|
}) {
|
|
185
|
-
const
|
|
186
|
-
const [confirming, setConfirming] = useState(false);
|
|
187
|
-
const [deleting, setDeleting] = useState(false);
|
|
188
|
-
const { capabilities } = useShell();
|
|
189
|
-
const [slug, setSlug] = useState(environment.slug);
|
|
190
|
-
const coffre = useCoffre();
|
|
191
|
-
const rename = useChange(renameEnvironment(coffre, project));
|
|
192
|
-
const archive = useChange(archiveEnvironment(coffre, project));
|
|
193
|
-
// What archiving it would stop, asked once the dialog opens (D41); Archive waits for the answer.
|
|
194
|
-
const place = `${project}/${environment.slug}`;
|
|
195
|
-
const archiving = confirming && environment.details?.archivedAt == null;
|
|
196
|
-
const { data: lent } = useQuery({ ...queries.references(coffre, place), enabled: archiving });
|
|
197
|
-
const blockers = archiving && lent?.ok === true ? archiveBlockers(place, lent.references) : [];
|
|
198
|
-
const asking = archiving && lent === undefined;
|
|
173
|
+
const { principal } = useShell();
|
|
199
174
|
const { status, dismiss } = useChangeStatus(keys.projects);
|
|
200
175
|
const state = status(environmentId(project, environment.slug));
|
|
201
176
|
const pending = state.state === 'pending';
|
|
@@ -203,15 +178,9 @@ function EnvironmentCard({
|
|
|
203
178
|
const isArchived = details !== null && details.archivedAt !== null;
|
|
204
179
|
const secretCount = details?.secretCount ?? null;
|
|
205
180
|
const opens = details !== null && !isArchived && environment.accessible && !pending;
|
|
206
|
-
const manageable = isAdmin && details !== null;
|
|
207
|
-
// Deleting is for those who run the instance, and only once the environment is archived.
|
|
208
|
-
const deletable = manageable && isArchived && capabilities.runsInstance;
|
|
209
|
-
const slugError = slug === '' ? null : environmentSlugProblem(slug);
|
|
210
181
|
const lastChange = useLastChange(project, environment.slug, opens);
|
|
211
182
|
// A personal config is its owner's alone: no grant reaches it, so none is shown on its card.
|
|
212
183
|
const holders = environment.personal === true ? [] : holdersOf(grants, environment.slug);
|
|
213
|
-
// Scopes match environments by slug: a new one is said to move them before the rename is saved.
|
|
214
|
-
const reslugged = slug !== environment.slug && slug !== '' && slugError === null;
|
|
215
184
|
|
|
216
185
|
return (
|
|
217
186
|
<div
|
|
@@ -230,7 +199,7 @@ function EnvironmentCard({
|
|
|
230
199
|
) : (
|
|
231
200
|
<span className="env-card-name">{environment.slug}</span>
|
|
232
201
|
)}
|
|
233
|
-
<Protection
|
|
202
|
+
<Protection environment={environment} compact />
|
|
234
203
|
{/* A fork: its keys are its parent's, but for those it sets or removes. An instance before 0.7 says nothing. */}
|
|
235
204
|
{environment.personal === true
|
|
236
205
|
? <span className="tag tag-blue">yours alone</span>
|
|
@@ -284,154 +253,15 @@ function EnvironmentCard({
|
|
|
284
253
|
|
|
285
254
|
{pending && <RowPending status={state} />}
|
|
286
255
|
|
|
287
|
-
{
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
<MenuPopup align="end">
|
|
297
|
-
<Menu.Item
|
|
298
|
-
className="menu-item"
|
|
299
|
-
onClick={() => {
|
|
300
|
-
setSlug(environment.slug);
|
|
301
|
-
setRenaming(true);
|
|
302
|
-
}}
|
|
303
|
-
>
|
|
304
|
-
<Pencil size={14} />
|
|
305
|
-
Rename
|
|
306
|
-
</Menu.Item>
|
|
307
|
-
<Menu.Separator className="menu-sep" />
|
|
308
|
-
<Menu.Item
|
|
309
|
-
className={`menu-item${isArchived ? '' : ' menu-item-danger'}`}
|
|
310
|
-
onClick={() => setConfirming(true)}
|
|
311
|
-
>
|
|
312
|
-
{isArchived ? <RotateBack size={14} /> : <Archive size={14} />}
|
|
313
|
-
{isArchived ? 'Restore' : 'Archive…'}
|
|
314
|
-
</Menu.Item>
|
|
315
|
-
{deletable && (
|
|
316
|
-
<Menu.Item className="menu-item menu-item-danger" onClick={() => setDeleting(true)}>
|
|
317
|
-
<Trash size={14} />
|
|
318
|
-
Delete…
|
|
319
|
-
</Menu.Item>
|
|
320
|
-
)}
|
|
321
|
-
</MenuPopup>
|
|
322
|
-
</Menu.Root>
|
|
323
|
-
)}
|
|
324
|
-
|
|
325
|
-
{manageable && (
|
|
326
|
-
<>
|
|
327
|
-
<Modal
|
|
328
|
-
open={renaming}
|
|
329
|
-
onOpenChange={setRenaming}
|
|
330
|
-
title={
|
|
331
|
-
<>
|
|
332
|
-
Rename{' '}
|
|
333
|
-
<span className="mono">
|
|
334
|
-
{project}/{environment.slug}
|
|
335
|
-
</span>
|
|
336
|
-
</>
|
|
337
|
-
}
|
|
338
|
-
>
|
|
339
|
-
<form
|
|
340
|
-
className="form"
|
|
341
|
-
onSubmit={(event) => {
|
|
342
|
-
event.preventDefault();
|
|
343
|
-
// Shown on the card at once; the card says if the server refuses.
|
|
344
|
-
rename({ from: environment.slug, slug });
|
|
345
|
-
setRenaming(false);
|
|
346
|
-
}}
|
|
347
|
-
>
|
|
348
|
-
<label className="field">
|
|
349
|
-
<span className="label">Slug</span>
|
|
350
|
-
<input
|
|
351
|
-
className="input input-mono"
|
|
352
|
-
autoFocus
|
|
353
|
-
spellCheck={false}
|
|
354
|
-
value={slug}
|
|
355
|
-
aria-invalid={slugError !== null}
|
|
356
|
-
onChange={(event) => setSlug(event.target.value)}
|
|
357
|
-
/>
|
|
358
|
-
<span className={`hint${slugError !== null ? ' edit-note-error' : ''}`}>
|
|
359
|
-
{slugError ??
|
|
360
|
-
`Anything running coffre run ${project}/${environment.slug} will need the new path.`}
|
|
361
|
-
</span>
|
|
362
|
-
</label>
|
|
363
|
-
{reslugged && (
|
|
364
|
-
<Notice tone="info">
|
|
365
|
-
Instance roles scoped to <span className="mono">{environment.slug}</span> stop reaching it; those scoped
|
|
366
|
-
to <span className="mono">{slug}</span> start.
|
|
367
|
-
</Notice>
|
|
368
|
-
)}
|
|
369
|
-
|
|
370
|
-
<div className="dialog-actions">
|
|
371
|
-
<button className="btn" type="button" onClick={() => setRenaming(false)}>
|
|
372
|
-
Cancel
|
|
373
|
-
</button>
|
|
374
|
-
<button
|
|
375
|
-
className="btn btn-primary"
|
|
376
|
-
type="submit"
|
|
377
|
-
disabled={slug === environment.slug || slug === '' || slugError !== null}
|
|
378
|
-
>
|
|
379
|
-
Save
|
|
380
|
-
</button>
|
|
381
|
-
</div>
|
|
382
|
-
</form>
|
|
383
|
-
</Modal>
|
|
384
|
-
|
|
385
|
-
<ConfirmDialog
|
|
386
|
-
open={confirming}
|
|
387
|
-
onOpenChange={setConfirming}
|
|
388
|
-
title={
|
|
389
|
-
<>
|
|
390
|
-
{isArchived ? 'Restore' : 'Archive'}{' '}
|
|
391
|
-
<span className="mono">
|
|
392
|
-
{project}/{environment.slug}
|
|
393
|
-
</span>
|
|
394
|
-
?
|
|
395
|
-
</>
|
|
396
|
-
}
|
|
397
|
-
body={
|
|
398
|
-
secretCount === null ? (
|
|
399
|
-
<>
|
|
400
|
-
This changes whether the environment serves its secrets. Values and history
|
|
401
|
-
stay stored.
|
|
402
|
-
</>
|
|
403
|
-
) : isArchived ? (
|
|
404
|
-
<>
|
|
405
|
-
It serves its {secretCount} secret{secretCount === 1 ? '' : 's'} again, to
|
|
406
|
-
everyone with a grant on it.
|
|
407
|
-
</>
|
|
408
|
-
) : (
|
|
409
|
-
<>
|
|
410
|
-
Its {secretCount} secret{secretCount === 1 ? '' : 's'} stop being served, so
|
|
411
|
-
anything running <code>coffre run</code> against{' '}
|
|
412
|
-
<span className="mono">
|
|
413
|
-
{project}/{environment.slug}
|
|
414
|
-
</span>{' '}
|
|
415
|
-
loses them at its next start. Values and history survive, and restoring is
|
|
416
|
-
one click.
|
|
417
|
-
</>
|
|
418
|
-
)
|
|
419
|
-
}
|
|
420
|
-
detail={<ArchiveBlocked references={blockers} />}
|
|
421
|
-
confirmLabel={isArchived ? 'Restore environment' : 'Archive environment'}
|
|
422
|
-
confirmDisabled={asking || blockers.length > 0}
|
|
423
|
-
destructive={!isArchived}
|
|
424
|
-
onConfirm={() => archive({ slug: environment.slug, archived: !isArchived })}
|
|
425
|
-
/>
|
|
426
|
-
</>
|
|
427
|
-
)}
|
|
428
|
-
|
|
429
|
-
{deletable && (
|
|
430
|
-
<DeletePlaceDialog
|
|
431
|
-
path={`${project}/${environment.slug}`}
|
|
432
|
-
open={deleting}
|
|
433
|
-
onOpenChange={setDeleting}
|
|
434
|
-
onDeleted={() => toast.success(`${project}/${environment.slug} deleted`)}
|
|
256
|
+
{!pending && (
|
|
257
|
+
<EnvironmentMenu
|
|
258
|
+
project={project}
|
|
259
|
+
environment={environment.slug}
|
|
260
|
+
inProject={environment}
|
|
261
|
+
ownConfig={principal?.type === 'user' && isActiveAccessibleEnvironment(environment) && environment.personal !== true}
|
|
262
|
+
busy={false}
|
|
263
|
+
follow={false}
|
|
264
|
+
className="act act-quiet env-card-menu"
|
|
435
265
|
/>
|
|
436
266
|
)}
|
|
437
267
|
|
|
@@ -496,148 +326,16 @@ function PersonalConfigs({ project }: { project: string }) {
|
|
|
496
326
|
);
|
|
497
327
|
}
|
|
498
328
|
|
|
499
|
-
/**
|
|
500
|
-
|
|
501
|
-
* its keys live (docs/design/forking.md), or each of them copied, value and
|
|
502
|
-
* folder, without history, or a reference to it. Copying is a read, and
|
|
503
|
-
* logged as one; inheriting reads nothing until the fork is read.
|
|
504
|
-
*/
|
|
505
|
-
function NewEnvironment({
|
|
506
|
-
project,
|
|
507
|
-
sources,
|
|
508
|
-
guarded,
|
|
509
|
-
}: {
|
|
510
|
-
project: string;
|
|
511
|
-
sources: string[];
|
|
512
|
-
/** The protected ones: a fork of one is protected too. */
|
|
513
|
-
guarded: string[];
|
|
514
|
-
}) {
|
|
329
|
+
/** Add environment, and the dialog it opens. */
|
|
330
|
+
function AddEnvironment({ project }: { project: string }) {
|
|
515
331
|
const [open, setOpen] = useState(false);
|
|
516
|
-
const [slug, setSlug] = useState('');
|
|
517
|
-
// '' for empty, 'inherit:prod' for a fork that inherits, 'copy:prod' for a copy, 'ref:prod' for references to prod.
|
|
518
|
-
const [start, setStart] = useState('');
|
|
519
|
-
const [how, from] = start === '' ? ['', ''] : (start.split(':') as ['inherit' | 'copy' | 'ref', string]);
|
|
520
|
-
const coffre = useCoffre();
|
|
521
|
-
// A fork as references copies the keys whose source you read only through their parent: said before you confirm.
|
|
522
|
-
const { data: parent } = useQuery({ ...queries.secrets(coffre, { project, environment: from }), enabled: how === 'ref' });
|
|
523
|
-
const copied = how === 'ref' && parent?.ok === true
|
|
524
|
-
? parent.keys.filter((key) => !key.archived && key.reference !== null && !key.reference.canOpenSource).map((key) => key.key)
|
|
525
|
-
: [];
|
|
526
|
-
const create = useChange(createEnvironment(coffre, project));
|
|
527
|
-
const slugError = slug === '' ? null : environmentSlugProblem(slug);
|
|
528
|
-
|
|
529
|
-
function close() {
|
|
530
|
-
setOpen(false);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
332
|
return (
|
|
534
333
|
<>
|
|
535
334
|
<button className="btn btn-primary" onClick={() => setOpen(true)}>
|
|
536
335
|
<Plus size={14} />
|
|
537
336
|
Add environment
|
|
538
337
|
</button>
|
|
539
|
-
|
|
540
|
-
<Modal
|
|
541
|
-
open={open}
|
|
542
|
-
onOpenChange={(next) => (next ? setOpen(true) : close())}
|
|
543
|
-
title={
|
|
544
|
-
<>
|
|
545
|
-
New environment in <span className="mono">{project}</span>
|
|
546
|
-
</>
|
|
547
|
-
}
|
|
548
|
-
>
|
|
549
|
-
<form
|
|
550
|
-
className="form"
|
|
551
|
-
onSubmit={(event) => {
|
|
552
|
-
event.preventDefault();
|
|
553
|
-
// Listed at once, as saving; the list says if the server refuses.
|
|
554
|
-
create({ slug, ...(from === '' ? {} : { from }), ...(how === 'ref' ? { references: true } : {}), ...(how === 'inherit' ? { inherit: true } : {}) });
|
|
555
|
-
setSlug('');
|
|
556
|
-
setStart('');
|
|
557
|
-
close();
|
|
558
|
-
}}
|
|
559
|
-
>
|
|
560
|
-
<label className="field">
|
|
561
|
-
<span className="label">Slug</span>
|
|
562
|
-
<input
|
|
563
|
-
className="input input-mono"
|
|
564
|
-
autoFocus
|
|
565
|
-
spellCheck={false}
|
|
566
|
-
autoComplete="off"
|
|
567
|
-
placeholder="staging"
|
|
568
|
-
value={slug}
|
|
569
|
-
aria-invalid={slugError !== null}
|
|
570
|
-
onChange={(event) => setSlug(event.target.value)}
|
|
571
|
-
/>
|
|
572
|
-
<span className={`hint${slugError !== null ? ' edit-note-error' : ''}`}>
|
|
573
|
-
{slugError ?? (
|
|
574
|
-
<>
|
|
575
|
-
The CLI will address it as{' '}
|
|
576
|
-
<span className="mono">
|
|
577
|
-
{project}/{slug === '' ? 'staging' : slug}
|
|
578
|
-
</span>
|
|
579
|
-
.
|
|
580
|
-
</>
|
|
581
|
-
)}
|
|
582
|
-
</span>
|
|
583
|
-
</label>
|
|
584
|
-
{sources.length > 0 && (
|
|
585
|
-
<label className="field">
|
|
586
|
-
<span className="label">Start from</span>
|
|
587
|
-
<select className="select" value={start} onChange={(event) => setStart(event.target.value)}>
|
|
588
|
-
<option value="">Empty</option>
|
|
589
|
-
{sources.map((source) => (
|
|
590
|
-
<option key={`inherit:${source}`} value={`inherit:${source}`}>
|
|
591
|
-
Inheriting from {source}
|
|
592
|
-
</option>
|
|
593
|
-
))}
|
|
594
|
-
{sources.map((source) => (
|
|
595
|
-
<option key={`copy:${source}`} value={`copy:${source}`}>
|
|
596
|
-
A copy of {source}
|
|
597
|
-
</option>
|
|
598
|
-
))}
|
|
599
|
-
{sources.map((source) => (
|
|
600
|
-
<option key={`ref:${source}`} value={`ref:${source}`}>
|
|
601
|
-
References to {source}
|
|
602
|
-
</option>
|
|
603
|
-
))}
|
|
604
|
-
</select>
|
|
605
|
-
<span className="hint">
|
|
606
|
-
{how === ''
|
|
607
|
-
? 'No secrets yet.'
|
|
608
|
-
: how === 'inherit'
|
|
609
|
-
? `Keeps reading ${from}'s keys, live, except those you set or remove here. Whoever reads ${slug === '' ? 'the new environment' : slug} needs read on ${from} too, for those.`
|
|
610
|
-
: how === 'copy'
|
|
611
|
-
? `Each of ${from}'s keys, with its current value and folder, without history.`
|
|
612
|
-
: `Each key follows ${from}'s until it gets a value of its own. Whoever can read ${slug === '' ? 'the new environment' : slug} will read ${from}'s values through them, even without access to ${from}.`}
|
|
613
|
-
</span>
|
|
614
|
-
{from !== '' && guarded.includes(from) && (
|
|
615
|
-
<span className="hint">
|
|
616
|
-
<span className="mono">{from}</span> is protected, so the new environment is too, from its first moment.
|
|
617
|
-
</span>
|
|
618
|
-
)}
|
|
619
|
-
{copied.length > 0 && (
|
|
620
|
-
<span className="hint">
|
|
621
|
-
Copied instead, since you read their source only through {from}: <span className="mono">{copied.join(', ')}</span>.
|
|
622
|
-
</span>
|
|
623
|
-
)}
|
|
624
|
-
</label>
|
|
625
|
-
)}
|
|
626
|
-
|
|
627
|
-
<div className="dialog-actions">
|
|
628
|
-
<button className="btn" type="button" onClick={close}>
|
|
629
|
-
Cancel
|
|
630
|
-
</button>
|
|
631
|
-
<button
|
|
632
|
-
className="btn btn-primary"
|
|
633
|
-
type="submit"
|
|
634
|
-
disabled={slug === '' || slugError !== null}
|
|
635
|
-
>
|
|
636
|
-
Add environment
|
|
637
|
-
</button>
|
|
638
|
-
</div>
|
|
639
|
-
</form>
|
|
640
|
-
</Modal>
|
|
338
|
+
<NewEnvironment project={project} open={open} onOpenChange={setOpen} />
|
|
641
339
|
</>
|
|
642
340
|
);
|
|
643
341
|
}
|
|
@@ -37,7 +37,7 @@ export function ServiceAccountsPage() {
|
|
|
37
37
|
principals={accounts}
|
|
38
38
|
hasRemoved={result.removed.some((principal) => principal.principalType === 'service')}
|
|
39
39
|
/>
|
|
40
|
-
<RemovedList principalType="service" removed={result.removed} />
|
|
40
|
+
<RemovedList principalType="service" removed={result.removed} reads={result.reads} />
|
|
41
41
|
</>
|
|
42
42
|
);
|
|
43
43
|
}
|