@coffre/ui 0.2.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} +115 -56
- 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 +115 -95
- 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
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { useSuspenseQueries, useSuspenseQuery } from '@tanstack/react-query';
|
|
3
|
-
import { Link } from '@tanstack/react-router';
|
|
3
|
+
import { Link, Outlet } from '@tanstack/react-router';
|
|
4
|
+
import { ROLES } from '@coffre/core/access';
|
|
4
5
|
import { useShell } from '../lib/use-shell';
|
|
5
6
|
import { toast } from 'sonner';
|
|
6
7
|
import { memberRef, useCoffre } from '../lib/coffre';
|
|
7
8
|
import { directoryList } from '../lib/changes';
|
|
8
|
-
import { affects, managedProjects, queries } from '../lib/queries';
|
|
9
|
+
import { affects, managedProjects, queries, signInWays } from '../lib/queries';
|
|
9
10
|
import { useChangeStatus } from '../lib/use-change';
|
|
11
|
+
import { useMounted } from '../lib/mounted';
|
|
10
12
|
import { ItemFailure } from './row-state';
|
|
11
13
|
import { useAction } from '../lib/use-action';
|
|
12
14
|
import { projectAccessLabel } from '../lib/project-access';
|
|
@@ -26,61 +28,69 @@ import type { DirectoryPrincipal, GrantRow, ProjectSummary } from '../shared/mod
|
|
|
26
28
|
import { ClosedDoor, PageHeader } from './page';
|
|
27
29
|
import { EmptyState, ErrorLine, Modal, Notice, Spinner } from './ui';
|
|
28
30
|
import { GrantRowView, GrantsTable } from './grants';
|
|
31
|
+
import { EveryProjectGrants } from './every-project';
|
|
32
|
+
import { ExpiryField } from './expiry-field';
|
|
29
33
|
import { InstanceRole, KIND, PrincipalActions } from './directory';
|
|
30
34
|
import { PrincipalReportCards, RemovedNotice } from './offboarding';
|
|
31
35
|
import { PrincipalAvatar } from './principal';
|
|
32
36
|
import { Tile } from './tile';
|
|
33
|
-
import { Clock, Folder, Key, Pencil, Users, X } from './icons';
|
|
37
|
+
import { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';
|
|
38
|
+
import { PageTabs } from './tabs';
|
|
34
39
|
|
|
35
40
|
type PrincipalType = DirectoryPrincipal['principalType'];
|
|
36
41
|
|
|
37
42
|
type ProjectAccess = { project: ProjectSummary; grants: GrantRow[]; grantsError: string | null };
|
|
38
43
|
|
|
44
|
+
/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */
|
|
45
|
+
function useReport(principalType: PrincipalType, principalId: string) {
|
|
46
|
+
const { capabilities } = useShell();
|
|
47
|
+
return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.canManageGrants)).data;
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
/**
|
|
40
|
-
*
|
|
41
|
-
* read:
|
|
42
|
-
* grants on every project where you manage access.
|
|
51
|
+
* Its grants on every project where you manage access, which `loadAccess`
|
|
52
|
+
* read: there is no call for one member's, so each project's are filtered.
|
|
43
53
|
*/
|
|
44
|
-
function
|
|
54
|
+
function useProjectAccess(principalType: PrincipalType, principalId: string): ProjectAccess[] {
|
|
45
55
|
const client = useCoffre();
|
|
46
|
-
const
|
|
47
|
-
const managed = managedProjects(projects);
|
|
48
|
-
const { data: report } = useSuspenseQuery(
|
|
49
|
-
queries.report(client, memberRef(principalType, principalId), capabilities.canManageGrants),
|
|
50
|
-
);
|
|
56
|
+
const managed = managedProjects(useShell().projects);
|
|
51
57
|
const grants = useSuspenseQueries({
|
|
52
58
|
queries: managed.map((project) => queries.grants(client, project.slug)),
|
|
53
59
|
});
|
|
54
|
-
|
|
60
|
+
return managed.map((project, index) => {
|
|
55
61
|
const result = grants[index]!.data;
|
|
56
62
|
return {
|
|
57
63
|
project,
|
|
64
|
+
// Grants on every project show once, below: not again in each project they reach.
|
|
58
65
|
grants: result.ok
|
|
59
66
|
? result.grants.filter(
|
|
60
|
-
(grant) =>
|
|
67
|
+
(grant) =>
|
|
68
|
+
grant.principalType === principalType &&
|
|
69
|
+
grant.principalId === principalId &&
|
|
70
|
+
grant.scope !== 'every-project',
|
|
61
71
|
)
|
|
62
72
|
: [],
|
|
63
73
|
grantsError: result.ok ? null : result.error,
|
|
64
74
|
};
|
|
65
75
|
});
|
|
66
|
-
return { report, access };
|
|
67
76
|
}
|
|
68
77
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
+
/**
|
|
79
|
+
* A user's or service account's page: who it is, its menu, and its tabs,
|
|
80
|
+
* each a page of its own under this one. Access is a user's first tab; a
|
|
81
|
+
* service account's is how it signs in, while it shows one. A tab the
|
|
82
|
+
* deployment left out is not offered.
|
|
83
|
+
*/
|
|
84
|
+
export function PrincipalLayout({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {
|
|
85
|
+
const shell = useShell();
|
|
86
|
+
const mounted = useMounted();
|
|
87
|
+
const { capabilities } = shell;
|
|
88
|
+
const report = useReport(principalType, principalId);
|
|
78
89
|
// A role change or removal made from this page's menu, refused.
|
|
79
90
|
const { status, dismiss } = useChangeStatus(directoryList.queryKey);
|
|
80
91
|
const change = status(memberRef(principalType, principalId));
|
|
81
92
|
const kind = KIND[principalType];
|
|
82
93
|
const people = principalType === 'user';
|
|
83
|
-
const list = people ? '/users' : '/tokens';
|
|
84
94
|
const found = report?.ok === true ? report.report : null;
|
|
85
95
|
const removed = found?.status === 'removed';
|
|
86
96
|
const entry =
|
|
@@ -98,15 +108,15 @@ export function PrincipalPage({
|
|
|
98
108
|
// miss there means there is no such user. Everyone else only reaches this
|
|
99
109
|
// page through projects they manage.
|
|
100
110
|
const unknown = report?.ok === true && found === null;
|
|
101
|
-
if (unknown || (report === null &&
|
|
111
|
+
if (unknown || (report === null && managedProjects(shell.projects).length === 0)) {
|
|
102
112
|
return (
|
|
103
113
|
<ClosedDoor
|
|
104
114
|
icon={people ? <Users size={18} /> : <Key size={18} />}
|
|
105
|
-
label={<span className="mono">{principalId}</span>}
|
|
106
|
-
title={people ? 'No such user for you' : 'No such
|
|
115
|
+
label={<span className="mono">{people ? principalId : `service:${principalId}`}</span>}
|
|
116
|
+
title={people ? 'No such user for you' : 'No such service account for you'}
|
|
107
117
|
actions={
|
|
108
|
-
<Link className="btn" to={
|
|
109
|
-
All {people ? 'users' : '
|
|
118
|
+
<Link className="btn" to={people ? '/users' : '/service-accounts'}>
|
|
119
|
+
All {people ? 'users' : 'service accounts'}
|
|
110
120
|
</Link>
|
|
111
121
|
}
|
|
112
122
|
>
|
|
@@ -117,22 +127,58 @@ export function PrincipalPage({
|
|
|
117
127
|
);
|
|
118
128
|
}
|
|
119
129
|
|
|
120
|
-
const
|
|
121
|
-
|
|
130
|
+
const access = (
|
|
131
|
+
<>
|
|
132
|
+
{removed ? <Archive size={15} /> : <Folder size={15} />}
|
|
133
|
+
{removed ? 'Offboarding' : 'Access'}
|
|
134
|
+
</>
|
|
122
135
|
);
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
const activity = (
|
|
137
|
+
<>
|
|
138
|
+
<Activity size={15} />
|
|
139
|
+
Activity
|
|
140
|
+
</>
|
|
141
|
+
);
|
|
142
|
+
const tabs = people
|
|
143
|
+
? [
|
|
144
|
+
<Link key="access" to="/users/$user" params={{ user: principalId }} activeOptions={{ exact: true, includeSearch: false }}>
|
|
145
|
+
{access}
|
|
146
|
+
</Link>,
|
|
147
|
+
capabilities.canReadAudit && mounted('/users/$user/activity') && (
|
|
148
|
+
<Link key="activity" to="/users/$user/activity" params={{ user: principalId }}>
|
|
149
|
+
{activity}
|
|
150
|
+
</Link>
|
|
151
|
+
),
|
|
152
|
+
]
|
|
153
|
+
: [
|
|
154
|
+
signInWays(shell, report) !== null && (
|
|
155
|
+
<Link key="sign-in" to="/service-accounts/$account" params={{ account: principalId }} activeOptions={{ exact: true, includeSearch: false }}>
|
|
156
|
+
<LinkIcon size={15} />
|
|
157
|
+
Sign-in
|
|
158
|
+
</Link>
|
|
159
|
+
),
|
|
160
|
+
mounted('/service-accounts/$account/access') && (
|
|
161
|
+
<Link key="access" to="/service-accounts/$account/access" params={{ account: principalId }}>
|
|
162
|
+
{access}
|
|
163
|
+
</Link>
|
|
164
|
+
),
|
|
165
|
+
capabilities.canReadAudit && mounted('/service-accounts/$account/activity') && (
|
|
166
|
+
<Link key="activity" to="/service-accounts/$account/activity" params={{ account: principalId }}>
|
|
167
|
+
{activity}
|
|
168
|
+
</Link>
|
|
169
|
+
),
|
|
170
|
+
];
|
|
130
171
|
|
|
131
172
|
return (
|
|
132
173
|
<>
|
|
133
174
|
<PageHeader
|
|
134
175
|
lead={<PrincipalAvatar type={principalType} id={principalId} size="lg" />}
|
|
135
|
-
title={principalId}
|
|
176
|
+
title={principalType === 'service' ? `service:${principalId}` : principalId}
|
|
177
|
+
description={
|
|
178
|
+
principalType === 'service'
|
|
179
|
+
? 'A service account: an identity for CI and other automation.'
|
|
180
|
+
: undefined
|
|
181
|
+
}
|
|
136
182
|
meta={
|
|
137
183
|
removed ? (
|
|
138
184
|
<span className="tag tag-red">Removed</span>
|
|
@@ -140,22 +186,7 @@ export function PrincipalPage({
|
|
|
140
186
|
entry?.principalType === 'user' && <InstanceRole principal={entry} />
|
|
141
187
|
)
|
|
142
188
|
}
|
|
143
|
-
actions={
|
|
144
|
-
(editable.length > 0 || entry !== undefined) && (
|
|
145
|
-
<>
|
|
146
|
-
{editable.length > 0 && (
|
|
147
|
-
<EditAccess
|
|
148
|
-
principalType={principalType}
|
|
149
|
-
principalId={principalId}
|
|
150
|
-
access={editable}
|
|
151
|
-
/>
|
|
152
|
-
)}
|
|
153
|
-
{entry !== undefined && (
|
|
154
|
-
<PrincipalActions principal={entry} trigger="btn btn-icon" />
|
|
155
|
-
)}
|
|
156
|
-
</>
|
|
157
|
-
)
|
|
158
|
-
}
|
|
189
|
+
actions={entry !== undefined && <PrincipalActions principal={entry} trigger="btn btn-icon" />}
|
|
159
190
|
/>
|
|
160
191
|
|
|
161
192
|
{change.state === 'failed' && (
|
|
@@ -168,13 +199,45 @@ export function PrincipalPage({
|
|
|
168
199
|
<Notice tone="bad">{report.error}</Notice>
|
|
169
200
|
</div>
|
|
170
201
|
)}
|
|
202
|
+
<PageTabs label={people ? 'User sections' : 'Service account sections'}>{tabs}</PageTabs>
|
|
203
|
+
|
|
204
|
+
<Outlet />
|
|
205
|
+
</>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A user's or service account's Access tab: its grants on every project
|
|
211
|
+
* where you manage access, and on every project; once it is removed, what
|
|
212
|
+
* its offboarding did instead.
|
|
213
|
+
*/
|
|
214
|
+
export function PrincipalAccess({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {
|
|
215
|
+
const { instanceRole } = useShell();
|
|
216
|
+
const report = useReport(principalType, principalId);
|
|
217
|
+
const access = useProjectAccess(principalType, principalId);
|
|
218
|
+
const kind = KIND[principalType];
|
|
219
|
+
const people = principalType === 'user';
|
|
220
|
+
const found = report?.ok === true ? report.report : null;
|
|
221
|
+
const removed = found?.status === 'removed';
|
|
222
|
+
|
|
223
|
+
const rows = access.flatMap(({ project, grants }) =>
|
|
224
|
+
grants.map((grant) => ({ project, grant })),
|
|
225
|
+
);
|
|
226
|
+
const errors = access.filter((entry) => entry.grantsError !== null);
|
|
227
|
+
// Grants to someone removed are refused until they are added back.
|
|
228
|
+
const editable = removed
|
|
229
|
+
? []
|
|
230
|
+
: access.filter(
|
|
231
|
+
({ project, grantsError }) => project.archivedAt === null && grantsError === null,
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<>
|
|
171
236
|
{removed && found !== null && <RemovedNotice report={found} />}
|
|
172
237
|
|
|
173
238
|
{/* Removal ends every grant, so there is no access left to show. */}
|
|
174
239
|
{!removed && (
|
|
175
240
|
<>
|
|
176
|
-
<h2 className="section-title">Project access</h2>
|
|
177
|
-
|
|
178
241
|
{errors.map(({ project, grantsError }) => (
|
|
179
242
|
<div key={project.slug} style={{ marginBottom: '0.75rem' }}>
|
|
180
243
|
<Notice tone="bad">
|
|
@@ -211,13 +274,12 @@ export function PrincipalPage({
|
|
|
211
274
|
<Tile name={project.slug} />
|
|
212
275
|
<Link
|
|
213
276
|
className="cell-link"
|
|
214
|
-
to=
|
|
277
|
+
to={people ? '/projects/$project/users' : '/projects/$project/service-accounts'}
|
|
215
278
|
params={{ project: project.slug }}
|
|
216
|
-
search={{ tab: people ? 'users' : 'tokens' }}
|
|
217
279
|
>
|
|
218
280
|
{project.name}
|
|
219
281
|
</Link>
|
|
220
|
-
{project.archivedAt !== null && <span className="tag tag-red">
|
|
282
|
+
{project.archivedAt !== null && <span className="tag tag-red">Archived</span>}
|
|
221
283
|
</span>
|
|
222
284
|
}
|
|
223
285
|
/>
|
|
@@ -226,12 +288,20 @@ export function PrincipalPage({
|
|
|
226
288
|
)}
|
|
227
289
|
</section>
|
|
228
290
|
|
|
291
|
+
{editable.length > 0 && (
|
|
292
|
+
<div className="table-actions">
|
|
293
|
+
<EditAccess principalType={principalType} principalId={principalId} access={editable} />
|
|
294
|
+
</div>
|
|
295
|
+
)}
|
|
296
|
+
|
|
229
297
|
{/* A root admin manages every project, so nothing is out of view. */}
|
|
230
298
|
{instanceRole !== 'root-admin' && (
|
|
231
299
|
<p className="hint section-foot">
|
|
232
300
|
Only projects where you manage access are listed.
|
|
233
301
|
</p>
|
|
234
302
|
)}
|
|
303
|
+
|
|
304
|
+
<EveryProjectGrants principalType={principalType} principalId={principalId} />
|
|
235
305
|
</>
|
|
236
306
|
)}
|
|
237
307
|
|
|
@@ -361,9 +431,9 @@ function EditAccess({
|
|
|
361
431
|
>
|
|
362
432
|
{held.level === 'custom' && <option value="custom">Keep as is</option>}
|
|
363
433
|
<option value="none">No access</option>
|
|
364
|
-
<option value="owner">
|
|
365
|
-
<option value="viewer">
|
|
366
|
-
<option value="developer">
|
|
434
|
+
<option value="owner">{ROLES.owner.name}</option>
|
|
435
|
+
<option value="viewer">{ROLES.viewer.name}: all</option>
|
|
436
|
+
<option value="developer">{ROLES.developer.name}: all</option>
|
|
367
437
|
{environments.length > 0 && <option value="env">Per environment…</option>}
|
|
368
438
|
</select>
|
|
369
439
|
{(plan.level === 'owner' ||
|
|
@@ -403,8 +473,8 @@ function EditAccess({
|
|
|
403
473
|
}}
|
|
404
474
|
>
|
|
405
475
|
<option value="">No access</option>
|
|
406
|
-
<option value="viewer">
|
|
407
|
-
<option value="developer">
|
|
476
|
+
<option value="viewer">{ROLES.viewer.name}</option>
|
|
477
|
+
<option value="developer">{ROLES.developer.name}</option>
|
|
408
478
|
</select>
|
|
409
479
|
{current !== null && (
|
|
410
480
|
<ExpiryField
|
|
@@ -462,46 +532,6 @@ function EditAccess({
|
|
|
462
532
|
);
|
|
463
533
|
}
|
|
464
534
|
|
|
465
|
-
/**
|
|
466
|
-
* When one grant ends, as a date: access lasts through that day, UTC. Blank
|
|
467
|
-
* reads "Never" where the browser lets the empty field be restyled.
|
|
468
|
-
*/
|
|
469
|
-
function ExpiryField({
|
|
470
|
-
label,
|
|
471
|
-
expiresAt,
|
|
472
|
-
onChange,
|
|
473
|
-
}: {
|
|
474
|
-
label: string;
|
|
475
|
-
expiresAt: string | null;
|
|
476
|
-
onChange: (expiresAt: string | null) => void;
|
|
477
|
-
}) {
|
|
478
|
-
const date = dateFromExpiry(expiresAt);
|
|
479
|
-
return (
|
|
480
|
-
<span className={`expiry${date === '' ? ' is-never' : ''}`}>
|
|
481
|
-
<input
|
|
482
|
-
className="input select-sm"
|
|
483
|
-
type="date"
|
|
484
|
-
aria-label={label}
|
|
485
|
-
min={new Date().toISOString().slice(0, 10)}
|
|
486
|
-
value={date}
|
|
487
|
-
onChange={(event) => onChange(expiryFromDate(event.target.value))}
|
|
488
|
-
/>
|
|
489
|
-
<span className="expiry-never" aria-hidden="true">
|
|
490
|
-
Never
|
|
491
|
-
</span>
|
|
492
|
-
<button
|
|
493
|
-
className="btn btn-quiet btn-sm btn-icon"
|
|
494
|
-
type="button"
|
|
495
|
-
aria-label={`${label}: never`}
|
|
496
|
-
title="Never expires"
|
|
497
|
-
onClick={() => onChange(null)}
|
|
498
|
-
>
|
|
499
|
-
<X size={12} />
|
|
500
|
-
</button>
|
|
501
|
-
</span>
|
|
502
|
-
);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
535
|
function AccessChangeTag({ change }: { change: AccessChange }) {
|
|
506
536
|
const until = (expiresAt: string | null) =>
|
|
507
537
|
expiresAt === null ? '' : ` until ${dateFromExpiry(expiresAt)}`;
|
|
@@ -13,7 +13,7 @@ import { Check, Search } from './icons';
|
|
|
13
13
|
type PrincipalType = DirectoryPrincipal['principalType'];
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Who a grant is for: picked from the registered users or
|
|
16
|
+
* Who a grant is for: picked from the registered users or service accounts, each shown
|
|
17
17
|
* with what it already holds on this project, or typed when the list is not
|
|
18
18
|
* yours to read.
|
|
19
19
|
*
|
|
@@ -21,7 +21,7 @@ type PrincipalType = DirectoryPrincipal['principalType'];
|
|
|
21
21
|
* would write a refusal to the audit log in their name, so they get a text
|
|
22
22
|
* field and the server's answer instead. The list is asked for when the
|
|
23
23
|
* dialog opens rather than with the page, since most visits never open it,
|
|
24
|
-
* and shared with the Users and
|
|
24
|
+
* and shared with the Users and Service accounts pages through the cache.
|
|
25
25
|
*/
|
|
26
26
|
export function PrincipalPicker({
|
|
27
27
|
principalType,
|
|
@@ -49,7 +49,7 @@ export function PrincipalPicker({
|
|
|
49
49
|
return (
|
|
50
50
|
<label className="field">
|
|
51
51
|
<span className="label">
|
|
52
|
-
{principalType === 'user' ? 'Email' : 'Service
|
|
52
|
+
{principalType === 'user' ? 'Email' : 'Service account name'}
|
|
53
53
|
</span>
|
|
54
54
|
<input
|
|
55
55
|
className="input input-mono"
|
|
@@ -61,7 +61,7 @@ export function PrincipalPicker({
|
|
|
61
61
|
onChange={(event) => onChange(event.target.value)}
|
|
62
62
|
/>
|
|
63
63
|
<span className="hint">
|
|
64
|
-
The {kind} must already be registered under {principalType === 'user' ? 'Users' : '
|
|
64
|
+
The {kind} must already be registered under {principalType === 'user' ? 'Users' : 'Service accounts'}.
|
|
65
65
|
</span>
|
|
66
66
|
</label>
|
|
67
67
|
);
|
|
@@ -109,7 +109,7 @@ export function PrincipalPicker({
|
|
|
109
109
|
) : registered.length === 0 ? (
|
|
110
110
|
<p className="picker-empty">
|
|
111
111
|
No {kind}s are registered yet.{' '}
|
|
112
|
-
<Link to={principalType === 'user' ? '/users' : '/
|
|
112
|
+
<Link to={principalType === 'user' ? '/users' : '/service-accounts'}>Add one</Link> first.
|
|
113
113
|
</p>
|
|
114
114
|
) : matches.length === 0 ? (
|
|
115
115
|
<p className="picker-empty">No registered {kind} matches “{query.trim()}”.</p>
|
|
@@ -41,15 +41,15 @@ export function PrincipalLink({
|
|
|
41
41
|
return (
|
|
42
42
|
<span className="cell-principal">
|
|
43
43
|
<PrincipalAvatar type={type} id={id} />
|
|
44
|
-
{!mounted(type === 'user' ? '/users/$user' : '/
|
|
45
|
-
<span>{id}</span>
|
|
44
|
+
{!mounted(type === 'user' ? '/users/$user' : '/service-accounts/$account') ? (
|
|
45
|
+
<span>{type === 'user' ? id : `service:${id}`}</span>
|
|
46
46
|
) : type === 'user' ? (
|
|
47
47
|
<Link className={className} to="/users/$user" params={{ user: id }}>
|
|
48
48
|
{id}
|
|
49
49
|
</Link>
|
|
50
50
|
) : (
|
|
51
|
-
<Link className={className} to="/
|
|
52
|
-
{id}
|
|
51
|
+
<Link className={className} to="/service-accounts/$account" params={{ account: id }}>
|
|
52
|
+
service:{id}
|
|
53
53
|
</Link>
|
|
54
54
|
)}
|
|
55
55
|
</span>
|