@coffre/ui 0.3.0 → 0.4.1
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/connected-apps-CUOyEZXR.js +146 -0
- package/dist/chunks/connected-apps-CUOyEZXR.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-CxxrnGUL.js} +177 -60
- package/dist/chunks/directory-CxxrnGUL.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-CXcmhujY.js +669 -0
- package/dist/chunks/grants-CXcmhujY.js.map +1 -0
- package/dist/chunks/offboarding-6eAduCsM.js +305 -0
- package/dist/chunks/offboarding-6eAduCsM.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-B9R2zPlp.js} +259 -251
- package/dist/chunks/principal-page-B9R2zPlp.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-CZdI2MJG.js} +75 -21
- package/dist/chunks/use-change-CZdI2MJG.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 +385 -31
- package/dist/index.js +188 -102
- package/dist/index.js.map +1 -1
- package/dist/pages/account.d.ts +2 -2
- package/dist/pages/account.js +174 -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/connected-apps.tsx +138 -0
- package/src/components/delete-place.tsx +180 -0
- package/src/components/directory.tsx +266 -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 +62 -34
- package/src/components/page.tsx +4 -1
- package/src/components/principal-page.tsx +154 -108
- 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 -3
- 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 +77 -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 -42
- package/src/pages/account.tsx +176 -133
- 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 +57 -10
- 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
|
-
import { directoryList } from '../lib/changes';
|
|
8
|
-
import { affects, managedProjects, queries } from '../lib/queries';
|
|
8
|
+
import { directoryList, disconnectMemberApp } from '../lib/changes';
|
|
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';
|
|
@@ -22,65 +24,74 @@ import {
|
|
|
22
24
|
type AccessChange,
|
|
23
25
|
type AccessPlan,
|
|
24
26
|
} from '../lib/access-plan';
|
|
25
|
-
import type { DirectoryPrincipal, GrantRow, ProjectSummary } from '../shared/models';
|
|
27
|
+
import type { DirectoryPrincipal, GrantRow, PrincipalReport, ProjectSummary } from '../shared/models';
|
|
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';
|
|
35
|
+
import { ConnectedAppsCard } from './connected-apps';
|
|
31
36
|
import { PrincipalAvatar } from './principal';
|
|
32
37
|
import { Tile } from './tile';
|
|
33
|
-
import { Clock, Folder, Key, Pencil, Users, X } from './icons';
|
|
38
|
+
import { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';
|
|
39
|
+
import { PageTabs } from './tabs';
|
|
34
40
|
|
|
35
41
|
type PrincipalType = DirectoryPrincipal['principalType'];
|
|
36
42
|
|
|
37
43
|
type ProjectAccess = { project: ProjectSummary; grants: GrantRow[]; grantsError: string | null };
|
|
38
44
|
|
|
45
|
+
/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */
|
|
46
|
+
function useReport(principalType: PrincipalType, principalId: string) {
|
|
47
|
+
const { capabilities } = useShell();
|
|
48
|
+
return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.canManageGrants)).data;
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
/**
|
|
40
|
-
*
|
|
41
|
-
* read:
|
|
42
|
-
* grants on every project where you manage access.
|
|
52
|
+
* Its grants on every project where you manage access, which `loadAccess`
|
|
53
|
+
* read: there is no call for one member's, so each project's are filtered.
|
|
43
54
|
*/
|
|
44
|
-
function
|
|
55
|
+
function useProjectAccess(principalType: PrincipalType, principalId: string): ProjectAccess[] {
|
|
45
56
|
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
|
-
);
|
|
57
|
+
const managed = managedProjects(useShell().projects);
|
|
51
58
|
const grants = useSuspenseQueries({
|
|
52
59
|
queries: managed.map((project) => queries.grants(client, project.slug)),
|
|
53
60
|
});
|
|
54
|
-
|
|
61
|
+
return managed.map((project, index) => {
|
|
55
62
|
const result = grants[index]!.data;
|
|
56
63
|
return {
|
|
57
64
|
project,
|
|
65
|
+
// Grants on every project show once, below: not again in each project they reach.
|
|
58
66
|
grants: result.ok
|
|
59
67
|
? result.grants.filter(
|
|
60
|
-
(grant) =>
|
|
68
|
+
(grant) =>
|
|
69
|
+
grant.principalType === principalType &&
|
|
70
|
+
grant.principalId === principalId &&
|
|
71
|
+
grant.scope !== 'every-project',
|
|
61
72
|
)
|
|
62
73
|
: [],
|
|
63
74
|
grantsError: result.ok ? null : result.error,
|
|
64
75
|
};
|
|
65
76
|
});
|
|
66
|
-
return { report, access };
|
|
67
77
|
}
|
|
68
78
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
79
|
+
/**
|
|
80
|
+
* A user's or service account's page: who it is, its menu, and its tabs,
|
|
81
|
+
* each a page of its own under this one. Access is a user's first tab; a
|
|
82
|
+
* service account's is how it signs in, while it shows one. A tab the
|
|
83
|
+
* deployment left out is not offered.
|
|
84
|
+
*/
|
|
85
|
+
export function PrincipalLayout({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {
|
|
86
|
+
const shell = useShell();
|
|
87
|
+
const mounted = useMounted();
|
|
88
|
+
const { capabilities } = shell;
|
|
89
|
+
const report = useReport(principalType, principalId);
|
|
78
90
|
// A role change or removal made from this page's menu, refused.
|
|
79
91
|
const { status, dismiss } = useChangeStatus(directoryList.queryKey);
|
|
80
92
|
const change = status(memberRef(principalType, principalId));
|
|
81
93
|
const kind = KIND[principalType];
|
|
82
94
|
const people = principalType === 'user';
|
|
83
|
-
const list = people ? '/users' : '/tokens';
|
|
84
95
|
const found = report?.ok === true ? report.report : null;
|
|
85
96
|
const removed = found?.status === 'removed';
|
|
86
97
|
const entry =
|
|
@@ -98,15 +109,15 @@ export function PrincipalPage({
|
|
|
98
109
|
// miss there means there is no such user. Everyone else only reaches this
|
|
99
110
|
// page through projects they manage.
|
|
100
111
|
const unknown = report?.ok === true && found === null;
|
|
101
|
-
if (unknown || (report === null &&
|
|
112
|
+
if (unknown || (report === null && managedProjects(shell.projects).length === 0)) {
|
|
102
113
|
return (
|
|
103
114
|
<ClosedDoor
|
|
104
115
|
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
|
|
116
|
+
label={<span className="mono">{people ? principalId : `service:${principalId}`}</span>}
|
|
117
|
+
title={people ? 'No such user for you' : 'No such service account for you'}
|
|
107
118
|
actions={
|
|
108
|
-
<Link className="btn" to={
|
|
109
|
-
All {people ? 'users' : '
|
|
119
|
+
<Link className="btn" to={people ? '/users' : '/service-accounts'}>
|
|
120
|
+
All {people ? 'users' : 'service accounts'}
|
|
110
121
|
</Link>
|
|
111
122
|
}
|
|
112
123
|
>
|
|
@@ -117,22 +128,58 @@ export function PrincipalPage({
|
|
|
117
128
|
);
|
|
118
129
|
}
|
|
119
130
|
|
|
120
|
-
const
|
|
121
|
-
|
|
131
|
+
const access = (
|
|
132
|
+
<>
|
|
133
|
+
{removed ? <Archive size={15} /> : <Folder size={15} />}
|
|
134
|
+
{removed ? 'Offboarding' : 'Access'}
|
|
135
|
+
</>
|
|
122
136
|
);
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
const activity = (
|
|
138
|
+
<>
|
|
139
|
+
<Activity size={15} />
|
|
140
|
+
Activity
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
const tabs = people
|
|
144
|
+
? [
|
|
145
|
+
<Link key="access" to="/users/$user" params={{ user: principalId }} activeOptions={{ exact: true, includeSearch: false }}>
|
|
146
|
+
{access}
|
|
147
|
+
</Link>,
|
|
148
|
+
capabilities.canReadAudit && mounted('/users/$user/activity') && (
|
|
149
|
+
<Link key="activity" to="/users/$user/activity" params={{ user: principalId }}>
|
|
150
|
+
{activity}
|
|
151
|
+
</Link>
|
|
152
|
+
),
|
|
153
|
+
]
|
|
154
|
+
: [
|
|
155
|
+
signInWays(shell, report) !== null && (
|
|
156
|
+
<Link key="sign-in" to="/service-accounts/$account" params={{ account: principalId }} activeOptions={{ exact: true, includeSearch: false }}>
|
|
157
|
+
<LinkIcon size={15} />
|
|
158
|
+
Sign-in
|
|
159
|
+
</Link>
|
|
160
|
+
),
|
|
161
|
+
mounted('/service-accounts/$account/access') && (
|
|
162
|
+
<Link key="access" to="/service-accounts/$account/access" params={{ account: principalId }}>
|
|
163
|
+
{access}
|
|
164
|
+
</Link>
|
|
165
|
+
),
|
|
166
|
+
capabilities.canReadAudit && mounted('/service-accounts/$account/activity') && (
|
|
167
|
+
<Link key="activity" to="/service-accounts/$account/activity" params={{ account: principalId }}>
|
|
168
|
+
{activity}
|
|
169
|
+
</Link>
|
|
170
|
+
),
|
|
171
|
+
];
|
|
130
172
|
|
|
131
173
|
return (
|
|
132
174
|
<>
|
|
133
175
|
<PageHeader
|
|
134
176
|
lead={<PrincipalAvatar type={principalType} id={principalId} size="lg" />}
|
|
135
|
-
title={principalId}
|
|
177
|
+
title={principalType === 'service' ? `service:${principalId}` : principalId}
|
|
178
|
+
description={
|
|
179
|
+
principalType === 'service'
|
|
180
|
+
? 'A service account: an identity for CI and other automation.'
|
|
181
|
+
: undefined
|
|
182
|
+
}
|
|
136
183
|
meta={
|
|
137
184
|
removed ? (
|
|
138
185
|
<span className="tag tag-red">Removed</span>
|
|
@@ -140,22 +187,7 @@ export function PrincipalPage({
|
|
|
140
187
|
entry?.principalType === 'user' && <InstanceRole principal={entry} />
|
|
141
188
|
)
|
|
142
189
|
}
|
|
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
|
-
}
|
|
190
|
+
actions={entry !== undefined && <PrincipalActions principal={entry} trigger="btn btn-icon" />}
|
|
159
191
|
/>
|
|
160
192
|
|
|
161
193
|
{change.state === 'failed' && (
|
|
@@ -168,13 +200,45 @@ export function PrincipalPage({
|
|
|
168
200
|
<Notice tone="bad">{report.error}</Notice>
|
|
169
201
|
</div>
|
|
170
202
|
)}
|
|
203
|
+
<PageTabs label={people ? 'User sections' : 'Service account sections'}>{tabs}</PageTabs>
|
|
204
|
+
|
|
205
|
+
<Outlet />
|
|
206
|
+
</>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A user's or service account's Access tab: its grants on every project
|
|
212
|
+
* where you manage access, and on every project; once it is removed, what
|
|
213
|
+
* its offboarding did instead.
|
|
214
|
+
*/
|
|
215
|
+
export function PrincipalAccess({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {
|
|
216
|
+
const { instanceRole, features } = useShell();
|
|
217
|
+
const report = useReport(principalType, principalId);
|
|
218
|
+
const access = useProjectAccess(principalType, principalId);
|
|
219
|
+
const kind = KIND[principalType];
|
|
220
|
+
const people = principalType === 'user';
|
|
221
|
+
const found = report?.ok === true ? report.report : null;
|
|
222
|
+
const removed = found?.status === 'removed';
|
|
223
|
+
|
|
224
|
+
const rows = access.flatMap(({ project, grants }) =>
|
|
225
|
+
grants.map((grant) => ({ project, grant })),
|
|
226
|
+
);
|
|
227
|
+
const errors = access.filter((entry) => entry.grantsError !== null);
|
|
228
|
+
// Grants to someone removed are refused until they are added back.
|
|
229
|
+
const editable = removed
|
|
230
|
+
? []
|
|
231
|
+
: access.filter(
|
|
232
|
+
({ project, grantsError }) => project.archivedAt === null && grantsError === null,
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<>
|
|
171
237
|
{removed && found !== null && <RemovedNotice report={found} />}
|
|
172
238
|
|
|
173
239
|
{/* Removal ends every grant, so there is no access left to show. */}
|
|
174
240
|
{!removed && (
|
|
175
241
|
<>
|
|
176
|
-
<h2 className="section-title">Project access</h2>
|
|
177
|
-
|
|
178
242
|
{errors.map(({ project, grantsError }) => (
|
|
179
243
|
<div key={project.slug} style={{ marginBottom: '0.75rem' }}>
|
|
180
244
|
<Notice tone="bad">
|
|
@@ -211,13 +275,12 @@ export function PrincipalPage({
|
|
|
211
275
|
<Tile name={project.slug} />
|
|
212
276
|
<Link
|
|
213
277
|
className="cell-link"
|
|
214
|
-
to=
|
|
278
|
+
to={people ? '/projects/$project/users' : '/projects/$project/service-accounts'}
|
|
215
279
|
params={{ project: project.slug }}
|
|
216
|
-
search={{ tab: people ? 'users' : 'tokens' }}
|
|
217
280
|
>
|
|
218
281
|
{project.name}
|
|
219
282
|
</Link>
|
|
220
|
-
{project.archivedAt !== null && <span className="tag tag-red">
|
|
283
|
+
{project.archivedAt !== null && <span className="tag tag-red">Archived</span>}
|
|
221
284
|
</span>
|
|
222
285
|
}
|
|
223
286
|
/>
|
|
@@ -226,12 +289,23 @@ export function PrincipalPage({
|
|
|
226
289
|
)}
|
|
227
290
|
</section>
|
|
228
291
|
|
|
292
|
+
{editable.length > 0 && (
|
|
293
|
+
<div className="table-actions">
|
|
294
|
+
<EditAccess principalType={principalType} principalId={principalId} access={editable} />
|
|
295
|
+
</div>
|
|
296
|
+
)}
|
|
297
|
+
|
|
229
298
|
{/* A root admin manages every project, so nothing is out of view. */}
|
|
230
299
|
{instanceRole !== 'root-admin' && (
|
|
231
300
|
<p className="hint section-foot">
|
|
232
301
|
Only projects where you manage access are listed.
|
|
233
302
|
</p>
|
|
234
303
|
)}
|
|
304
|
+
|
|
305
|
+
<EveryProjectGrants principalType={principalType} principalId={principalId} />
|
|
306
|
+
|
|
307
|
+
{/* Only an owner reads the report that lists them; removal disconnects them. */}
|
|
308
|
+
{features.mcp && people && found !== null && <MemberApps principalId={principalId} apps={found.apps} />}
|
|
235
309
|
</>
|
|
236
310
|
)}
|
|
237
311
|
|
|
@@ -240,6 +314,18 @@ export function PrincipalPage({
|
|
|
240
314
|
);
|
|
241
315
|
}
|
|
242
316
|
|
|
317
|
+
/** A person's connected apps, for an owner, who may disconnect any of them. */
|
|
318
|
+
function MemberApps({ principalId, apps }: { principalId: string; apps: PrincipalReport['apps'] }) {
|
|
319
|
+
return (
|
|
320
|
+
<ConnectedAppsCard
|
|
321
|
+
apps={apps}
|
|
322
|
+
change={disconnectMemberApp(useCoffre(), memberRef('user', principalId))}
|
|
323
|
+
description="AI assistants and other MCP clients they connected. Each acts as them, never beyond their access. Disconnecting one stops it at its next request; removing them disconnects every one."
|
|
324
|
+
empty="They have connected none. An app connects only after they approve it on coffre's page."
|
|
325
|
+
/>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
243
329
|
/**
|
|
244
330
|
* One principal's access to every project you manage, edited in one place.
|
|
245
331
|
*
|
|
@@ -361,9 +447,9 @@ function EditAccess({
|
|
|
361
447
|
>
|
|
362
448
|
{held.level === 'custom' && <option value="custom">Keep as is</option>}
|
|
363
449
|
<option value="none">No access</option>
|
|
364
|
-
<option value="owner">
|
|
365
|
-
<option value="viewer">
|
|
366
|
-
<option value="developer">
|
|
450
|
+
<option value="owner">{ROLES.owner.name}</option>
|
|
451
|
+
<option value="viewer">{ROLES.viewer.name}: all</option>
|
|
452
|
+
<option value="developer">{ROLES.developer.name}: all</option>
|
|
367
453
|
{environments.length > 0 && <option value="env">Per environment…</option>}
|
|
368
454
|
</select>
|
|
369
455
|
{(plan.level === 'owner' ||
|
|
@@ -403,8 +489,8 @@ function EditAccess({
|
|
|
403
489
|
}}
|
|
404
490
|
>
|
|
405
491
|
<option value="">No access</option>
|
|
406
|
-
<option value="viewer">
|
|
407
|
-
<option value="developer">
|
|
492
|
+
<option value="viewer">{ROLES.viewer.name}</option>
|
|
493
|
+
<option value="developer">{ROLES.developer.name}</option>
|
|
408
494
|
</select>
|
|
409
495
|
{current !== null && (
|
|
410
496
|
<ExpiryField
|
|
@@ -462,46 +548,6 @@ function EditAccess({
|
|
|
462
548
|
);
|
|
463
549
|
}
|
|
464
550
|
|
|
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
551
|
function AccessChangeTag({ change }: { change: AccessChange }) {
|
|
506
552
|
const until = (expiresAt: string | null) =>
|
|
507
553
|
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>
|