@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","names":[],"sources":["../../src/pages/settings.tsx"],"sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query';\nimport { Link } from '@tanstack/react-router';\nimport { useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useShell } from '../lib/use-shell';\nimport { Card, Fact, PageHeader } from '../components/page';\n\n/** The instance's settings. Your own are under Account, at the sidebar's foot. */\n\
|
|
1
|
+
{"version":3,"file":"settings.js","names":[],"sources":["../../src/pages/settings.tsx"],"sourcesContent":["import type { RouteOutput } from '@coffre/client';\nimport { useSuspenseQuery } from '@tanstack/react-query';\nimport { Link } from '@tanstack/react-router';\nimport { useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useShell } from '../lib/use-shell';\nimport { Card, Fact, PageHeader } from '../components/page';\nimport { Toggletip } from '../components/ui';\nimport { Info } from '../components/icons';\n\n/** The instance's settings. Your own are under Account, at the sidebar's foot. */\n\nexport function SettingsPage() {\n const { auth, capabilities } = useShell();\n const client = useCoffre();\n const { data: directory } = useSuspenseQuery(queries.directory(client, capabilities.canManageGrants));\n const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.canManageGrants));\n const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];\n\n const principals = directory?.ok === true ? directory.principals : null;\n const rootAdmins = principals?.filter((entry) => entry.isRootAdmin) ?? [];\n const users = principals?.filter((entry) => entry.principalType === 'user').length ?? 0;\n const tokens = principals?.filter((entry) => entry.principalType === 'service').length ?? 0;\n\n return (\n <>\n <PageHeader title=\"Settings\" />\n\n <Card\n labelledBy=\"instance\"\n title=\"Instance\"\n description=\"Set in the deployment's configuration, so shown here rather than edited.\"\n >\n <dl className=\"facts\">\n <Fact label=\"Sign-in\">\n <span>\n {auth?.signin ? providers.join(', ') : 'Cloudflare Access'}\n <Toggletip\n label={\n auth?.signin\n ? 'coffre’s own sign-in. Only invited members get in.'\n : 'coffre has no sign-in of its own: every request carries an Access assertion, verified at the origin.'\n }\n >\n <button type=\"button\" className=\"fact-tip\" aria-label=\"About sign-in\">\n <Info size={14} />\n </button>\n </Toggletip>\n </span>\n </Fact>\n {principals !== null && (\n <>\n <Fact label=\"Root admins\">\n <span className=\"fact-list\">\n {rootAdmins.map((admin) => (\n <span key={admin.principalId} className=\"mono\">\n {admin.principalId}\n </span>\n ))}\n </span>\n </Fact>\n <Fact label=\"Directory\">\n <span>\n <Link to=\"/users\">\n {users} user{users === 1 ? '' : 's'}\n </Link>\n {' · '}\n <Link to=\"/service-accounts\">\n {tokens} service account{tokens === 1 ? '' : 's'}\n </Link>\n </span>\n </Fact>\n </>\n )}\n </dl>\n </Card>\n\n {keys?.ok === true && <Keys keys={keys} />}\n </>\n );\n}\n\n/**\n * What the keys you keep are checked against: no secret, so shown. The keys\n * themselves are checked by `coffre verify keys`, on your machine: a vault\n * key typed into a web page would be within reach of everything running in it.\n */\nfunction Keys({ keys }: { keys: RouteOutput<'GET /audit/keys'> }) {\n const { current, checks } = keys.vault;\n const replaced = new Set(checks.map((check) => check.vaultId).filter((id) => id !== current.vaultId)).size;\n return (\n <Card\n labelledBy=\"keys\"\n title=\"Keys\"\n description={\n <>\n What the vault key and app key you keep are checked against. Check the keys themselves\n with <code>coffre verify keys</code>, which reads them on your machine and sends neither.\n </>\n }\n >\n <dl className=\"facts\">\n <Fact label=\"Vault ID\">\n <span className=\"mono\">{current.vaultId}</span>\n </Fact>\n <Fact label=\"Vault key\">\n <span>\n Held by <span className=\"mono\">{current.provider}</span>\n {replaced > 0 && `; ${replaced} earlier vault key${replaced === 1 ? '' : 's'} still checkable`}\n </span>\n </Fact>\n <Fact label=\"App key\">\n <span className=\"mono\">{keys.app.keyId}</span>\n </Fact>\n </dl>\n </Card>\n );\n}\n\n"],"mappings":"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"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as useShell } from "../chunks/use-shell-jxd7Tzd-.js";
|
|
1
|
+
import { n as ClosedDoor, tt as User } from "../chunks/page-DvsgZ2Hd.js";
|
|
2
|
+
import { t as useShell } from "../chunks/use-shell-rNKfGjdj.js";
|
|
4
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
//#region src/pages/unregistered.tsx
|
|
6
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unregistered.js","names":[],"sources":["../../src/pages/unregistered.tsx"],"sourcesContent":["import { useShell } from '../lib/use-shell';\n\nimport { ClosedDoor } from '../components/page';\nimport { User } from '../components/icons';\n\n/**\n * Cloudflare Access has authenticated this person, but Coffre has not\n * registered them as a member. Keep this deliberately actionless: registration is\n * an owner decision, not a self-service privilege escalation path.\n */\nexport function UnregisteredPage() {\n const { principal, accessTampered } = useShell();\n\n if (accessTampered) {\n return (\n <ClosedDoor icon={<User size={18} />} label=\"Integrity check failed\" title=\"Your access is on hold\">\n <p>\n Your access record\n {principal !== null && (\n <>\n {' '}\n (<span className=\"mono\">{principal.id}</span>)\n </>\n )}{' '}\n was changed outside coffre, so its vault refuses it until someone looks. Nothing you\n held is available meanwhile.\n </p>\n <p>Ask a coffre owner to remove you under Users and add you again, which starts your access over.</p>\n </ClosedDoor>\n );\n }\n\n return (\n <ClosedDoor\n icon={<User size={18} />}\n label=\"Registration required\"\n title=\"You are not a member yet\"\n >\n <p>\n Cloudflare Access knows who you are\n {principal !== null && (\n <>\n {' '}\n (<span className=\"mono\">{principal.id}</span>)\n </>\n )}\n , but this coffre instance has not registered that identity. Until it does, no\n projects, secrets, audit entries or API operations are available to you.\n </p>\n <p>\n Ask a coffre owner or root admin to add your Access email under Users.\n </p>\n </ClosedDoor>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"unregistered.js","names":[],"sources":["../../src/pages/unregistered.tsx"],"sourcesContent":["import { useShell } from '../lib/use-shell';\n\nimport { ClosedDoor } from '../components/page';\nimport { User } from '../components/icons';\n\n/**\n * Cloudflare Access has authenticated this person, but Coffre has not\n * registered them as a member. Keep this deliberately actionless: registration is\n * an owner decision, not a self-service privilege escalation path.\n */\nexport function UnregisteredPage() {\n const { principal, accessTampered } = useShell();\n\n if (accessTampered) {\n return (\n <ClosedDoor icon={<User size={18} />} label=\"Integrity check failed\" title=\"Your access is on hold\">\n <p>\n Your access record\n {principal !== null && (\n <>\n {' '}\n (<span className=\"mono\">{principal.id}</span>)\n </>\n )}{' '}\n was changed outside coffre, so its vault refuses it until someone looks. Nothing you\n held is available meanwhile.\n </p>\n <p>Ask a coffre owner to remove you under Users and add you again, which starts your access over.</p>\n </ClosedDoor>\n );\n }\n\n return (\n <ClosedDoor\n icon={<User size={18} />}\n label=\"Registration required\"\n title=\"You are not a member yet\"\n >\n <p>\n Cloudflare Access knows who you are\n {principal !== null && (\n <>\n {' '}\n (<span className=\"mono\">{principal.id}</span>)\n </>\n )}\n , but this coffre instance has not registered that identity. Until it does, no\n projects, secrets, audit entries or API operations are available to you.\n </p>\n <p>\n Ask a coffre owner or root admin to add your Access email under Users.\n </p>\n </ClosedDoor>\n );\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,mBAAmB;CACjC,MAAM,EAAE,WAAW,mBAAmB,SAAS;CAE/C,IAAI,gBACF,OACE,qBAAC,YAAD;EAAY,MAAM,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EAAG,OAAM;EAAyB,OAAM;YAA3E,CACE,qBAAC,KAAD,EAAA,UAAA;GAAG;GAEA,cAAc,QACb,qBAAA,UAAA,EAAA,UAAA;IACG;IAAI;IACJ,oBAAC,QAAD;KAAM,WAAU;eAAQ,UAAU;IAAS,CAAA;IAAC;GAC7C,EAAA,CAAA;GACD;GAAI;EAGN,EAAA,CAAA,GACH,oBAAC,KAAD,EAAA,UAAG,iGAAiG,CAAA,CAC1F;;CAIhB,OACE,qBAAC,YAAD;EACE,MAAM,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EACvB,OAAM;EACN,OAAM;YAHR,CAKE,qBAAC,KAAD,EAAA,UAAA;GAAG;GAEA,cAAc,QACb,qBAAA,UAAA,EAAA,UAAA;IACG;IAAI;IACJ,oBAAC,QAAD;KAAM,WAAU;eAAQ,UAAU;IAAS,CAAA;IAAC;GAC7C,EAAA,CAAA;GACF;EAGD,EAAA,CAAA,GACH,oBAAC,KAAD,EAAA,UAAG,yEAEA,CAAA,CACO;;AAEhB"}
|
package/dist/pages/user.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
//#region src/pages/user.d.ts
|
|
2
|
-
|
|
2
|
+
/** A user's page, around its tabs. */
|
|
3
|
+
export declare function UserLayout(): import("react").JSX.Element;
|
|
4
|
+
/** Their first tab: their access, or once removed, their offboarding. */
|
|
5
|
+
export declare function UserAccessPage(): import("react").JSX.Element;
|
|
6
|
+
/** Everything they did, from the audit log. */
|
|
7
|
+
export declare function UserActivityPage(): import("react").JSX.Element;
|
|
3
8
|
//#endregion
|
package/dist/pages/user.js
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
+
import { s as memberRef } from "../chunks/page-DvsgZ2Hd.js";
|
|
1
2
|
import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
|
|
2
|
-
import { t as
|
|
3
|
+
import { n as PrincipalLayout, r as ActionsLog, t as PrincipalAccess } from "../chunks/principal-page-DhjO76GH.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
//#region src/pages/user.tsx
|
|
5
6
|
var Route = pageRoute();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return /* @__PURE__ */ jsx(
|
|
7
|
+
/** A user's page, around its tabs. */
|
|
8
|
+
function UserLayout() {
|
|
9
|
+
return /* @__PURE__ */ jsx(PrincipalLayout, {
|
|
9
10
|
principalType: "user",
|
|
10
|
-
principalId: user
|
|
11
|
+
principalId: Route.useParams().user
|
|
11
12
|
});
|
|
12
13
|
}
|
|
14
|
+
/** Their first tab: their access, or once removed, their offboarding. */
|
|
15
|
+
function UserAccessPage() {
|
|
16
|
+
return /* @__PURE__ */ jsx(PrincipalAccess, {
|
|
17
|
+
principalType: "user",
|
|
18
|
+
principalId: Route.useParams().user
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** Everything they did, from the audit log. */
|
|
22
|
+
function UserActivityPage() {
|
|
23
|
+
return /* @__PURE__ */ jsx(ActionsLog, { member: memberRef("user", Route.useParams().user) });
|
|
24
|
+
}
|
|
13
25
|
//#endregion
|
|
14
|
-
export {
|
|
26
|
+
export { UserAccessPage, UserActivityPage, UserLayout };
|
|
15
27
|
|
|
16
28
|
//# sourceMappingURL=user.js.map
|
package/dist/pages/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":[],"sources":["../../src/pages/user.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"user.js","names":[],"sources":["../../src/pages/user.tsx"],"sourcesContent":["import { ActionsLog } from '../components/actions-log';\nimport { PrincipalAccess, PrincipalLayout } from '../components/principal-page';\nimport { memberRef } from '../lib/coffre';\nimport { pageRoute } from '../lib/page-route';\nimport type { user } from '../options';\n\nconst Route = pageRoute<typeof user>();\n\n/** A user's page, around its tabs. */\nexport function UserLayout() {\n return <PrincipalLayout principalType=\"user\" principalId={Route.useParams().user} />;\n}\n\n/** Their first tab: their access, or once removed, their offboarding. */\nexport function UserAccessPage() {\n return <PrincipalAccess principalType=\"user\" principalId={Route.useParams().user} />;\n}\n\n/** Everything they did, from the audit log. */\nexport function UserActivityPage() {\n return <ActionsLog member={memberRef('user', Route.useParams().user)} />;\n}\n"],"mappings":";;;;;AAMA,IAAM,QAAQ,UAAuB;;AAGrC,SAAgB,aAAa;CAC3B,OAAO,oBAAC,iBAAD;EAAiB,eAAc;EAAO,aAAa,MAAM,UAAU,CAAC,CAAC;CAAO,CAAA;AACrF;;AAGA,SAAgB,iBAAiB;CAC/B,OAAO,oBAAC,iBAAD;EAAiB,eAAc;EAAO,aAAa,MAAM,UAAU,CAAC,CAAC;CAAO,CAAA;AACrF;;AAGA,SAAgB,mBAAmB;CACjC,OAAO,oBAAC,YAAD,EAAY,QAAQ,UAAU,QAAQ,MAAM,UAAU,CAAC,CAAC,IAAI,EAAI,CAAA;AACzE"}
|
package/dist/pages/users.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as
|
|
6
|
-
import { n as RemovedList } from "../chunks/offboarding-C6l30DZR.js";
|
|
1
|
+
import { i as PageHeader, n as ClosedDoor, rt as Users, u as useCoffre } from "../chunks/page-DvsgZ2Hd.js";
|
|
2
|
+
import { p as queries } from "../chunks/queries-DVR_i3rA.js";
|
|
3
|
+
import { t as useShell } from "../chunks/use-shell-rNKfGjdj.js";
|
|
4
|
+
import { t as DirectoryTable } from "../chunks/directory-zr3ek7Mc.js";
|
|
5
|
+
import { n as RemovedList } from "../chunks/offboarding-CE6d7um1.js";
|
|
7
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
9
8
|
//#region src/pages/users.tsx
|
|
@@ -18,10 +17,7 @@ function UsersPage() {
|
|
|
18
17
|
});
|
|
19
18
|
const users = result.principals.filter((principal) => principal.principalType === "user");
|
|
20
19
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
21
|
-
/* @__PURE__ */ jsx(PageHeader, {
|
|
22
|
-
title: "Users",
|
|
23
|
-
actions: /* @__PURE__ */ jsx(AddPrincipal, { principalType: "user" })
|
|
24
|
-
}),
|
|
20
|
+
/* @__PURE__ */ jsx(PageHeader, { title: "Users" }),
|
|
25
21
|
/* @__PURE__ */ jsx(DirectoryTable, {
|
|
26
22
|
principalType: "user",
|
|
27
23
|
principals: users,
|
package/dist/pages/users.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.js","names":[],"sources":["../../src/pages/users.tsx"],"sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query';\n\nimport {
|
|
1
|
+
{"version":3,"file":"users.js","names":[],"sources":["../../src/pages/users.tsx"],"sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query';\n\nimport { DirectoryTable } from '../components/directory';\nimport { useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useShell } from '../lib/use-shell';\nimport { ClosedDoor, PageHeader } from '../components/page';\nimport { RemovedList } from '../components/offboarding';\nimport { Users } from '../components/icons';\n\nexport function UsersPage() {\n const { capabilities } = useShell();\n const { data: result } = useSuspenseQuery(queries.directory(useCoffre(), capabilities.canManageGrants));\n\n if (!result.ok) {\n return (\n <ClosedDoor icon={<Users size={18} />} label=\"Users\" title=\"Users are closed to you\">\n {result.error}\n </ClosedDoor>\n );\n }\n\n const users = result.principals.filter((principal) => principal.principalType === 'user');\n\n return (\n <>\n <PageHeader title=\"Users\" />\n <DirectoryTable\n principalType=\"user\"\n principals={users}\n hasRemoved={result.removed.some((principal) => principal.principalType === 'user')}\n />\n <RemovedList principalType=\"user\" removed={result.removed} />\n </>\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,YAAY;CAC1B,MAAM,EAAE,iBAAiB,SAAS;CAClC,MAAM,EAAE,MAAM,WAAW,iBAAiB,QAAQ,UAAU,UAAU,GAAG,aAAa,eAAe,CAAC;CAEtG,IAAI,CAAC,OAAO,IACV,OACE,oBAAC,YAAD;EAAY,MAAM,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA;EAAG,OAAM;EAAQ,OAAM;YACxD,OAAO;CACE,CAAA;CAIhB,MAAM,QAAQ,OAAO,WAAW,QAAQ,cAAc,UAAU,kBAAkB,MAAM;CAExF,OACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,YAAD,EAAY,OAAM,QAAS,CAAA;EAC3B,oBAAC,gBAAD;GACE,eAAc;GACd,YAAY;GACZ,YAAY,OAAO,QAAQ,MAAM,cAAc,UAAU,kBAAkB,MAAM;EAClF,CAAA;EACD,oBAAC,aAAD;GAAa,eAAc;GAAO,SAAS,OAAO;EAAU,CAAA;CAC5D,EAAA,CAAA;AAEN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "coffre's pages, for a deployment's own TanStack Start app: its router, and a Vite plugin for its build.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@tanstack/router-core": "1.171.15",
|
|
45
45
|
"lucide-react": "1.47.0",
|
|
46
46
|
"sonner": "2.0.7",
|
|
47
|
-
"@coffre/client": "0.
|
|
48
|
-
"@coffre/core": "0.
|
|
47
|
+
"@coffre/client": "0.4.0",
|
|
48
|
+
"@coffre/core": "0.4.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@tanstack/react-query": "5.103.1",
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
|
+
import { uiResult, useCoffre } from '../lib/coffre';
|
|
3
|
+
import { keys } from '../lib/queries';
|
|
4
|
+
import { describe, lines } from '../lib/audit-sentences';
|
|
5
|
+
import { Sentence } from './audit-sentence';
|
|
6
|
+
import { EmptyState, Notice, Spinner, Timestamp } from './ui';
|
|
7
|
+
import { Activity, Clock, ShieldCheck, SlashCircle } from './icons';
|
|
8
|
+
|
|
9
|
+
const PAGE_SIZE = 50;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Everything one member did, newest first, from the audit log: the same
|
|
13
|
+
* entries `coffre audit --actor` lists, said as the audit page says them.
|
|
14
|
+
* Older pages come on request.
|
|
15
|
+
*/
|
|
16
|
+
export function ActionsLog({ member }: { member: string }) {
|
|
17
|
+
const client = useCoffre();
|
|
18
|
+
const log = useInfiniteQuery({
|
|
19
|
+
queryKey: [...keys.audit, 'actor', member],
|
|
20
|
+
staleTime: 0,
|
|
21
|
+
initialPageParam: undefined as number | undefined,
|
|
22
|
+
queryFn: ({ pageParam }) =>
|
|
23
|
+
uiResult(() => client.audit.list({ actor: member, limit: PAGE_SIZE, before: pageParam })),
|
|
24
|
+
getNextPageParam: (page) =>
|
|
25
|
+
page.ok && page.entries.length === PAGE_SIZE ? page.entries.at(-1)!.seq : undefined,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (log.isPending) {
|
|
29
|
+
return (
|
|
30
|
+
<p className="hint">
|
|
31
|
+
<Spinner size={13} /> Reading the log…
|
|
32
|
+
</p>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const failed = log.data?.pages.find((page) => !page.ok);
|
|
36
|
+
if (failed !== undefined && !failed.ok) return <Notice tone="bad">{failed.error}</Notice>;
|
|
37
|
+
const entries = (log.data?.pages ?? []).flatMap((page) => (page.ok ? page.entries : []));
|
|
38
|
+
const shown = lines(entries);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
<section className="card" aria-label="Actions log">
|
|
43
|
+
{shown.length === 0 ? (
|
|
44
|
+
<EmptyState title="Nothing done yet">Every read, write and change they make is listed here.</EmptyState>
|
|
45
|
+
) : (
|
|
46
|
+
<div className="dt-wrap">
|
|
47
|
+
<table className="dt actions-log stacks stacks-inline">
|
|
48
|
+
<thead>
|
|
49
|
+
<tr>
|
|
50
|
+
<th className="col-shrink">
|
|
51
|
+
<span className="th">
|
|
52
|
+
<Clock size={14} />
|
|
53
|
+
When
|
|
54
|
+
</span>
|
|
55
|
+
</th>
|
|
56
|
+
<th>
|
|
57
|
+
<span className="th">
|
|
58
|
+
<Activity size={14} />
|
|
59
|
+
Action
|
|
60
|
+
</span>
|
|
61
|
+
</th>
|
|
62
|
+
<th className="col-shrink">
|
|
63
|
+
<span className="th">
|
|
64
|
+
<ShieldCheck size={14} />
|
|
65
|
+
Outcome
|
|
66
|
+
</span>
|
|
67
|
+
</th>
|
|
68
|
+
</tr>
|
|
69
|
+
</thead>
|
|
70
|
+
<tbody>
|
|
71
|
+
{shown.map((batch) => {
|
|
72
|
+
const lead = batch[0]!;
|
|
73
|
+
const sentence = describe(batch);
|
|
74
|
+
return (
|
|
75
|
+
<tr key={lead.seq} className={sentence.refused ? 'is-denied' : undefined}>
|
|
76
|
+
<td className="nowrap cell-muted" title={lead.occurredAt}>
|
|
77
|
+
<Timestamp iso={lead.occurredAt} display="relative" />
|
|
78
|
+
</td>
|
|
79
|
+
<td className="cell-sentence">
|
|
80
|
+
<span className="sentence">
|
|
81
|
+
<Sentence parts={sentence.parts} />
|
|
82
|
+
</span>
|
|
83
|
+
</td>
|
|
84
|
+
<td className="nowrap" data-label="Outcome">
|
|
85
|
+
{sentence.refused ? (
|
|
86
|
+
<span className="decided decided-refused">
|
|
87
|
+
<SlashCircle size={13} />
|
|
88
|
+
Refused
|
|
89
|
+
</span>
|
|
90
|
+
) : (
|
|
91
|
+
<span className="cell-muted">Allowed</span>
|
|
92
|
+
)}
|
|
93
|
+
</td>
|
|
94
|
+
</tr>
|
|
95
|
+
);
|
|
96
|
+
})}
|
|
97
|
+
</tbody>
|
|
98
|
+
</table>
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</section>
|
|
102
|
+
{log.hasNextPage && (
|
|
103
|
+
<div className="table-actions">
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
className="btn"
|
|
107
|
+
disabled={log.isFetchingNextPage}
|
|
108
|
+
onClick={() => void log.fetchNextPage()}
|
|
109
|
+
>
|
|
110
|
+
{log.isFetchingNextPage && <Spinner />}
|
|
111
|
+
Show older
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
</>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { serviceName, shownMember } from '@coffre/client';
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { Link } from '@tanstack/react-router';
|
|
4
|
+
import type { Part } from '../lib/audit-sentences';
|
|
5
|
+
import { breakAfterUnderscores } from './ui';
|
|
6
|
+
|
|
7
|
+
/** A sentence, its people and places links to their pages. */
|
|
8
|
+
export function Sentence({ parts }: { parts: Part[] }) {
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
{parts.map((part, index) => (
|
|
12
|
+
<Fragment key={index}>
|
|
13
|
+
{typeof part === 'string' ? (
|
|
14
|
+
part
|
|
15
|
+
) : 'place' in part ? (
|
|
16
|
+
<PlaceLink path={part.place} />
|
|
17
|
+
) : (
|
|
18
|
+
<MemberLink member={part.member} />
|
|
19
|
+
)}
|
|
20
|
+
</Fragment>
|
|
21
|
+
))}
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function PlaceLink({ path }: { path: string }) {
|
|
27
|
+
const [project, environment] = path.split('/') as [string, string | undefined];
|
|
28
|
+
const text = <span className="mono">{breakAfterUnderscores(path)}</span>;
|
|
29
|
+
return environment === undefined ? (
|
|
30
|
+
<Link to="/projects/$project" params={{ project }}>
|
|
31
|
+
{text}
|
|
32
|
+
</Link>
|
|
33
|
+
) : (
|
|
34
|
+
<Link to="/projects/$project/$environment" params={{ project, environment }}>
|
|
35
|
+
{text}
|
|
36
|
+
</Link>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A member from the log, which keeps `token:<name>`, shown as people read it: `service:<name>`, to its page. */
|
|
41
|
+
function MemberLink({ member }: { member: string }) {
|
|
42
|
+
return member.startsWith('token:') ? (
|
|
43
|
+
<Link to="/service-accounts/$account" params={{ account: serviceName(member) }}>
|
|
44
|
+
{shownMember(member)}
|
|
45
|
+
</Link>
|
|
46
|
+
) : (
|
|
47
|
+
<Link to="/users/$user" params={{ user: memberName(member) }}>
|
|
48
|
+
{memberName(member)}
|
|
49
|
+
</Link>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function memberName(member: string): string {
|
|
54
|
+
return member.startsWith('user:') ? member.slice('user:'.length) : shownMember(member);
|
|
55
|
+
}
|
|
@@ -145,11 +145,11 @@ export function CommandPalette({
|
|
|
145
145
|
run: closing(() => navigate({ to: '/users' })),
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
|
-
value: '
|
|
148
|
+
value: 'service accounts tokens machines ci oidc directory',
|
|
149
149
|
icon: <Key size={15} />,
|
|
150
|
-
label: '
|
|
151
|
-
path: '/
|
|
152
|
-
run: closing(() => navigate({ to: '/
|
|
150
|
+
label: 'Service accounts',
|
|
151
|
+
path: '/service-accounts',
|
|
152
|
+
run: closing(() => navigate({ to: '/service-accounts' })),
|
|
153
153
|
},
|
|
154
154
|
],
|
|
155
155
|
audit: [
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { shownMember, type Deletion } from '@coffre/client';
|
|
4
|
+
|
|
5
|
+
import { useCoffre } from '../lib/coffre';
|
|
6
|
+
import { affects, queries } from '../lib/queries';
|
|
7
|
+
import { useAction } from '../lib/use-action';
|
|
8
|
+
import { Trash } from './icons';
|
|
9
|
+
import { ErrorLine, Modal, Notice, Spinner } from './ui';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Deleting an archived project or environment for good, `market` or
|
|
13
|
+
* `market/prod`. The dialog first asks the server what the deletion would
|
|
14
|
+
* take, then needs the place's path typed out before it deletes: nothing
|
|
15
|
+
* brings it back, so the one click a slip can make is never enough.
|
|
16
|
+
*/
|
|
17
|
+
export function DeletePlaceDialog({
|
|
18
|
+
path,
|
|
19
|
+
open,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
onDeleted,
|
|
22
|
+
}: {
|
|
23
|
+
path: string;
|
|
24
|
+
open: boolean;
|
|
25
|
+
onOpenChange: (open: boolean) => void;
|
|
26
|
+
onDeleted: (deletion: Deletion) => unknown;
|
|
27
|
+
}) {
|
|
28
|
+
const coffre = useCoffre();
|
|
29
|
+
const plan = useQuery({ ...queries.deletion(coffre, path), enabled: open });
|
|
30
|
+
const [typed, setTyped] = useState('');
|
|
31
|
+
const { pending, error, setError, run } = useAction();
|
|
32
|
+
const what = path.includes('/') ? 'environment' : 'project';
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!open) return;
|
|
36
|
+
setTyped('');
|
|
37
|
+
setError(null);
|
|
38
|
+
}, [open, setError]);
|
|
39
|
+
|
|
40
|
+
const deletion = plan.data?.ok === true ? plan.data.deletion : null;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Modal
|
|
44
|
+
open={open}
|
|
45
|
+
onOpenChange={onOpenChange}
|
|
46
|
+
title={
|
|
47
|
+
<>
|
|
48
|
+
Delete <span className="mono">{path}</span> for good?
|
|
49
|
+
</>
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
<div className="dialog-body">
|
|
53
|
+
{plan.data === undefined ? (
|
|
54
|
+
<Spinner />
|
|
55
|
+
) : plan.data.ok ? (
|
|
56
|
+
<DeletionSummary deletion={plan.data.deletion} what={what} />
|
|
57
|
+
) : (
|
|
58
|
+
<ErrorLine error={plan.data.error} />
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
<div className="dialog-body">
|
|
62
|
+
<Notice tone="bad">
|
|
63
|
+
Nothing brings it back. Backups of the database taken before now still hold its
|
|
64
|
+
encrypted values; only they, with the vault key, could restore them.
|
|
65
|
+
</Notice>
|
|
66
|
+
</div>
|
|
67
|
+
<form
|
|
68
|
+
className="form"
|
|
69
|
+
onSubmit={(event) => {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
if (typed !== path || deletion === null) return;
|
|
72
|
+
run(
|
|
73
|
+
() => (what === 'project' ? coffre.projects.delete(path) : coffre.environments.delete(path)),
|
|
74
|
+
{
|
|
75
|
+
affects: affects.places(),
|
|
76
|
+
onSuccess: (result) => {
|
|
77
|
+
onOpenChange(false);
|
|
78
|
+
return onDeleted(result.deletion);
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<label className="field">
|
|
85
|
+
<span className="label">
|
|
86
|
+
Type <span className="mono">{path}</span> to confirm
|
|
87
|
+
</span>
|
|
88
|
+
<input
|
|
89
|
+
className="input input-mono"
|
|
90
|
+
autoFocus
|
|
91
|
+
spellCheck={false}
|
|
92
|
+
autoComplete="off"
|
|
93
|
+
value={typed}
|
|
94
|
+
onChange={(event) => setTyped(event.target.value)}
|
|
95
|
+
/>
|
|
96
|
+
</label>
|
|
97
|
+
<ErrorLine error={error} />
|
|
98
|
+
<div className="dialog-actions">
|
|
99
|
+
<button className="btn" type="button" onClick={() => onOpenChange(false)}>
|
|
100
|
+
Cancel
|
|
101
|
+
</button>
|
|
102
|
+
<button
|
|
103
|
+
className="btn btn-danger"
|
|
104
|
+
type="submit"
|
|
105
|
+
disabled={typed !== path || deletion === null || pending}
|
|
106
|
+
>
|
|
107
|
+
{pending ? <Spinner /> : <Trash size={14} />}
|
|
108
|
+
Delete {what}
|
|
109
|
+
</button>
|
|
110
|
+
</div>
|
|
111
|
+
</form>
|
|
112
|
+
</Modal>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** What the deletion takes and what it keeps, in the server's numbers. */
|
|
117
|
+
function DeletionSummary({ deletion, what }: { deletion: Deletion; what: 'project' | 'environment' }) {
|
|
118
|
+
const count = (n: number, one: string) => `${n} ${one}${n === 1 ? '' : 's'}`;
|
|
119
|
+
const environments = what === 'project' && deletion.environments.length > 0 ? (
|
|
120
|
+
<>
|
|
121
|
+
{' '}
|
|
122
|
+
in <span className="mono">{deletion.environments.join(', ')}</span>
|
|
123
|
+
</>
|
|
124
|
+
) : null;
|
|
125
|
+
return (
|
|
126
|
+
<ul className="deletion-summary">
|
|
127
|
+
<li>
|
|
128
|
+
<strong>Erased:</strong> the values of {count(deletion.versions, 'secret version')}
|
|
129
|
+
{environments}, ciphertext and wrapped key both.
|
|
130
|
+
</li>
|
|
131
|
+
<li>
|
|
132
|
+
<strong>Revoked:</strong> {count(deletion.grants.length, 'grant')}
|
|
133
|
+
{deletion.grants.length > 0 && (
|
|
134
|
+
<>
|
|
135
|
+
{', '}
|
|
136
|
+
{deletion.grants.map((grant, index) => (
|
|
137
|
+
<span key={`${grant.member} ${grant.place}`}>
|
|
138
|
+
{index > 0 && ', '}
|
|
139
|
+
<span className="mono">{shownMember(grant.member)}</span> on{' '}
|
|
140
|
+
<span className="mono">{grant.place}</span>
|
|
141
|
+
</span>
|
|
142
|
+
))}
|
|
143
|
+
</>
|
|
144
|
+
)}
|
|
145
|
+
.
|
|
146
|
+
</li>
|
|
147
|
+
{deletion.references.length > 0 && (
|
|
148
|
+
<li>
|
|
149
|
+
<strong>Ended:</strong> {count(deletion.references.length, 'reference')}, which read it from
|
|
150
|
+
elsewhere or which it reads:{' '}
|
|
151
|
+
{deletion.references.map((reference, index) => (
|
|
152
|
+
<span key={`${reference.holder} ${reference.source}`}>
|
|
153
|
+
{index > 0 && ', '}
|
|
154
|
+
<span className="mono">{reference.holder}</span> from{' '}
|
|
155
|
+
<span className="mono">{reference.source}</span>
|
|
156
|
+
</span>
|
|
157
|
+
))}
|
|
158
|
+
.
|
|
159
|
+
</li>
|
|
160
|
+
)}
|
|
161
|
+
<li>
|
|
162
|
+
<strong>Kept, names only:</strong> the {what} and its {count(deletion.keys, 'key')}, as{' '}
|
|
163
|
+
<span className="mono">{deletion.tombstone}</span>, so the audit log still reads. Its
|
|
164
|
+
name is free to use again.
|
|
165
|
+
</li>
|
|
166
|
+
{deletion.stranded.length > 0 && (
|
|
167
|
+
<li>
|
|
168
|
+
<strong>Left with no access:</strong>{' '}
|
|
169
|
+
{deletion.stranded.map((member, index) => (
|
|
170
|
+
<span key={member}>
|
|
171
|
+
{index > 0 && ', '}
|
|
172
|
+
<span className="mono">{shownMember(member)}</span>
|
|
173
|
+
</span>
|
|
174
|
+
))}
|
|
175
|
+
. Offboard them on the Users or Service accounts page if they are no longer needed.
|
|
176
|
+
</li>
|
|
177
|
+
)}
|
|
178
|
+
</ul>
|
|
179
|
+
);
|
|
180
|
+
}
|