@coffre/ui 0.4.5 → 0.5.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/{affordances-DAvsVz7u.js → affordances-Bqdevf7w.js} +10 -5
- package/dist/chunks/affordances-Bqdevf7w.js.map +1 -0
- package/dist/chunks/{audit-sentence-BhHmvQX_.js → audit-sentence-Cm5nby5k.js} +115 -8
- package/dist/chunks/audit-sentence-Cm5nby5k.js.map +1 -0
- package/dist/chunks/{connected-apps-AZsX9Zvv.js → connected-apps-DTNS7YmY.js} +2 -2
- package/dist/chunks/{connected-apps-AZsX9Zvv.js.map → connected-apps-DTNS7YmY.js.map} +1 -1
- package/dist/chunks/{delete-place-D6LIZkg9.js → delete-place-CIaOq0mt.js} +3 -3
- package/dist/chunks/{delete-place-D6LIZkg9.js.map → delete-place-CIaOq0mt.js.map} +1 -1
- package/dist/chunks/{directory-B6FuiCir.js → directory-DSVt5Tya.js} +54 -60
- package/dist/chunks/directory-DSVt5Tya.js.map +1 -0
- package/dist/chunks/{folders-DvSqBhuu.js → folders-CoGK9oqg.js} +2 -2
- package/dist/chunks/{folders-DvSqBhuu.js.map → folders-CoGK9oqg.js.map} +1 -1
- package/dist/chunks/grants-CRU7yZhL.js +164 -0
- package/dist/chunks/grants-CRU7yZhL.js.map +1 -0
- package/dist/chunks/{offboarding-CLJaNTcD.js → offboarding-DVBSiJRZ.js} +7 -3
- package/dist/chunks/offboarding-DVBSiJRZ.js.map +1 -0
- package/dist/chunks/{principal-page-UtNWKCf8.js → principal-page-BEBr_zW7.js} +350 -91
- package/dist/chunks/principal-page-BEBr_zW7.js.map +1 -0
- package/dist/chunks/{project-page-C4cEaRFa.js → project-page-B3TZ5_ig.js} +2 -2
- package/dist/chunks/{project-page-C4cEaRFa.js.map → project-page-B3TZ5_ig.js.map} +1 -1
- package/dist/chunks/{queries-Dew8mIeo.js → queries-DE5nK2y4.js} +132 -54
- package/dist/chunks/queries-DE5nK2y4.js.map +1 -0
- package/dist/chunks/{references-DWDnXNoW.js → references-uv4Mli9z.js} +4 -3
- package/dist/chunks/{references-DWDnXNoW.js.map → references-uv4Mli9z.js.map} +1 -1
- package/dist/chunks/role-field-DWhkRY6n.js +192 -0
- package/dist/chunks/role-field-DWhkRY6n.js.map +1 -0
- package/dist/chunks/use-action-BRgvbUWt.js +49 -0
- package/dist/chunks/use-action-BRgvbUWt.js.map +1 -0
- package/dist/chunks/{use-change-C4bGRhHY.js → use-change-BJ3dCFHb.js} +40 -14
- package/dist/chunks/use-change-BJ3dCFHb.js.map +1 -0
- package/dist/chunks/{use-shell-Dkv89nW1.js → use-shell-BO4ZTr1y.js} +2 -2
- package/dist/chunks/{use-shell-Dkv89nW1.js.map → use-shell-BO4ZTr1y.js.map} +1 -1
- package/dist/chunks/validation-DiHIwZRA.js +37 -0
- package/dist/chunks/validation-DiHIwZRA.js.map +1 -0
- package/dist/index.d.ts +116 -88
- package/dist/index.js +40 -21
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +8 -7
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.js +53 -21
- package/dist/pages/approval.js.map +1 -1
- package/dist/pages/audit.js +2 -2
- package/dist/pages/environment.js +8 -7
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +2 -2
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/project-access.js +7 -7
- package/dist/pages/project-environments.js +26 -21
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +9 -8
- package/dist/pages/project-settings.js.map +1 -1
- package/dist/pages/project.js +1 -1
- package/dist/pages/projects.js +8 -13
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.js +294 -88
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +7 -7
- package/dist/pages/service-accounts.js.map +1 -1
- package/dist/pages/settings.js +91 -9
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.d.ts +1 -1
- package/dist/pages/unregistered.js +4 -4
- package/dist/pages/unregistered.js.map +1 -1
- package/dist/pages/user.d.ts +2 -0
- package/dist/pages/user.js +21 -3
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/affordances.ts +7 -3
- package/src/components/command-palette.tsx +2 -0
- package/src/components/directory.tsx +58 -63
- package/src/components/grants.tsx +9 -9
- package/src/components/offboarding.tsx +3 -1
- package/src/components/principal-page.tsx +124 -74
- package/src/components/role-field.tsx +183 -0
- package/src/components/scope-picker.tsx +73 -0
- package/src/components/service-tokens.tsx +20 -9
- package/src/components/shell.tsx +6 -10
- package/src/components/trusted-workloads.tsx +121 -42
- package/src/index.ts +1 -0
- package/src/lib/approval.ts +23 -0
- package/src/lib/audit-sentences.ts +109 -3
- package/src/lib/bindings.ts +33 -10
- package/src/lib/capabilities.ts +28 -8
- package/src/lib/changes.ts +22 -13
- package/src/lib/project-access.ts +21 -0
- package/src/lib/queries.ts +121 -44
- package/src/lib/service-setup.ts +41 -0
- package/src/lib/validation.ts +7 -0
- package/src/options.ts +31 -11
- package/src/pages/account.tsx +3 -2
- package/src/pages/approval.tsx +18 -17
- package/src/pages/login.tsx +1 -1
- package/src/pages/project-environments.tsx +12 -15
- package/src/pages/project-settings.tsx +3 -3
- package/src/pages/projects.tsx +1 -5
- package/src/pages/service-account.tsx +7 -5
- package/src/pages/service-accounts.tsx +8 -4
- package/src/pages/settings.tsx +80 -4
- package/src/pages/unregistered.tsx +3 -3
- package/src/pages/user.tsx +24 -1
- package/src/parity.ts +5 -1
- package/src/register.ts +3 -1
- package/src/shared/models.ts +8 -4
- package/src/styles/globals.css +111 -28
- package/dist/chunks/affordances-DAvsVz7u.js.map +0 -1
- package/dist/chunks/audit-sentence-BhHmvQX_.js.map +0 -1
- package/dist/chunks/directory-B6FuiCir.js.map +0 -1
- package/dist/chunks/grants-9kIV6uZ7.js +0 -669
- package/dist/chunks/grants-9kIV6uZ7.js.map +0 -1
- package/dist/chunks/offboarding-CLJaNTcD.js.map +0 -1
- package/dist/chunks/principal-page-UtNWKCf8.js.map +0 -1
- package/dist/chunks/queries-Dew8mIeo.js.map +0 -1
- package/dist/chunks/use-change-C4bGRhHY.js.map +0 -1
- package/dist/chunks/validation-DvPinn8V.js +0 -87
- package/dist/chunks/validation-DvPinn8V.js.map +0 -1
- package/src/components/every-project.tsx +0 -287
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offboarding-DVBSiJRZ.js","names":[],"sources":["../../src/components/offboarding.tsx"],"sourcesContent":["import { Link } from '@tanstack/react-router';\nimport { credentialScopeInWords } from '@coffre/core/access';\nimport type { PrincipalReport, RemovedPrincipal } from '../shared/models';\nimport { Card } from './page';\nimport { EmptyState, Notice, Timestamp } from './ui';\nimport { PrincipalLink } from './principal';\nimport { referenceProblem } from './references';\nimport { ChevronRight, Key, User } from './icons';\nimport { serviceName } from '@coffre/client';\n\n/**\n * The part of a user's or token's page that answers \"what do we change now\n * they have left?\". Owners only. Once someone is removed everything that let\n * them in is gone, but what they saw is not, nor tokens they issued.\n */\nexport function PrincipalReportCards({ report }: { report: PrincipalReport }) {\n const person = report.principalType === 'user';\n return (\n <>\n {report.status === 'removed' && <ConsiderRotating report={report} person={person} />}\n {report.issuedTokens.length > 0 && <IssuedTokens report={report} />}\n {report.references.length > 0 && <MadeReferences report={report} />}\n </>\n );\n}\n\nexport function RemovedNotice({ report }: { report: PrincipalReport }) {\n const person = report.principalType === 'user';\n return (\n <div className=\"report-notice\">\n <Notice>\n Removed\n {report.removedBy !== null && (\n <>\n {' '}by <span className=\"mono\">{report.removedBy}</span>\n </>\n )}\n {report.removedAt !== null && (\n <>\n {' '}on <Timestamp iso={report.removedAt} />\n </>\n )}\n .{' '}\n {person\n ? 'Their project access, sessions, CLI logins, linked sign-in accounts and connected apps were revoked, so adding them again starts from nothing.'\n : 'Its project access and every token issued to it were revoked, so adding it again starts from nothing.'}\n </Notice>\n </div>\n );\n}\n\n/**\n * The people or service accounts removed from the directory, under the live ones.\n * Removal ends their access but not the work it leaves, so they stay one click\n * away until every value they saw has been rotated.\n */\nexport function RemovedList({\n principalType,\n removed,\n}: {\n principalType: RemovedPrincipal['principalType'];\n removed: RemovedPrincipal[];\n}) {\n const users = principalType === 'user';\n const rows = removed.filter((principal) => principal.principalType === principalType);\n if (rows.length === 0) return null;\n return (\n <>\n <h2 className=\"section-title\">Removed</h2>\n <section className=\"card\" aria-label={users ? 'Removed users' : 'Removed service accounts'}>\n <div className=\"dt-wrap\">\n <table className=\"dt directory stacks\">\n <thead>\n <tr>\n <th className=\"n\">#</th>\n <th className=\"col-principal\">\n <span className=\"th\">\n {users ? <User size={14} /> : <Key size={14} />}\n {users ? 'Email' : 'Name'}\n </span>\n </th>\n <th className=\"col-role\">Consider rotating</th>\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Report</span>\n </th>\n </tr>\n </thead>\n <tbody>\n {rows.map((principal, index) => (\n <tr key={principal.principalId} className=\"row-link\">\n <td className=\"n\">{index + 1}</td>\n <td className=\"col-lead\" data-label={users ? 'Email' : 'Name'}>\n <PrincipalLink type={principal.principalType} id={principal.principalId} stretch />\n </td>\n <td className=\"col-role\" data-label=\"Consider rotating\">\n {principal.toRotate === 0 ? (\n <span className=\"cell-muted\">Nothing</span>\n ) : (\n `${principal.toRotate} ${principal.toRotate === 1 ? 'value' : 'values'}`\n )}\n </td>\n {/* The row opens the report; the chevron says it does. */}\n <td className=\"col-actions col-open cell-muted\" aria-hidden=\"true\">\n <ChevronRight size={16} />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </section>\n </>\n );\n}\n\n/** Values a removed member saw that nobody has changed since. */\nfunction ConsiderRotating({ report, person }: { report: PrincipalReport; person: boolean }) {\n const they = person ? 'they' : 'it';\n return (\n <Card\n labelledBy=\"seen-values\"\n title=\"Consider rotating\"\n description={`Values ${they} read or wrote that nobody has changed since. Rotate each at its source, such as a new API key or database password, then save the new value here.`}\n actions={\n report.rotated > 0 && (\n <span className=\"card-aside\">{report.rotated} already rotated</span>\n )\n }\n >\n {report.exposed.length === 0 ? (\n <EmptyState title=\"Nothing left to rotate\">\n {report.rotated > 0\n ? `Every value ${they} saw has had a new version since.`\n : `${person ? 'They have' : 'It has'} not read or written a value that is still current.`}\n </EmptyState>\n ) : (\n <div className=\"dt-wrap\">\n <table className=\"dt report-values\">\n <thead>\n <tr>\n <th>Secret</th>\n <th className=\"col-shrink\">Version</th>\n <th className=\"col-shrink\">Last seen</th>\n </tr>\n </thead>\n <tbody>\n {report.exposed.map((secret) => (\n <tr key={`${secret.project}/${secret.environment}/${secret.key}`}>\n <td>\n <Link\n className=\"cell-link mono\"\n to=\"/projects/$project/$environment\"\n params={{ project: secret.project, environment: secret.environment }}\n search={{ filter: secret.key }}\n >\n <span className=\"report-path\">\n {secret.project}/{secret.environment}/\n </span>\n {secret.key}\n </Link>\n </td>\n <td className=\"col-shrink cell-mono cell-muted\">v{secret.version}</td>\n <td className=\"col-shrink nowrap\">\n {secret.how === 'wrote' ? 'Wrote' : 'Read'}{' '}\n <Timestamp iso={secret.at} display=\"relative\" />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </Card>\n );\n}\n\n/**\n * References they made, as the log names them: each belongs to the\n * environment that holds it, like a value, not to them (D46), so their\n * leaving ends none. Listed to review.\n */\nfunction MadeReferences({ report }: { report: PrincipalReport }) {\n return (\n <Card\n labelledBy=\"made-references\"\n title=\"References they made\"\n description=\"These stay after they leave, and whoever reads a reference's environment reads its source through it. Review them: the source's access managers, or whoever writes where one is held, can break it.\"\n >\n <div className=\"dt-wrap\">\n <table className=\"dt stacks\">\n <thead>\n <tr>\n <th>Reference</th>\n <th>Reads</th>\n <th className=\"col-shrink\">Made</th>\n </tr>\n </thead>\n <tbody>\n {report.references.map((reference) => (\n <tr key={reference.id}>\n <td className=\"mono\" data-label=\"Reference\">{reference.holder}</td>\n <td data-label=\"Reads\">\n <span className=\"mono\">{reference.source}</span>\n {reference.state !== 'live' && <span className=\"cell-muted\"> · {referenceProblem(reference.state)}</span>}\n </td>\n <td className=\"col-shrink nowrap\" data-label=\"Made\">\n <Timestamp iso={reference.createdAt} display=\"relative\" />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </Card>\n );\n}\n\nfunction IssuedTokens({ report }: { report: PrincipalReport }) {\n return (\n <Card\n labelledBy=\"issued-tokens\"\n title=\"Bearer tokens they issued\"\n description=\"These still work, and they saw each one when it was issued. Revoke any they may have kept.\"\n >\n <div className=\"dt-wrap\">\n <table className=\"dt report-tokens\">\n <thead>\n <tr>\n <th>Token</th>\n <th className=\"col-shrink\">Expires</th>\n <th className=\"col-shrink col-hide-narrow\">Last used</th>\n </tr>\n </thead>\n <tbody>\n {report.issuedTokens.map((token) => (\n <tr key={token.id}>\n <td>\n <span className=\"cell-stack\">\n <Link className=\"cell-link mono\" to=\"/service-accounts/$account\" params={{ account: serviceName(token.service) }}>\n service:{serviceName(token.service)}\n </Link>\n <small>\n {token.label ?? 'No label'} · <span className=\"mono\">{token.hint}</span> · reaches{' '}\n {token.scope === null ? 'all its account holds' : credentialScopeInWords(token.scope)}\n </small>\n </span>\n </td>\n <td className=\"col-shrink nowrap\">\n <Timestamp iso={token.expiresAt} display=\"relative\" />\n </td>\n <td className=\"col-shrink col-hide-narrow nowrap\">\n {token.lastUsedAt === null ? (\n <span className=\"cell-muted\">Never</span>\n ) : (\n <Timestamp iso={token.lastUsedAt} display=\"relative\" />\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,qBAAqB,EAAE,UAAuC;CAC5E,MAAM,SAAS,OAAO,kBAAkB;CACxC,OACE,qBAAA,UAAA,EAAA,UAAA;EACG,OAAO,WAAW,aAAa,oBAAC,kBAAD;GAA0B;GAAgB;EAAS,CAAA;EAClF,OAAO,aAAa,SAAS,KAAK,oBAAC,cAAD,EAAsB,OAAS,CAAA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U;OAAiB,IAAG;OAA6B,QAAQ,EAAE,SAAS,YAAY,MAAM,OAAO,EAAE;iBAA/G,CAAkH,YACvG,YAAY,MAAM,OAAO,CAC9B;UACN,qBAAC,SAAD,EAAA,UAAA;OACG,MAAM,SAAS;OAAW;OAAG,oBAAC,QAAD;QAAM,WAAU;kBAAQ,MAAM;OAAW,CAAA;OAAC;OAAW;OAClF,MAAM,UAAU,OAAO,0BAA0B,uBAAuB,MAAM,KAAK;MAC/E,EAAA,CAAA,CACH;QACJ,CAAA;KACJ,oBAAC,MAAD;MAAI,WAAU;gBACZ,oBAAC,WAAD;OAAW,KAAK,MAAM;OAAW,SAAQ;MAAY,CAAA;KACnD,CAAA;KACJ,oBAAC,MAAD;MAAI,WAAU;gBACX,MAAM,eAAe,OACpB,oBAAC,QAAD;OAAM,WAAU;iBAAa;MAAW,CAAA,IAExC,oBAAC,WAAD;OAAW,KAAK,MAAM;OAAY,SAAQ;MAAY,CAAA;KAEtD,CAAA;IACF,EAAA,GAtBK,MAAM,EAsBX,CACL,EACI,CAAA,CACF;;EACJ,CAAA;CACD,CAAA;AAEV"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { t as useMounted } from "./mounted-jJmqqV_n.js";
|
|
2
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";
|
|
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, it as X, l as uiResult, n as ClosedDoor, rt as Users, s as memberRef, u as useCoffre, x as Clock } from "./page-DvsgZ2Hd.js";
|
|
4
4
|
import { t as ItemFailure } from "./row-state-DOPUsjQK.js";
|
|
5
|
-
import {
|
|
6
|
-
import { t as useShell } from "./use-shell-
|
|
5
|
+
import { a as listsAccess, g as queries, i as keys, m as managedProjects, r as hasAppsTab, t as affects, y as signInWays } from "./queries-DE5nK2y4.js";
|
|
6
|
+
import { t as useShell } from "./use-shell-BO4ZTr1y.js";
|
|
7
7
|
import { t as PageTabs } from "./tabs-BmwKfUeK.js";
|
|
8
|
-
import {
|
|
8
|
+
import { j as projectAccessLabel, k as accessRows, l as directoryList, n as useChangeStatus } from "./use-change-BJ3dCFHb.js";
|
|
9
9
|
import { t as PrincipalAvatar } from "./principal-BIN-xwZw.js";
|
|
10
|
-
import { i as PrincipalActions, n as InstanceRole, r as KIND } from "./directory-
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { r as RemovedNotice, t as PrincipalReportCards } from "./offboarding-CLJaNTcD.js";
|
|
10
|
+
import { i as PrincipalActions, n as InstanceRole, r as KIND } from "./directory-DSVt5Tya.js";
|
|
11
|
+
import { a as lines, i as describe, t as Sentence } from "./audit-sentence-Cm5nby5k.js";
|
|
12
|
+
import { t as useAction } from "./use-action-BRgvbUWt.js";
|
|
13
|
+
import { n as GrantsTable, t as GrantRowView } from "./grants-CRU7yZhL.js";
|
|
14
|
+
import { r as RemovedNotice, t as PrincipalReportCards } from "./offboarding-DVBSiJRZ.js";
|
|
16
15
|
import { useState } from "react";
|
|
17
16
|
import { Link, Outlet } from "@tanstack/react-router";
|
|
18
17
|
import { toast } from "sonner";
|
|
18
|
+
import { INSTANCE_ROLES, ROLES, ROLE_NAMES, inScope, scopeInWords, unscoped } from "@coffre/core/access";
|
|
19
19
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
-
import { useInfiniteQuery,
|
|
21
|
-
import { ROLES } from "@coffre/core/access";
|
|
20
|
+
import { useInfiniteQuery, useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
|
22
21
|
//#region src/components/actions-log.tsx
|
|
23
22
|
var PAGE_SIZE = 50;
|
|
24
23
|
/**
|
|
@@ -131,28 +130,262 @@ function ActionsLog({ member }) {
|
|
|
131
130
|
})] });
|
|
132
131
|
}
|
|
133
132
|
//#endregion
|
|
133
|
+
//#region src/lib/service-setup.ts
|
|
134
|
+
/**
|
|
135
|
+
* The roles you may give a service account at a project, or one of its
|
|
136
|
+
* environments, as the server decides it (`givesService` in
|
|
137
|
+
* @coffre/core/access): any, where you manage access; otherwise, inside the
|
|
138
|
+
* instance's setting, those whose every permission you hold there.
|
|
139
|
+
*
|
|
140
|
+
* a Developer of every dev, at market/dev viewer, developer
|
|
141
|
+
* the same, at market none: a project takes holding all of it
|
|
142
|
+
*/
|
|
143
|
+
function givable(holder, project, environment) {
|
|
144
|
+
const held = environment === null ? project.permissions : holder.environments.find((entry) => entry.project === project.slug && entry.environment === environment)?.permissions ?? [];
|
|
145
|
+
if (held.includes("grant.manage")) return [...ROLE_NAMES];
|
|
146
|
+
const setting = holder.serviceSetup;
|
|
147
|
+
const place = environment === null ? { projectId: project.slug } : {
|
|
148
|
+
projectId: project.slug,
|
|
149
|
+
environmentId: environment,
|
|
150
|
+
environmentSlug: environment
|
|
151
|
+
};
|
|
152
|
+
if (setting === null || !inScope(setting, place)) return [];
|
|
153
|
+
return ROLE_NAMES.filter((role) => ROLES[role].permissions.every((permission) => held.includes(permission)));
|
|
154
|
+
}
|
|
155
|
+
/** The projects where you may give a service account something: on the project, or on one of its environments. */
|
|
156
|
+
function serviceProjects(holder) {
|
|
157
|
+
return holder.projects.filter((project) => givable(holder, project, null).length > 0 || project.environments.some((environment) => givable(holder, project, environment.slug).length > 0));
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/lib/access-plan.ts
|
|
161
|
+
/** An environment's access in a plan; slugs like `constructor` are not inherited. */
|
|
162
|
+
function environmentAccess(plan, slug) {
|
|
163
|
+
return Object.hasOwn(plan.environments, slug) ? plan.environments[slug] : null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Read what a principal holds on a project back into the editor's terms.
|
|
167
|
+
* `environments` are the ones the editor can set: live, and not archived.
|
|
168
|
+
*/
|
|
169
|
+
function planFromGrants(grants, environments) {
|
|
170
|
+
if (grants.length === 0) return {
|
|
171
|
+
level: "none",
|
|
172
|
+
expiresAt: null,
|
|
173
|
+
environments: {}
|
|
174
|
+
};
|
|
175
|
+
const [only] = grants;
|
|
176
|
+
if (grants.length === 1 && only.environmentSlug === null && (only.role === "owner" || only.role === "viewer" || only.role === "developer")) return {
|
|
177
|
+
level: only.role,
|
|
178
|
+
expiresAt: only.expiresAt,
|
|
179
|
+
environments: {}
|
|
180
|
+
};
|
|
181
|
+
const perEnvironment = {};
|
|
182
|
+
for (const grant of grants) {
|
|
183
|
+
const slug = grant.environmentSlug;
|
|
184
|
+
if (slug === null || !environments.includes(slug) || Object.hasOwn(perEnvironment, slug) || grant.role !== "viewer" && grant.role !== "developer") return {
|
|
185
|
+
level: "custom",
|
|
186
|
+
expiresAt: null,
|
|
187
|
+
environments: {}
|
|
188
|
+
};
|
|
189
|
+
perEnvironment[slug] = {
|
|
190
|
+
role: grant.role,
|
|
191
|
+
expiresAt: grant.expiresAt
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
level: "env",
|
|
196
|
+
expiresAt: null,
|
|
197
|
+
environments: perEnvironment
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Switch a plan's level. Going from read or write everywhere to per
|
|
202
|
+
* environment starts every environment at that level and expiry, so the
|
|
203
|
+
* switch alone keeps the same reach.
|
|
204
|
+
*/
|
|
205
|
+
function withLevel(plan, level, environments) {
|
|
206
|
+
if (level === "env" && (plan.level === "viewer" || plan.level === "developer") && Object.keys(plan.environments).length === 0) {
|
|
207
|
+
const access = {
|
|
208
|
+
role: plan.level,
|
|
209
|
+
expiresAt: plan.expiresAt
|
|
210
|
+
};
|
|
211
|
+
return {
|
|
212
|
+
...plan,
|
|
213
|
+
level,
|
|
214
|
+
environments: Object.fromEntries(environments.map((slug) => [slug, access]))
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
...plan,
|
|
219
|
+
level
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/** Set one environment's access, or take it away with `null`. */
|
|
223
|
+
function withEnvironment(plan, slug, access) {
|
|
224
|
+
const environments = { ...plan.environments };
|
|
225
|
+
if (access === null) delete environments[slug];
|
|
226
|
+
else environments[slug] = access;
|
|
227
|
+
return {
|
|
228
|
+
...plan,
|
|
229
|
+
environments
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function grantsFor(plan) {
|
|
233
|
+
switch (plan.level) {
|
|
234
|
+
case "none":
|
|
235
|
+
case "custom": return [];
|
|
236
|
+
case "owner":
|
|
237
|
+
case "viewer":
|
|
238
|
+
case "developer": return [{
|
|
239
|
+
role: plan.level,
|
|
240
|
+
environmentSlug: null,
|
|
241
|
+
expiresAt: plan.expiresAt
|
|
242
|
+
}];
|
|
243
|
+
case "env": return Object.entries(plan.environments).map(([environmentSlug, access]) => ({
|
|
244
|
+
environmentSlug,
|
|
245
|
+
...access
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** The server and the date field spell the same instant differently. */
|
|
250
|
+
function sameExpiry(a, b) {
|
|
251
|
+
return a === b || a !== null && b !== null && Date.parse(a) === Date.parse(b);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The changes that take what is held to the plan: grants to create, grants
|
|
255
|
+
* whose expiry moves, and grants to revoke, in that order. Asking for what is
|
|
256
|
+
* already held yields nothing, so applying the same plan twice is a no-op.
|
|
257
|
+
*/
|
|
258
|
+
function accessChanges(grants, plan) {
|
|
259
|
+
if (plan.level === "custom") return [];
|
|
260
|
+
const key = (grant) => `${grant.role}@${grant.environmentSlug ?? ""}`;
|
|
261
|
+
const wanted = new Map(grantsFor(plan).map((grant) => [key(grant), grant]));
|
|
262
|
+
const held = new Map(grants.map((grant) => [key(grant), grant]));
|
|
263
|
+
const changes = [];
|
|
264
|
+
for (const [id, grant] of wanted) if (!held.has(id)) changes.push({
|
|
265
|
+
kind: "create",
|
|
266
|
+
...grant
|
|
267
|
+
});
|
|
268
|
+
for (const [id, grant] of held) {
|
|
269
|
+
const want = wanted.get(id);
|
|
270
|
+
if (want !== void 0 && !sameExpiry(grant.expiresAt, want.expiresAt)) changes.push({
|
|
271
|
+
kind: "expiry",
|
|
272
|
+
grant,
|
|
273
|
+
expiresAt: want.expiresAt
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
for (const [id, grant] of held) if (!wanted.has(id)) changes.push({
|
|
277
|
+
kind: "revoke",
|
|
278
|
+
grant
|
|
279
|
+
});
|
|
280
|
+
return changes;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The changes as the API's access patch for one project: each place it
|
|
284
|
+
* touches, and the role to hold there until when, or `null` for none.
|
|
285
|
+
*
|
|
286
|
+
* { "market": null, "market/dev": { "role": "developer", "until": "2026-12-31T23:59:59.000Z" } }
|
|
287
|
+
*
|
|
288
|
+
* A place holds one role, so where a level changes, the revoke of the old
|
|
289
|
+
* role and the create of the new land on the same place, and the new role
|
|
290
|
+
* wins: the server replaces one with the other, never passing through none.
|
|
291
|
+
*/
|
|
292
|
+
function accessPatch(project, changes) {
|
|
293
|
+
const place = (environmentSlug) => environmentSlug === null ? project : `${project}/${environmentSlug}`;
|
|
294
|
+
const holding = (role, expiresAt) => expiresAt === null ? role : {
|
|
295
|
+
role,
|
|
296
|
+
until: expiresAt
|
|
297
|
+
};
|
|
298
|
+
const patch = {};
|
|
299
|
+
for (const change of changes) if (change.kind === "revoke") patch[place(change.grant.environmentSlug)] = null;
|
|
300
|
+
for (const change of changes) {
|
|
301
|
+
if (change.kind === "expiry") patch[place(change.grant.environmentSlug)] = holding(change.grant.role, change.expiresAt);
|
|
302
|
+
if (change.kind === "create") patch[place(change.environmentSlug)] = holding(change.role, change.expiresAt);
|
|
303
|
+
}
|
|
304
|
+
return patch;
|
|
305
|
+
}
|
|
306
|
+
/** A date field's value as the instant access ends: the close of that day, UTC. */
|
|
307
|
+
function expiryFromDate(date) {
|
|
308
|
+
return date === "" ? null : (/* @__PURE__ */ new Date(`${date}T23:59:59Z`)).toISOString();
|
|
309
|
+
}
|
|
310
|
+
/** A date field's value for an expiry. Expiries are shown as UTC dates everywhere. */
|
|
311
|
+
function dateFromExpiry(expiresAt) {
|
|
312
|
+
return expiresAt === null ? "" : expiresAt.slice(0, 10);
|
|
313
|
+
}
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/components/expiry-field.tsx
|
|
316
|
+
/**
|
|
317
|
+
* When one grant ends, as a date: access lasts through that day, UTC. Blank
|
|
318
|
+
* reads "Never" where the browser lets the empty field be restyled.
|
|
319
|
+
*/
|
|
320
|
+
function ExpiryField({ label, expiresAt, onChange }) {
|
|
321
|
+
const date = dateFromExpiry(expiresAt);
|
|
322
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
323
|
+
className: `expiry${date === "" ? " is-never" : ""}`,
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx("input", {
|
|
326
|
+
className: "input select-sm",
|
|
327
|
+
type: "date",
|
|
328
|
+
"aria-label": label,
|
|
329
|
+
min: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
330
|
+
value: date,
|
|
331
|
+
onChange: (event) => onChange(expiryFromDate(event.target.value))
|
|
332
|
+
}),
|
|
333
|
+
/* @__PURE__ */ jsx("span", {
|
|
334
|
+
className: "expiry-never",
|
|
335
|
+
"aria-hidden": "true",
|
|
336
|
+
children: "Never"
|
|
337
|
+
}),
|
|
338
|
+
/* @__PURE__ */ jsx("button", {
|
|
339
|
+
className: "btn btn-quiet btn-sm btn-icon",
|
|
340
|
+
type: "button",
|
|
341
|
+
"aria-label": `${label}: never`,
|
|
342
|
+
title: "Never expires",
|
|
343
|
+
onClick: () => onChange(null),
|
|
344
|
+
children: /* @__PURE__ */ jsx(X, { size: 12 })
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
134
350
|
//#region src/components/principal-page.tsx
|
|
135
351
|
/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */
|
|
136
352
|
function useReport(principalType, principalId) {
|
|
137
353
|
const { capabilities } = useShell();
|
|
138
|
-
return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.
|
|
354
|
+
return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.runsInstance)).data;
|
|
139
355
|
}
|
|
140
356
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
357
|
+
* What `loadAccess` read in one request: their role and scope, and, for each
|
|
358
|
+
* project where you manage access, the grants they hold there. For a
|
|
359
|
+
* service account you manage, each project where you may give it
|
|
360
|
+
* something, and what (`offers`).
|
|
143
361
|
*/
|
|
144
|
-
function
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
362
|
+
function useMemberAccess(principalType, principalId) {
|
|
363
|
+
const shell = useShell();
|
|
364
|
+
const { data } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));
|
|
365
|
+
const error = data !== null && !data.ok ? data.error : null;
|
|
366
|
+
const access = data?.ok === true ? data : null;
|
|
367
|
+
const yours = principalType === "service" && access?.managed === true;
|
|
368
|
+
const listed = yours ? serviceProjects(shell) : managedProjects(shell.projects);
|
|
369
|
+
return {
|
|
370
|
+
access,
|
|
371
|
+
error,
|
|
372
|
+
offers: yours ? (project, environment) => givable(shell, project, environment) : () => ROLE_NAMES,
|
|
373
|
+
projects: listed.map((project) => ({
|
|
151
374
|
project,
|
|
152
|
-
grants:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
375
|
+
grants: (access?.grants ?? []).filter((grant) => grant.project === project.slug).map((grant) => ({
|
|
376
|
+
id: grant.id,
|
|
377
|
+
principalType,
|
|
378
|
+
principalId,
|
|
379
|
+
role: grant.role,
|
|
380
|
+
roleName: grant.roleName,
|
|
381
|
+
permissions: grant.permissions,
|
|
382
|
+
scope: grant.environment === null ? "project" : "environment",
|
|
383
|
+
environmentSlug: grant.environment,
|
|
384
|
+
expiresAt: grant.expiresAt
|
|
385
|
+
})),
|
|
386
|
+
grantsError: error
|
|
387
|
+
}))
|
|
388
|
+
};
|
|
156
389
|
}
|
|
157
390
|
/**
|
|
158
391
|
* A user's or service account's page: who it is, its menu, and its tabs,
|
|
@@ -165,6 +398,8 @@ function PrincipalLayout({ principalType, principalId }) {
|
|
|
165
398
|
const mounted = useMounted();
|
|
166
399
|
const { capabilities } = shell;
|
|
167
400
|
const report = useReport(principalType, principalId);
|
|
401
|
+
const { data: held } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));
|
|
402
|
+
const yours = principalType === "service" && held?.ok === true && held.managed;
|
|
168
403
|
const { status, dismiss } = useChangeStatus(directoryList.queryKey);
|
|
169
404
|
const change = status(memberRef(principalType, principalId));
|
|
170
405
|
const kind = KIND[principalType];
|
|
@@ -175,10 +410,20 @@ function PrincipalLayout({ principalType, principalId }) {
|
|
|
175
410
|
principalType,
|
|
176
411
|
principalId,
|
|
177
412
|
instanceRole: found.instanceRole,
|
|
413
|
+
scope: found.scope,
|
|
178
414
|
isRootAdmin: found.isRootAdmin,
|
|
179
|
-
tampered: found.status === "tampered"
|
|
415
|
+
tampered: found.status === "tampered",
|
|
416
|
+
managed: principalType === "service"
|
|
417
|
+
} : yours ? {
|
|
418
|
+
principalType,
|
|
419
|
+
principalId,
|
|
420
|
+
instanceRole: "member",
|
|
421
|
+
scope: null,
|
|
422
|
+
isRootAdmin: false,
|
|
423
|
+
tampered: false,
|
|
424
|
+
managed: true
|
|
180
425
|
} : void 0;
|
|
181
|
-
if (report?.ok === true && found === null || report === null && managedProjects(shell.projects).length === 0) return /* @__PURE__ */ jsx(ClosedDoor, {
|
|
426
|
+
if (report?.ok === true && found === null || report === null && managedProjects(shell.projects).length === 0 && !yours) return /* @__PURE__ */ jsx(ClosedDoor, {
|
|
182
427
|
icon: people ? /* @__PURE__ */ jsx(Users, { size: 18 }) : /* @__PURE__ */ jsx(Key, { size: 18 }),
|
|
183
428
|
label: /* @__PURE__ */ jsx("span", {
|
|
184
429
|
className: "mono",
|
|
@@ -194,20 +439,28 @@ function PrincipalLayout({ principalType, principalId }) {
|
|
|
194
439
|
});
|
|
195
440
|
const access = /* @__PURE__ */ jsxs(Fragment$1, { children: [removed ? /* @__PURE__ */ jsx(Archive, { size: 15 }) : /* @__PURE__ */ jsx(Folder, { size: 15 }), removed ? "Offboarding" : "Access"] });
|
|
196
441
|
const activity = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Activity, { size: 15 }), "Activity"] });
|
|
197
|
-
const tabs = people ? [
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
442
|
+
const tabs = people ? [
|
|
443
|
+
/* @__PURE__ */ jsx(Link, {
|
|
444
|
+
to: "/users/$user",
|
|
445
|
+
params: { user: principalId },
|
|
446
|
+
activeOptions: {
|
|
447
|
+
exact: true,
|
|
448
|
+
includeSearch: false
|
|
449
|
+
},
|
|
450
|
+
children: access
|
|
451
|
+
}, "access"),
|
|
452
|
+
hasAppsTab(shell, report) && mounted("/users/$user/apps") && /* @__PURE__ */ jsxs(Link, {
|
|
453
|
+
to: "/users/$user/apps",
|
|
454
|
+
params: { user: principalId },
|
|
455
|
+
children: [/* @__PURE__ */ jsx(Link$1, { size: 15 }), "Connected apps"]
|
|
456
|
+
}, "apps"),
|
|
457
|
+
capabilities.canReadAudit && mounted("/users/$user/activity") && /* @__PURE__ */ jsx(Link, {
|
|
458
|
+
to: "/users/$user/activity",
|
|
459
|
+
params: { user: principalId },
|
|
460
|
+
children: activity
|
|
461
|
+
}, "activity")
|
|
462
|
+
] : [
|
|
463
|
+
signInWays(shell, held) !== null && /* @__PURE__ */ jsxs(Link, {
|
|
211
464
|
to: "/service-accounts/$account",
|
|
212
465
|
params: { account: principalId },
|
|
213
466
|
activeOptions: {
|
|
@@ -272,40 +525,26 @@ function PrincipalLayout({ principalType, principalId }) {
|
|
|
272
525
|
* its offboarding did instead.
|
|
273
526
|
*/
|
|
274
527
|
function PrincipalAccess({ principalType, principalId }) {
|
|
275
|
-
const { instanceRole
|
|
528
|
+
const { instanceRole } = useShell();
|
|
276
529
|
const report = useReport(principalType, principalId);
|
|
277
|
-
const access =
|
|
530
|
+
const { access: held, error, projects: access, offers } = useMemberAccess(principalType, principalId);
|
|
278
531
|
const kind = KIND[principalType];
|
|
279
532
|
const people = principalType === "user";
|
|
280
533
|
const found = report?.ok === true ? report.report : null;
|
|
281
534
|
const removed = found?.status === "removed";
|
|
282
|
-
const rows = access.flatMap((
|
|
283
|
-
project,
|
|
284
|
-
grant
|
|
285
|
-
})));
|
|
286
|
-
const errors = access.filter((entry) => entry.grantsError !== null);
|
|
535
|
+
const rows = accessRows(access).flatMap((row) => row.grant === null ? [] : [row]);
|
|
287
536
|
const editable = removed ? [] : access.filter(({ project, grantsError }) => project.archivedAt === null && grantsError === null);
|
|
288
537
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
289
538
|
removed && found !== null && /* @__PURE__ */ jsx(RemovedNotice, { report: found }),
|
|
290
539
|
!removed && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
291
|
-
|
|
292
|
-
style: { marginBottom: "0.75rem" },
|
|
293
|
-
children: /* @__PURE__ */ jsxs(Notice, {
|
|
294
|
-
tone: "bad",
|
|
295
|
-
children: [
|
|
296
|
-
/* @__PURE__ */ jsx("span", {
|
|
297
|
-
className: "mono",
|
|
298
|
-
children: project.slug
|
|
299
|
-
}),
|
|
300
|
-
": ",
|
|
301
|
-
grantsError
|
|
302
|
-
]
|
|
303
|
-
})
|
|
304
|
-
}, project.slug)),
|
|
540
|
+
people && held !== null && /* @__PURE__ */ jsx(InstanceRoleNote, { access: held }),
|
|
305
541
|
/* @__PURE__ */ jsx("section", {
|
|
306
542
|
className: "card",
|
|
307
543
|
"aria-label": "Project access",
|
|
308
|
-
children:
|
|
544
|
+
children: error !== null ? /* @__PURE__ */ jsx(UnreadAccess, {
|
|
545
|
+
member: memberRef(principalType, principalId),
|
|
546
|
+
error
|
|
547
|
+
}) : rows.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
309
548
|
title: "No project access yet",
|
|
310
549
|
children: editable.length > 0 ? `Edit access gives this ${kind} access to several projects at once.` : `None of the projects where you manage access has a grant for this ${kind}.`
|
|
311
550
|
}) : /* @__PURE__ */ jsx(GrantsTable, {
|
|
@@ -342,32 +581,50 @@ function PrincipalAccess({ principalType, principalId }) {
|
|
|
342
581
|
children: /* @__PURE__ */ jsx(EditAccess, {
|
|
343
582
|
principalType,
|
|
344
583
|
principalId,
|
|
345
|
-
access: editable
|
|
584
|
+
access: editable,
|
|
585
|
+
offers
|
|
346
586
|
})
|
|
347
587
|
}),
|
|
348
588
|
instanceRole !== "root-admin" && /* @__PURE__ */ jsx("p", {
|
|
349
589
|
className: "hint section-foot",
|
|
350
|
-
children: "Only projects where you manage access are listed."
|
|
351
|
-
}),
|
|
352
|
-
/* @__PURE__ */ jsx(EveryProjectGrants, {
|
|
353
|
-
principalType,
|
|
354
|
-
principalId
|
|
355
|
-
}),
|
|
356
|
-
features.mcp && people && found !== null && /* @__PURE__ */ jsx(MemberApps, {
|
|
357
|
-
principalId,
|
|
358
|
-
apps: found.apps
|
|
590
|
+
children: held?.managed === true && principalType === "service" ? "Only projects where you may give it access are listed: what you hold there, where the instance lets you." : "Only projects where you manage access are listed."
|
|
359
591
|
})
|
|
360
592
|
] }),
|
|
361
593
|
found !== null && /* @__PURE__ */ jsx(PrincipalReportCards, { report: found })
|
|
362
594
|
] });
|
|
363
595
|
}
|
|
364
|
-
/**
|
|
365
|
-
function
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
596
|
+
/** What a person's instance role gives them, above the grants that add to it: nothing for a Member. */
|
|
597
|
+
function InstanceRoleNote({ access }) {
|
|
598
|
+
if (access.instanceRole === "member" || access.instanceRole === "root-admin") return null;
|
|
599
|
+
const { name } = INSTANCE_ROLES[access.instanceRole];
|
|
600
|
+
return /* @__PURE__ */ jsx("div", {
|
|
601
|
+
className: "report-notice",
|
|
602
|
+
children: /* @__PURE__ */ jsxs(Notice, {
|
|
603
|
+
tone: "info",
|
|
604
|
+
children: [
|
|
605
|
+
/* @__PURE__ */ jsx("strong", { children: name }),
|
|
606
|
+
access.scope === null ? "" : unscoped(access.scope) ? " in every project" : `: ${scopeInWords(access.scope)}`,
|
|
607
|
+
", from their instance role. The grants below add to it."
|
|
608
|
+
]
|
|
609
|
+
})
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
/** Their access could not be read: why, and another try, never an empty list that reads as no access. */
|
|
613
|
+
function UnreadAccess({ member, error }) {
|
|
614
|
+
const queryClient = useQueryClient();
|
|
615
|
+
const [retrying, setRetrying] = useState(false);
|
|
616
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
617
|
+
className: "row-failure-line unread-access",
|
|
618
|
+
children: [/* @__PURE__ */ jsx(ErrorLine, { error: `Their access could not be read. ${error}` }), /* @__PURE__ */ jsxs("button", {
|
|
619
|
+
type: "button",
|
|
620
|
+
className: "act",
|
|
621
|
+
disabled: retrying,
|
|
622
|
+
onClick: () => {
|
|
623
|
+
setRetrying(true);
|
|
624
|
+
queryClient.refetchQueries({ queryKey: keys.memberAccess(member) }).finally(() => setRetrying(false));
|
|
625
|
+
},
|
|
626
|
+
children: [retrying && /* @__PURE__ */ jsx(Spinner, { size: 13 }), "Retry"]
|
|
627
|
+
})]
|
|
371
628
|
});
|
|
372
629
|
}
|
|
373
630
|
/**
|
|
@@ -378,7 +635,7 @@ function MemberApps({ principalId, apps }) {
|
|
|
378
635
|
* only the difference, every project in one `access.set`: the server applies
|
|
379
636
|
* all of it in one transaction, or none of it.
|
|
380
637
|
*/
|
|
381
|
-
function EditAccess({ principalType, principalId, access }) {
|
|
638
|
+
function EditAccess({ principalType, principalId, access, offers }) {
|
|
382
639
|
const coffre = useCoffre();
|
|
383
640
|
const [open, setOpen] = useState(false);
|
|
384
641
|
const [edits, setEdits] = useState({});
|
|
@@ -394,6 +651,8 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
394
651
|
environments,
|
|
395
652
|
held,
|
|
396
653
|
plan,
|
|
654
|
+
whole: offers(project, null),
|
|
655
|
+
each: Object.fromEntries(environments.map((slug) => [slug, offers(project, slug)])),
|
|
397
656
|
changes: accessChanges(grants, plan)
|
|
398
657
|
};
|
|
399
658
|
});
|
|
@@ -414,7 +673,7 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
414
673
|
className: "mono",
|
|
415
674
|
children: principalId
|
|
416
675
|
})] }),
|
|
417
|
-
description: `Set what this ${kind} can reach on each project you manage, and until when.`,
|
|
676
|
+
description: `Set what this ${kind} can reach on each project you ${principalType === "service" ? "may give it access to" : "manage"}, and until when.`,
|
|
418
677
|
wide: true,
|
|
419
678
|
children: /* @__PURE__ */ jsxs("form", {
|
|
420
679
|
className: "form",
|
|
@@ -439,7 +698,7 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
439
698
|
/* @__PURE__ */ jsx("span", { children: "Access" }),
|
|
440
699
|
/* @__PURE__ */ jsx("span", { children: "Expires" })
|
|
441
700
|
]
|
|
442
|
-
}), rows.map(({ project, grants, environments, held, plan, changes }) => {
|
|
701
|
+
}), rows.map(({ project, grants, environments, held, plan, whole, each, changes }) => {
|
|
443
702
|
const id = `plan-${project.slug}`;
|
|
444
703
|
const edit = (next) => setEdits((current) => ({
|
|
445
704
|
...current,
|
|
@@ -476,19 +735,19 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
476
735
|
value: "none",
|
|
477
736
|
children: "No access"
|
|
478
737
|
}),
|
|
479
|
-
/* @__PURE__ */ jsx("option", {
|
|
738
|
+
whole.includes("owner") && /* @__PURE__ */ jsx("option", {
|
|
480
739
|
value: "owner",
|
|
481
740
|
children: ROLES.owner.name
|
|
482
741
|
}),
|
|
483
|
-
/* @__PURE__ */ jsxs("option", {
|
|
742
|
+
whole.includes("viewer") && /* @__PURE__ */ jsxs("option", {
|
|
484
743
|
value: "viewer",
|
|
485
744
|
children: [ROLES.viewer.name, ": all"]
|
|
486
745
|
}),
|
|
487
|
-
/* @__PURE__ */ jsxs("option", {
|
|
746
|
+
whole.includes("developer") && /* @__PURE__ */ jsxs("option", {
|
|
488
747
|
value: "developer",
|
|
489
748
|
children: [ROLES.developer.name, ": all"]
|
|
490
749
|
}),
|
|
491
|
-
environments.length > 0 && /* @__PURE__ */ jsx("option", {
|
|
750
|
+
environments.some((slug) => each[slug].length > 0) && /* @__PURE__ */ jsx("option", {
|
|
492
751
|
value: "env",
|
|
493
752
|
children: "Per environment…"
|
|
494
753
|
})
|
|
@@ -531,11 +790,11 @@ function EditAccess({ principalType, principalId, access }) {
|
|
|
531
790
|
value: "",
|
|
532
791
|
children: "No access"
|
|
533
792
|
}),
|
|
534
|
-
/* @__PURE__ */ jsx("option", {
|
|
793
|
+
each[slug].includes("viewer") && /* @__PURE__ */ jsx("option", {
|
|
535
794
|
value: "viewer",
|
|
536
795
|
children: ROLES.viewer.name
|
|
537
796
|
}),
|
|
538
|
-
/* @__PURE__ */ jsx("option", {
|
|
797
|
+
each[slug].includes("developer") && /* @__PURE__ */ jsx("option", {
|
|
539
798
|
value: "developer",
|
|
540
799
|
children: ROLES.developer.name
|
|
541
800
|
})
|
|
@@ -633,4 +892,4 @@ function AccessChangeTag({ change }) {
|
|
|
633
892
|
//#endregion
|
|
634
893
|
export { PrincipalLayout as n, ActionsLog as r, PrincipalAccess as t };
|
|
635
894
|
|
|
636
|
-
//# sourceMappingURL=principal-page-
|
|
895
|
+
//# sourceMappingURL=principal-page-BEBr_zW7.js.map
|