@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,206 +1,173 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { d as Tile, i as PageHeader, n as ClosedDoor, s as memberRef, u as useCoffre } from "./page-
|
|
4
|
-
import { t as ItemFailure } from "./row-state-
|
|
5
|
-
import {
|
|
6
|
-
import { t as useShell } from "./use-shell-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { t as useMounted } from "./mounted-jJmqqV_n.js";
|
|
2
|
+
import { a as ErrorLine, c as Notice, i as EmptyState, l as Spinner, s as Modal, u as Timestamp } from "./ui-DJje3gST.js";
|
|
3
|
+
import { A as Key, H as Pencil, J as ShieldCheck, N as Link$1, T as Folder, X as SlashCircle, d as Tile, f as Activity, h as Archive, i as PageHeader, l as uiResult, n as ClosedDoor, rt as Users, s as memberRef, u as useCoffre, x as Clock } from "./page-DvsgZ2Hd.js";
|
|
4
|
+
import { t as ItemFailure } from "./row-state-DOPUsjQK.js";
|
|
5
|
+
import { d as managedProjects, g as signInWays, p as queries, r as keys, t as affects } from "./queries-DVR_i3rA.js";
|
|
6
|
+
import { t as useShell } from "./use-shell-rNKfGjdj.js";
|
|
7
|
+
import { k as projectAccessLabel, l as directoryList, n as useChangeStatus } from "./use-change-DUiGO19U.js";
|
|
8
|
+
import { t as PrincipalAvatar } from "./principal-BIN-xwZw.js";
|
|
9
|
+
import { i as PrincipalActions, n as InstanceRole, r as KIND } from "./directory-zr3ek7Mc.js";
|
|
10
|
+
import { a as lines, i as describe, t as Sentence } from "./audit-sentence-BhHmvQX_.js";
|
|
11
|
+
import { a as useAction } from "./validation-D312_NLf.js";
|
|
12
|
+
import { a as EveryProjectGrants, d as accessPatch, f as dateFromExpiry, g as withLevel, h as withEnvironment, l as ExpiryField, m as planFromGrants, n as GrantsTable, p as environmentAccess, t as GrantRowView, u as accessChanges } from "./grants-Cw1FyGID.js";
|
|
13
|
+
import { t as PageTabs } from "./tabs-BmwKfUeK.js";
|
|
14
|
+
import { r as RemovedNotice, t as PrincipalReportCards } from "./offboarding-CE6d7um1.js";
|
|
12
15
|
import { useState } from "react";
|
|
13
|
-
import { Link } from "@tanstack/react-router";
|
|
16
|
+
import { Link, Outlet } from "@tanstack/react-router";
|
|
14
17
|
import { toast } from "sonner";
|
|
15
18
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
import { useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return Object.hasOwn(plan.environments, slug) ? plan.environments[slug] : null;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Read what a principal holds on a project back into the editor's terms.
|
|
24
|
-
* `environments` are the ones the editor can set: live, and not archived.
|
|
25
|
-
*/
|
|
26
|
-
function planFromGrants(grants, environments) {
|
|
27
|
-
if (grants.length === 0) return {
|
|
28
|
-
level: "none",
|
|
29
|
-
expiresAt: null,
|
|
30
|
-
environments: {}
|
|
31
|
-
};
|
|
32
|
-
const [only] = grants;
|
|
33
|
-
if (grants.length === 1 && only.environmentSlug === null && (only.role === "owner" || only.role === "viewer" || only.role === "developer")) return {
|
|
34
|
-
level: only.role,
|
|
35
|
-
expiresAt: only.expiresAt,
|
|
36
|
-
environments: {}
|
|
37
|
-
};
|
|
38
|
-
const perEnvironment = {};
|
|
39
|
-
for (const grant of grants) {
|
|
40
|
-
const slug = grant.environmentSlug;
|
|
41
|
-
if (slug === null || !environments.includes(slug) || Object.hasOwn(perEnvironment, slug) || grant.role !== "viewer" && grant.role !== "developer") return {
|
|
42
|
-
level: "custom",
|
|
43
|
-
expiresAt: null,
|
|
44
|
-
environments: {}
|
|
45
|
-
};
|
|
46
|
-
perEnvironment[slug] = {
|
|
47
|
-
role: grant.role,
|
|
48
|
-
expiresAt: grant.expiresAt
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
level: "env",
|
|
53
|
-
expiresAt: null,
|
|
54
|
-
environments: perEnvironment
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Switch a plan's level. Going from read or write everywhere to per
|
|
59
|
-
* environment starts every environment at that level and expiry, so the
|
|
60
|
-
* switch alone keeps the same reach.
|
|
61
|
-
*/
|
|
62
|
-
function withLevel(plan, level, environments) {
|
|
63
|
-
if (level === "env" && (plan.level === "viewer" || plan.level === "developer") && Object.keys(plan.environments).length === 0) {
|
|
64
|
-
const access = {
|
|
65
|
-
role: plan.level,
|
|
66
|
-
expiresAt: plan.expiresAt
|
|
67
|
-
};
|
|
68
|
-
return {
|
|
69
|
-
...plan,
|
|
70
|
-
level,
|
|
71
|
-
environments: Object.fromEntries(environments.map((slug) => [slug, access]))
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
...plan,
|
|
76
|
-
level
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/** Set one environment's access, or take it away with `null`. */
|
|
80
|
-
function withEnvironment(plan, slug, access) {
|
|
81
|
-
const environments = { ...plan.environments };
|
|
82
|
-
if (access === null) delete environments[slug];
|
|
83
|
-
else environments[slug] = access;
|
|
84
|
-
return {
|
|
85
|
-
...plan,
|
|
86
|
-
environments
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function grantsFor(plan) {
|
|
90
|
-
switch (plan.level) {
|
|
91
|
-
case "none":
|
|
92
|
-
case "custom": return [];
|
|
93
|
-
case "owner":
|
|
94
|
-
case "viewer":
|
|
95
|
-
case "developer": return [{
|
|
96
|
-
role: plan.level,
|
|
97
|
-
environmentSlug: null,
|
|
98
|
-
expiresAt: plan.expiresAt
|
|
99
|
-
}];
|
|
100
|
-
case "env": return Object.entries(plan.environments).map(([environmentSlug, access]) => ({
|
|
101
|
-
environmentSlug,
|
|
102
|
-
...access
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/** The server and the date field spell the same instant differently. */
|
|
107
|
-
function sameExpiry(a, b) {
|
|
108
|
-
return a === b || a !== null && b !== null && Date.parse(a) === Date.parse(b);
|
|
109
|
-
}
|
|
19
|
+
import { useInfiniteQuery, useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
|
|
20
|
+
import { ROLES } from "@coffre/core/access";
|
|
21
|
+
//#region src/components/actions-log.tsx
|
|
22
|
+
var PAGE_SIZE = 50;
|
|
110
23
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
24
|
+
* Everything one member did, newest first, from the audit log: the same
|
|
25
|
+
* entries `coffre audit --actor` lists, said as the audit page says them.
|
|
26
|
+
* Older pages come on request.
|
|
114
27
|
*/
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
28
|
+
function ActionsLog({ member }) {
|
|
29
|
+
const client = useCoffre();
|
|
30
|
+
const log = useInfiniteQuery({
|
|
31
|
+
queryKey: [
|
|
32
|
+
...keys.audit,
|
|
33
|
+
"actor",
|
|
34
|
+
member
|
|
35
|
+
],
|
|
36
|
+
staleTime: 0,
|
|
37
|
+
initialPageParam: void 0,
|
|
38
|
+
queryFn: ({ pageParam }) => uiResult(() => client.audit.list({
|
|
39
|
+
actor: member,
|
|
40
|
+
limit: PAGE_SIZE,
|
|
41
|
+
before: pageParam
|
|
42
|
+
})),
|
|
43
|
+
getNextPageParam: (page) => page.ok && page.entries.length === PAGE_SIZE ? page.entries.at(-1).seq : void 0
|
|
124
44
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
kind: "expiry",
|
|
129
|
-
grant,
|
|
130
|
-
expiresAt: want.expiresAt
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
for (const [id, grant] of held) if (!wanted.has(id)) changes.push({
|
|
134
|
-
kind: "revoke",
|
|
135
|
-
grant
|
|
45
|
+
if (log.isPending) return /* @__PURE__ */ jsxs("p", {
|
|
46
|
+
className: "hint",
|
|
47
|
+
children: [/* @__PURE__ */ jsx(Spinner, { size: 13 }), " Reading the log…"]
|
|
136
48
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
49
|
+
const failed = log.data?.pages.find((page) => !page.ok);
|
|
50
|
+
if (failed !== void 0 && !failed.ok) return /* @__PURE__ */ jsx(Notice, {
|
|
51
|
+
tone: "bad",
|
|
52
|
+
children: failed.error
|
|
53
|
+
});
|
|
54
|
+
const shown = lines((log.data?.pages ?? []).flatMap((page) => page.ok ? page.entries : []));
|
|
55
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("section", {
|
|
56
|
+
className: "card",
|
|
57
|
+
"aria-label": "Actions log",
|
|
58
|
+
children: shown.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
59
|
+
title: "Nothing done yet",
|
|
60
|
+
children: "Every read, write and change they make is listed here."
|
|
61
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
62
|
+
className: "dt-wrap",
|
|
63
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
64
|
+
className: "dt actions-log stacks stacks-inline",
|
|
65
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
66
|
+
/* @__PURE__ */ jsx("th", {
|
|
67
|
+
className: "col-shrink",
|
|
68
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
69
|
+
className: "th",
|
|
70
|
+
children: [/* @__PURE__ */ jsx(Clock, { size: 14 }), "When"]
|
|
71
|
+
})
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ jsx("th", { children: /* @__PURE__ */ jsxs("span", {
|
|
74
|
+
className: "th",
|
|
75
|
+
children: [/* @__PURE__ */ jsx(Activity, { size: 14 }), "Action"]
|
|
76
|
+
}) }),
|
|
77
|
+
/* @__PURE__ */ jsx("th", {
|
|
78
|
+
className: "col-shrink",
|
|
79
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
80
|
+
className: "th",
|
|
81
|
+
children: [/* @__PURE__ */ jsx(ShieldCheck, { size: 14 }), "Outcome"]
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: shown.map((batch) => {
|
|
85
|
+
const lead = batch[0];
|
|
86
|
+
const sentence = describe(batch);
|
|
87
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
88
|
+
className: sentence.refused ? "is-denied" : void 0,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx("td", {
|
|
91
|
+
className: "nowrap cell-muted",
|
|
92
|
+
title: lead.occurredAt,
|
|
93
|
+
children: /* @__PURE__ */ jsx(Timestamp, {
|
|
94
|
+
iso: lead.occurredAt,
|
|
95
|
+
display: "relative"
|
|
96
|
+
})
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx("td", {
|
|
99
|
+
className: "cell-sentence",
|
|
100
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
101
|
+
className: "sentence",
|
|
102
|
+
children: /* @__PURE__ */ jsx(Sentence, { parts: sentence.parts })
|
|
103
|
+
})
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ jsx("td", {
|
|
106
|
+
className: "nowrap",
|
|
107
|
+
"data-label": "Outcome",
|
|
108
|
+
children: sentence.refused ? /* @__PURE__ */ jsxs("span", {
|
|
109
|
+
className: "decided decided-refused",
|
|
110
|
+
children: [/* @__PURE__ */ jsx(SlashCircle, { size: 13 }), "Refused"]
|
|
111
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
112
|
+
className: "cell-muted",
|
|
113
|
+
children: "Allowed"
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
}, lead.seq);
|
|
118
|
+
}) })]
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
}), log.hasNextPage && /* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: "table-actions",
|
|
123
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
124
|
+
type: "button",
|
|
125
|
+
className: "btn",
|
|
126
|
+
disabled: log.isFetchingNextPage,
|
|
127
|
+
onClick: () => void log.fetchNextPage(),
|
|
128
|
+
children: [log.isFetchingNextPage && /* @__PURE__ */ jsx(Spinner, {}), "Show older"]
|
|
129
|
+
})
|
|
130
|
+
})] });
|
|
170
131
|
}
|
|
171
132
|
//#endregion
|
|
172
133
|
//#region src/components/principal-page.tsx
|
|
134
|
+
/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */
|
|
135
|
+
function useReport(principalType, principalId) {
|
|
136
|
+
const { capabilities } = useShell();
|
|
137
|
+
return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.canManageGrants)).data;
|
|
138
|
+
}
|
|
173
139
|
/**
|
|
174
|
-
*
|
|
175
|
-
* read:
|
|
176
|
-
* grants on every project where you manage access.
|
|
140
|
+
* Its grants on every project where you manage access, which `loadAccess`
|
|
141
|
+
* read: there is no call for one member's, so each project's are filtered.
|
|
177
142
|
*/
|
|
178
|
-
function
|
|
143
|
+
function useProjectAccess(principalType, principalId) {
|
|
179
144
|
const client = useCoffre();
|
|
180
|
-
const
|
|
181
|
-
const managed = managedProjects(projects);
|
|
182
|
-
const { data: report } = useSuspenseQuery(queries.report(client, memberRef(principalType, principalId), capabilities.canManageGrants));
|
|
145
|
+
const managed = managedProjects(useShell().projects);
|
|
183
146
|
const grants = useSuspenseQueries({ queries: managed.map((project) => queries.grants(client, project.slug)) });
|
|
184
|
-
return {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
};
|
|
193
|
-
})
|
|
194
|
-
};
|
|
147
|
+
return managed.map((project, index) => {
|
|
148
|
+
const result = grants[index].data;
|
|
149
|
+
return {
|
|
150
|
+
project,
|
|
151
|
+
grants: result.ok ? result.grants.filter((grant) => grant.principalType === principalType && grant.principalId === principalId && grant.scope !== "every-project") : [],
|
|
152
|
+
grantsError: result.ok ? null : result.error
|
|
153
|
+
};
|
|
154
|
+
});
|
|
195
155
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
156
|
+
/**
|
|
157
|
+
* A user's or service account's page: who it is, its menu, and its tabs,
|
|
158
|
+
* each a page of its own under this one. Access is a user's first tab; a
|
|
159
|
+
* service account's is how it signs in, while it shows one. A tab the
|
|
160
|
+
* deployment left out is not offered.
|
|
161
|
+
*/
|
|
162
|
+
function PrincipalLayout({ principalType, principalId }) {
|
|
163
|
+
const shell = useShell();
|
|
164
|
+
const mounted = useMounted();
|
|
165
|
+
const { capabilities } = shell;
|
|
166
|
+
const report = useReport(principalType, principalId);
|
|
199
167
|
const { status, dismiss } = useChangeStatus(directoryList.queryKey);
|
|
200
168
|
const change = status(memberRef(principalType, principalId));
|
|
201
169
|
const kind = KIND[principalType];
|
|
202
170
|
const people = principalType === "user";
|
|
203
|
-
const list = people ? "/users" : "/tokens";
|
|
204
171
|
const found = report?.ok === true ? report.report : null;
|
|
205
172
|
const removed = found?.status === "removed";
|
|
206
173
|
const entry = found !== null && !removed ? {
|
|
@@ -210,26 +177,55 @@ function PrincipalPage({ principalType, principalId }) {
|
|
|
210
177
|
isRootAdmin: found.isRootAdmin,
|
|
211
178
|
tampered: found.status === "tampered"
|
|
212
179
|
} : void 0;
|
|
213
|
-
if (report?.ok === true && found === null || report === null &&
|
|
180
|
+
if (report?.ok === true && found === null || report === null && managedProjects(shell.projects).length === 0) return /* @__PURE__ */ jsx(ClosedDoor, {
|
|
214
181
|
icon: people ? /* @__PURE__ */ jsx(Users, { size: 18 }) : /* @__PURE__ */ jsx(Key, { size: 18 }),
|
|
215
182
|
label: /* @__PURE__ */ jsx("span", {
|
|
216
183
|
className: "mono",
|
|
217
|
-
children: principalId
|
|
184
|
+
children: people ? principalId : `service:${principalId}`
|
|
218
185
|
}),
|
|
219
|
-
title: people ? "No such user for you" : "No such
|
|
186
|
+
title: people ? "No such user for you" : "No such service account for you",
|
|
220
187
|
actions: /* @__PURE__ */ jsxs(Link, {
|
|
221
188
|
className: "btn",
|
|
222
|
-
to:
|
|
223
|
-
children: ["All ", people ? "users" : "
|
|
189
|
+
to: people ? "/users" : "/service-accounts",
|
|
190
|
+
children: ["All ", people ? "users" : "service accounts"]
|
|
224
191
|
}),
|
|
225
192
|
children: report === null ? `A ${kind}'s page lists its access to the projects where you manage access, and you manage none.` : `No ${kind} by that name has ever been registered here.`
|
|
226
193
|
});
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
194
|
+
const access = /* @__PURE__ */ jsxs(Fragment$1, { children: [removed ? /* @__PURE__ */ jsx(Archive, { size: 15 }) : /* @__PURE__ */ jsx(Folder, { size: 15 }), removed ? "Offboarding" : "Access"] });
|
|
195
|
+
const activity = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Activity, { size: 15 }), "Activity"] });
|
|
196
|
+
const tabs = people ? [/* @__PURE__ */ jsx(Link, {
|
|
197
|
+
to: "/users/$user",
|
|
198
|
+
params: { user: principalId },
|
|
199
|
+
activeOptions: {
|
|
200
|
+
exact: true,
|
|
201
|
+
includeSearch: false
|
|
202
|
+
},
|
|
203
|
+
children: access
|
|
204
|
+
}, "access"), capabilities.canReadAudit && mounted("/users/$user/activity") && /* @__PURE__ */ jsx(Link, {
|
|
205
|
+
to: "/users/$user/activity",
|
|
206
|
+
params: { user: principalId },
|
|
207
|
+
children: activity
|
|
208
|
+
}, "activity")] : [
|
|
209
|
+
signInWays(shell, report) !== null && /* @__PURE__ */ jsxs(Link, {
|
|
210
|
+
to: "/service-accounts/$account",
|
|
211
|
+
params: { account: principalId },
|
|
212
|
+
activeOptions: {
|
|
213
|
+
exact: true,
|
|
214
|
+
includeSearch: false
|
|
215
|
+
},
|
|
216
|
+
children: [/* @__PURE__ */ jsx(Link$1, { size: 15 }), "Sign-in"]
|
|
217
|
+
}, "sign-in"),
|
|
218
|
+
mounted("/service-accounts/$account/access") && /* @__PURE__ */ jsx(Link, {
|
|
219
|
+
to: "/service-accounts/$account/access",
|
|
220
|
+
params: { account: principalId },
|
|
221
|
+
children: access
|
|
222
|
+
}, "access"),
|
|
223
|
+
capabilities.canReadAudit && mounted("/service-accounts/$account/activity") && /* @__PURE__ */ jsx(Link, {
|
|
224
|
+
to: "/service-accounts/$account/activity",
|
|
225
|
+
params: { account: principalId },
|
|
226
|
+
children: activity
|
|
227
|
+
}, "activity")
|
|
228
|
+
];
|
|
233
229
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
234
230
|
/* @__PURE__ */ jsx(PageHeader, {
|
|
235
231
|
lead: /* @__PURE__ */ jsx(PrincipalAvatar, {
|
|
@@ -237,19 +233,16 @@ function PrincipalPage({ principalType, principalId }) {
|
|
|
237
233
|
id: principalId,
|
|
238
234
|
size: "lg"
|
|
239
235
|
}),
|
|
240
|
-
title: principalId,
|
|
236
|
+
title: principalType === "service" ? `service:${principalId}` : principalId,
|
|
237
|
+
description: principalType === "service" ? "A service account: an identity for CI and other automation." : void 0,
|
|
241
238
|
meta: removed ? /* @__PURE__ */ jsx("span", {
|
|
242
239
|
className: "tag tag-red",
|
|
243
240
|
children: "Removed"
|
|
244
241
|
}) : entry?.principalType === "user" && /* @__PURE__ */ jsx(InstanceRole, { principal: entry }),
|
|
245
|
-
actions:
|
|
246
|
-
principalType,
|
|
247
|
-
principalId,
|
|
248
|
-
access: editable
|
|
249
|
-
}), entry !== void 0 && /* @__PURE__ */ jsx(PrincipalActions, {
|
|
242
|
+
actions: entry !== void 0 && /* @__PURE__ */ jsx(PrincipalActions, {
|
|
250
243
|
principal: entry,
|
|
251
244
|
trigger: "btn btn-icon"
|
|
252
|
-
})
|
|
245
|
+
})
|
|
253
246
|
}),
|
|
254
247
|
change.state === "failed" && /* @__PURE__ */ jsx("div", {
|
|
255
248
|
className: "report-notice",
|
|
@@ -265,12 +258,35 @@ function PrincipalPage({ principalType, principalId }) {
|
|
|
265
258
|
children: report.error
|
|
266
259
|
})
|
|
267
260
|
}),
|
|
261
|
+
/* @__PURE__ */ jsx(PageTabs, {
|
|
262
|
+
label: people ? "User sections" : "Service account sections",
|
|
263
|
+
children: tabs
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ jsx(Outlet, {})
|
|
266
|
+
] });
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* A user's or service account's Access tab: its grants on every project
|
|
270
|
+
* where you manage access, and on every project; once it is removed, what
|
|
271
|
+
* its offboarding did instead.
|
|
272
|
+
*/
|
|
273
|
+
function PrincipalAccess({ principalType, principalId }) {
|
|
274
|
+
const { instanceRole } = useShell();
|
|
275
|
+
const report = useReport(principalType, principalId);
|
|
276
|
+
const access = useProjectAccess(principalType, principalId);
|
|
277
|
+
const kind = KIND[principalType];
|
|
278
|
+
const people = principalType === "user";
|
|
279
|
+
const found = report?.ok === true ? report.report : null;
|
|
280
|
+
const removed = found?.status === "removed";
|
|
281
|
+
const rows = access.flatMap(({ project, grants }) => grants.map((grant) => ({
|
|
282
|
+
project,
|
|
283
|
+
grant
|
|
284
|
+
})));
|
|
285
|
+
const errors = access.filter((entry) => entry.grantsError !== null);
|
|
286
|
+
const editable = removed ? [] : access.filter(({ project, grantsError }) => project.archivedAt === null && grantsError === null);
|
|
287
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
268
288
|
removed && found !== null && /* @__PURE__ */ jsx(RemovedNotice, { report: found }),
|
|
269
289
|
!removed && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
270
|
-
/* @__PURE__ */ jsx("h2", {
|
|
271
|
-
className: "section-title",
|
|
272
|
-
children: "Project access"
|
|
273
|
-
}),
|
|
274
290
|
errors.map(({ project, grantsError }) => /* @__PURE__ */ jsx("div", {
|
|
275
291
|
style: { marginBottom: "0.75rem" },
|
|
276
292
|
children: /* @__PURE__ */ jsxs(Notice, {
|
|
@@ -307,23 +323,34 @@ function PrincipalPage({ principalType, principalId }) {
|
|
|
307
323
|
/* @__PURE__ */ jsx(Tile, { name: project.slug }),
|
|
308
324
|
/* @__PURE__ */ jsx(Link, {
|
|
309
325
|
className: "cell-link",
|
|
310
|
-
to: "/projects/$project",
|
|
326
|
+
to: people ? "/projects/$project/users" : "/projects/$project/service-accounts",
|
|
311
327
|
params: { project: project.slug },
|
|
312
|
-
search: { tab: people ? "users" : "tokens" },
|
|
313
328
|
children: project.name
|
|
314
329
|
}),
|
|
315
330
|
project.archivedAt !== null && /* @__PURE__ */ jsx("span", {
|
|
316
331
|
className: "tag tag-red",
|
|
317
|
-
children: "
|
|
332
|
+
children: "Archived"
|
|
318
333
|
})
|
|
319
334
|
]
|
|
320
335
|
})
|
|
321
336
|
}, grant.id))
|
|
322
337
|
})
|
|
323
338
|
}),
|
|
339
|
+
editable.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
340
|
+
className: "table-actions",
|
|
341
|
+
children: /* @__PURE__ */ jsx(EditAccess, {
|
|
342
|
+
principalType,
|
|
343
|
+
principalId,
|
|
344
|
+
access: editable
|
|
345
|
+
})
|
|
346
|
+
}),
|
|
324
347
|
instanceRole !== "root-admin" && /* @__PURE__ */ jsx("p", {
|
|
325
348
|
className: "hint section-foot",
|
|
326
349
|
children: "Only projects where you manage access are listed."
|
|
350
|
+
}),
|
|
351
|
+
/* @__PURE__ */ jsx(EveryProjectGrants, {
|
|
352
|
+
principalType,
|
|
353
|
+
principalId
|
|
327
354
|
})
|
|
328
355
|
] }),
|
|
329
356
|
found !== null && /* @__PURE__ */ jsx(PrincipalReportCards, { report: found })
|
|
@@ -437,15 +464,15 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
437
464
|
}),
|
|
438
465
|
/* @__PURE__ */ jsx("option", {
|
|
439
466
|
value: "owner",
|
|
440
|
-
children:
|
|
467
|
+
children: ROLES.owner.name
|
|
441
468
|
}),
|
|
442
|
-
/* @__PURE__ */
|
|
469
|
+
/* @__PURE__ */ jsxs("option", {
|
|
443
470
|
value: "viewer",
|
|
444
|
-
children: "
|
|
471
|
+
children: [ROLES.viewer.name, ": all"]
|
|
445
472
|
}),
|
|
446
|
-
/* @__PURE__ */
|
|
473
|
+
/* @__PURE__ */ jsxs("option", {
|
|
447
474
|
value: "developer",
|
|
448
|
-
children: "
|
|
475
|
+
children: [ROLES.developer.name, ": all"]
|
|
449
476
|
}),
|
|
450
477
|
environments.length > 0 && /* @__PURE__ */ jsx("option", {
|
|
451
478
|
value: "env",
|
|
@@ -492,11 +519,11 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
492
519
|
}),
|
|
493
520
|
/* @__PURE__ */ jsx("option", {
|
|
494
521
|
value: "viewer",
|
|
495
|
-
children:
|
|
522
|
+
children: ROLES.viewer.name
|
|
496
523
|
}),
|
|
497
524
|
/* @__PURE__ */ jsx("option", {
|
|
498
525
|
value: "developer",
|
|
499
|
-
children:
|
|
526
|
+
children: ROLES.developer.name
|
|
500
527
|
})
|
|
501
528
|
]
|
|
502
529
|
}),
|
|
@@ -540,39 +567,6 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
540
567
|
})
|
|
541
568
|
})] });
|
|
542
569
|
}
|
|
543
|
-
/**
|
|
544
|
-
* When one grant ends, as a date: access lasts through that day, UTC. Blank
|
|
545
|
-
* reads "Never" where the browser lets the empty field be restyled.
|
|
546
|
-
*/
|
|
547
|
-
function ExpiryField({ label, expiresAt, onChange }) {
|
|
548
|
-
const date = dateFromExpiry(expiresAt);
|
|
549
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
550
|
-
className: `expiry${date === "" ? " is-never" : ""}`,
|
|
551
|
-
children: [
|
|
552
|
-
/* @__PURE__ */ jsx("input", {
|
|
553
|
-
className: "input select-sm",
|
|
554
|
-
type: "date",
|
|
555
|
-
"aria-label": label,
|
|
556
|
-
min: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
557
|
-
value: date,
|
|
558
|
-
onChange: (event) => onChange(expiryFromDate(event.target.value))
|
|
559
|
-
}),
|
|
560
|
-
/* @__PURE__ */ jsx("span", {
|
|
561
|
-
className: "expiry-never",
|
|
562
|
-
"aria-hidden": "true",
|
|
563
|
-
children: "Never"
|
|
564
|
-
}),
|
|
565
|
-
/* @__PURE__ */ jsx("button", {
|
|
566
|
-
className: "btn btn-quiet btn-sm btn-icon",
|
|
567
|
-
type: "button",
|
|
568
|
-
"aria-label": `${label}: never`,
|
|
569
|
-
title: "Never expires",
|
|
570
|
-
onClick: () => onChange(null),
|
|
571
|
-
children: /* @__PURE__ */ jsx(X, { size: 12 })
|
|
572
|
-
})
|
|
573
|
-
]
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
570
|
function AccessChangeTag({ change }) {
|
|
577
571
|
const until = (expiresAt) => expiresAt === null ? "" : ` until ${dateFromExpiry(expiresAt)}`;
|
|
578
572
|
switch (change.kind) {
|
|
@@ -623,6 +617,6 @@ function AccessChangeTag({ change }) {
|
|
|
623
617
|
}
|
|
624
618
|
}
|
|
625
619
|
//#endregion
|
|
626
|
-
export {
|
|
620
|
+
export { PrincipalLayout as n, ActionsLog as r, PrincipalAccess as t };
|
|
627
621
|
|
|
628
|
-
//# sourceMappingURL=principal-page-
|
|
622
|
+
//# sourceMappingURL=principal-page-DhjO76GH.js.map
|