@coffre/ui 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +7 -3
- package/dist/client/.assetsignore +2 -0
- package/dist/client/_coffre/assets/account-C3Zo1l5A.js +1 -0
- package/dist/client/_coffre/assets/account-C4bNbeO7.js +2 -0
- package/dist/client/_coffre/assets/affordances-DiuJIiR2.js +1 -0
- package/dist/client/_coffre/assets/audit-1xLyuxGz.js +2 -0
- package/dist/client/_coffre/assets/audit-Dab2GuRj.js +1 -0
- package/dist/client/_coffre/assets/auth.device-BfCfeBWe.js +2 -0
- package/dist/client/_coffre/assets/auth.device-D2pCLF-X.js +1 -0
- package/dist/client/_coffre/assets/coffre-C7qL3HGR.js +1 -0
- package/dist/client/_coffre/assets/directory-C2Ou4SQv.js +1 -0
- package/dist/client/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/client/_coffre/assets/grants-fqTtJ-aW.js +1 -0
- package/dist/client/_coffre/assets/index-BpGwbjmM.js +12 -0
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/login-CR9CBXlw.js +2 -0
- package/dist/client/_coffre/assets/login-DZizFxa4.js +1 -0
- package/dist/client/_coffre/assets/offboarding-DOLJQcXU.js +1 -0
- package/dist/client/_coffre/assets/page-BxW2MwaX.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-BHuP8_FL.js +46 -0
- package/dist/client/_coffre/assets/principal-page-xnBZVURr.js +1 -0
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CrWjQmIA.js +2 -0
- package/dist/client/_coffre/assets/projects._project._environment-CwRVG9Ne.js +3 -0
- package/dist/client/_coffre/assets/projects._project.index-CCDEuE-z.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DCJsmnD7.js +1 -0
- package/dist/client/_coffre/assets/projects.index-B8eV8JIn.js +1 -0
- package/dist/client/_coffre/assets/projects.index-BNEC7Oz8.js +2 -0
- package/dist/client/_coffre/assets/settings-2BPsenNM.js +2 -0
- package/dist/client/_coffre/assets/settings-BrS0-wEt.js +1 -0
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-B3-YwuKp.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-D_hsbHx6.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-BdKE2Jv8.js +2 -0
- package/dist/client/_coffre/assets/tokens.index-XvA4XRxh.js +1 -0
- package/dist/client/_coffre/assets/unregistered-CTRMtBIy.js +1 -0
- package/dist/client/_coffre/assets/use-action-DgAf-tiX.js +1 -0
- package/dist/client/_coffre/assets/users._user-BFPXcJ4y.js +2 -0
- package/dist/client/_coffre/assets/users._user-DEtMeSoh.js +1 -0
- package/dist/client/_coffre/assets/users.index-B03beUHq.js +1 -0
- package/dist/client/_coffre/assets/users.index-D8hwzM6P.js +2 -0
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/server/.vite/manifest.json +572 -0
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-B6CZDfrB.js +133 -0
- package/dist/server/_coffre/assets/account-B71_b5xc.js +296 -0
- package/dist/server/_coffre/assets/account-BoO6ZqMc.js +176 -0
- package/dist/server/_coffre/assets/affordances-BNaXjMOb.js +46 -0
- package/dist/server/_coffre/assets/async-local-storage-C0cwgkEr.js +3107 -0
- package/dist/server/_coffre/assets/audit-CwRFnSAY.js +74 -0
- package/dist/server/_coffre/assets/audit-t1sYjtrf.js +964 -0
- package/dist/server/_coffre/assets/auth.device-1IcJ475s.js +208 -0
- package/dist/server/_coffre/assets/auth.device-CJwZYYtn.js +29 -0
- package/dist/server/_coffre/assets/coffre-1hxT2E_U.js +278 -0
- package/dist/server/_coffre/assets/directory-wm_JQUfk.js +396 -0
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +5 -0
- package/dist/server/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/server/_coffre/assets/grants-BmhEY1vz.js +243 -0
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/login-B5O5LPXV.js +100 -0
- package/dist/server/_coffre/assets/login-Bvc4gp0X.js +22 -0
- package/dist/server/_coffre/assets/offboarding-CvSilnSm.js +330 -0
- package/dist/server/_coffre/assets/page-BjXk0Ehu.js +2003 -0
- package/dist/server/_coffre/assets/principal-page-DkwNGzM2.js +617 -0
- package/dist/server/_coffre/assets/project-environments-lEzFHUt4.js +9 -0
- package/dist/server/_coffre/assets/projects._project._environment-7grhqlgq.js +2227 -0
- package/dist/server/_coffre/assets/projects._project._environment-ByEf6pmz.js +55 -0
- package/dist/server/_coffre/assets/projects._project.index-B1bjowP-.js +932 -0
- package/dist/server/_coffre/assets/projects._project.index-DU8wtoHD.js +22 -0
- package/dist/server/_coffre/assets/projects.index-B0DoHbCz.js +280 -0
- package/dist/server/_coffre/assets/projects.index-kMDA6pMy.js +54 -0
- package/dist/server/_coffre/assets/react-dom-qCTiwGGR.js +1352 -0
- package/dist/server/_coffre/assets/router-ChU_CwCX.js +2028 -0
- package/dist/server/_coffre/assets/settings-CM9-h7in.js +18 -0
- package/dist/server/_coffre/assets/settings-Cg5qOGij.js +60 -0
- package/dist/server/_coffre/assets/signin-errors-BEFlVDbQ.js +28 -0
- package/dist/server/_coffre/assets/start-DR3rN0St.js +4 -0
- package/dist/server/_coffre/assets/tokens._token-CCpaPMAk.js +268 -0
- package/dist/server/_coffre/assets/tokens._token-Di4OZdAA.js +18 -0
- package/dist/server/_coffre/assets/tokens.index-Do3OHR31.js +34 -0
- package/dist/server/_coffre/assets/tokens.index-tDKq4AFh.js +10 -0
- package/dist/server/_coffre/assets/ui-BNzhIAQP.js +15710 -0
- package/dist/server/_coffre/assets/unregistered-BqaWYFJK.js +51 -0
- package/dist/server/_coffre/assets/use-action-BkJXC5JM.js +953 -0
- package/dist/server/_coffre/assets/useStore-DWGPqzXR.js +892 -0
- package/dist/server/_coffre/assets/users._user-BenYva93.js +15 -0
- package/dist/server/_coffre/assets/users._user-Cp039Va-.js +10 -0
- package/dist/server/_coffre/assets/users.index-BrzG1Ecq.js +10 -0
- package/dist/server/_coffre/assets/users.index-DQ_45DQl.js +34 -0
- package/dist/server/_coffre/assets/validation-BQtqPe2V.js +27 -0
- package/dist/server/index.js +13910 -0
- package/package.json +58 -5
- package/src/components/affordances.ts +80 -0
- package/src/components/agentation.tsx +34 -0
- package/src/components/command-palette.tsx +271 -0
- package/src/components/directory.tsx +448 -0
- package/src/components/grants.tsx +204 -0
- package/src/components/icons.tsx +283 -0
- package/src/components/offboarding.tsx +286 -0
- package/src/components/page.tsx +128 -0
- package/src/components/principal-page.tsx +549 -0
- package/src/components/principal-picker.tsx +168 -0
- package/src/components/principal.tsx +53 -0
- package/src/components/route-states.tsx +60 -0
- package/src/components/service-tokens.tsx +212 -0
- package/src/components/shell.tsx +641 -0
- package/src/components/syncs.tsx +581 -0
- package/src/components/theme.tsx +141 -0
- package/src/components/tile.tsx +22 -0
- package/src/components/ui.tsx +440 -0
- package/src/entry.ts +19 -0
- package/src/lib/access-plan.ts +201 -0
- package/src/lib/audit-sentences.ts +468 -0
- package/src/lib/capabilities.ts +45 -0
- package/src/lib/coffre.ts +57 -0
- package/src/lib/project-access.ts +95 -0
- package/src/lib/project-environments.ts +23 -0
- package/src/lib/reveal.ts +21 -0
- package/src/lib/secret-edit-batch.ts +181 -0
- package/src/lib/signin-errors.ts +33 -0
- package/src/lib/use-action.ts +50 -0
- package/src/lib/validation.ts +27 -0
- package/src/routeTree.gen.ts +367 -0
- package/src/router.tsx +84 -0
- package/src/routes/__root.tsx +192 -0
- package/src/routes/access.tsx +11 -0
- package/src/routes/account.tsx +359 -0
- package/src/routes/audit.tsx +545 -0
- package/src/routes/auth.device.tsx +200 -0
- package/src/routes/index.tsx +15 -0
- package/src/routes/login.tsx +129 -0
- package/src/routes/projects.$project.$environment.tsx +1659 -0
- package/src/routes/projects.$project.index.tsx +917 -0
- package/src/routes/projects.index.tsx +353 -0
- package/src/routes/settings.tsx +72 -0
- package/src/routes/tokens.$token.tsx +35 -0
- package/src/routes/tokens.index.tsx +37 -0
- package/src/routes/unregistered.tsx +59 -0
- package/src/routes/users.$user.tsx +13 -0
- package/src/routes/users.index.tsx +37 -0
- package/src/shared/models.ts +55 -0
- package/src/styles/globals.css +4118 -0
- package/src/types.ts +21 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
import { C as require_react, E as __toESM, i as useRouter, o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
|
|
2
|
+
import { E as Link, a as ErrorLine, c as Spinner, i as EmptyState, o as Modal, s as Notice } from "./ui-BNzhIAQP.js";
|
|
3
|
+
import { $ as Users, C as Key, I as Pencil, a as Tile, et as X, i as PageHeader, m as Clock, n as ClosedDoor, tt as useLoaderData, v as Folder } from "./page-BjXk0Ehu.js";
|
|
4
|
+
import { i as statusOf, o as uiResult, r as memberRef, s as useCoffre } from "./coffre-1hxT2E_U.js";
|
|
5
|
+
import { r as toast, t as useAction } from "./use-action-BkJXC5JM.js";
|
|
6
|
+
import { a as PrincipalActions, i as KIND, r as InstanceRole, s as PrincipalAvatar } from "./directory-wm_JQUfk.js";
|
|
7
|
+
import { i as loadProject, n as GrantsTable, o as projectAccessLabel, t as GrantRowView } from "./grants-BmhEY1vz.js";
|
|
8
|
+
import { r as RemovedNotice, t as PrincipalReportCards } from "./offboarding-CvSilnSm.js";
|
|
9
|
+
//#region src/lib/access-plan.ts
|
|
10
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
11
|
+
/** An environment's access in a plan; slugs like `constructor` are not inherited. */
|
|
12
|
+
function environmentAccess(plan, slug) {
|
|
13
|
+
return Object.hasOwn(plan.environments, slug) ? plan.environments[slug] : null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Read what a principal holds on a project back into the editor's terms.
|
|
17
|
+
* `environments` are the ones the editor can set: live, and not archived.
|
|
18
|
+
*/
|
|
19
|
+
function planFromGrants(grants, environments) {
|
|
20
|
+
if (grants.length === 0) return {
|
|
21
|
+
level: "none",
|
|
22
|
+
expiresAt: null,
|
|
23
|
+
environments: {}
|
|
24
|
+
};
|
|
25
|
+
const [only] = grants;
|
|
26
|
+
if (grants.length === 1 && only.environmentSlug === null && (only.role === "owner" || only.role === "viewer" || only.role === "developer")) return {
|
|
27
|
+
level: only.role,
|
|
28
|
+
expiresAt: only.expiresAt,
|
|
29
|
+
environments: {}
|
|
30
|
+
};
|
|
31
|
+
const perEnvironment = {};
|
|
32
|
+
for (const grant of grants) {
|
|
33
|
+
const slug = grant.environmentSlug;
|
|
34
|
+
if (slug === null || !environments.includes(slug) || Object.hasOwn(perEnvironment, slug) || grant.role !== "viewer" && grant.role !== "developer") return {
|
|
35
|
+
level: "custom",
|
|
36
|
+
expiresAt: null,
|
|
37
|
+
environments: {}
|
|
38
|
+
};
|
|
39
|
+
perEnvironment[slug] = {
|
|
40
|
+
role: grant.role,
|
|
41
|
+
expiresAt: grant.expiresAt
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
level: "env",
|
|
46
|
+
expiresAt: null,
|
|
47
|
+
environments: perEnvironment
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Switch a plan's level. Going from read or write everywhere to per
|
|
52
|
+
* environment starts every environment at that level and expiry, so the
|
|
53
|
+
* switch alone keeps the same reach.
|
|
54
|
+
*/
|
|
55
|
+
function withLevel(plan, level, environments) {
|
|
56
|
+
if (level === "env" && (plan.level === "viewer" || plan.level === "developer") && Object.keys(plan.environments).length === 0) {
|
|
57
|
+
const access = {
|
|
58
|
+
role: plan.level,
|
|
59
|
+
expiresAt: plan.expiresAt
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
...plan,
|
|
63
|
+
level,
|
|
64
|
+
environments: Object.fromEntries(environments.map((slug) => [slug, access]))
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...plan,
|
|
69
|
+
level
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Set one environment's access, or take it away with `null`. */
|
|
73
|
+
function withEnvironment(plan, slug, access) {
|
|
74
|
+
const environments = { ...plan.environments };
|
|
75
|
+
if (access === null) delete environments[slug];
|
|
76
|
+
else environments[slug] = access;
|
|
77
|
+
return {
|
|
78
|
+
...plan,
|
|
79
|
+
environments
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function grantsFor(plan) {
|
|
83
|
+
switch (plan.level) {
|
|
84
|
+
case "none":
|
|
85
|
+
case "custom": return [];
|
|
86
|
+
case "owner":
|
|
87
|
+
case "viewer":
|
|
88
|
+
case "developer": return [{
|
|
89
|
+
role: plan.level,
|
|
90
|
+
environmentSlug: null,
|
|
91
|
+
expiresAt: plan.expiresAt
|
|
92
|
+
}];
|
|
93
|
+
case "env": return Object.entries(plan.environments).map(([environmentSlug, access]) => ({
|
|
94
|
+
environmentSlug,
|
|
95
|
+
...access
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** The server and the date field spell the same instant differently. */
|
|
100
|
+
function sameExpiry(a, b) {
|
|
101
|
+
return a === b || a !== null && b !== null && Date.parse(a) === Date.parse(b);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The changes that take what is held to the plan: grants to create, grants
|
|
105
|
+
* whose expiry moves, and grants to revoke, in that order. Asking for what is
|
|
106
|
+
* already held yields nothing, so applying the same plan twice is a no-op.
|
|
107
|
+
*/
|
|
108
|
+
function accessChanges(grants, plan) {
|
|
109
|
+
if (plan.level === "custom") return [];
|
|
110
|
+
const key = (grant) => `${grant.role}@${grant.environmentSlug ?? ""}`;
|
|
111
|
+
const wanted = new Map(grantsFor(plan).map((grant) => [key(grant), grant]));
|
|
112
|
+
const held = new Map(grants.map((grant) => [key(grant), grant]));
|
|
113
|
+
const changes = [];
|
|
114
|
+
for (const [id, grant] of wanted) if (!held.has(id)) changes.push({
|
|
115
|
+
kind: "create",
|
|
116
|
+
...grant
|
|
117
|
+
});
|
|
118
|
+
for (const [id, grant] of held) {
|
|
119
|
+
const want = wanted.get(id);
|
|
120
|
+
if (want !== void 0 && !sameExpiry(grant.expiresAt, want.expiresAt)) changes.push({
|
|
121
|
+
kind: "expiry",
|
|
122
|
+
grant,
|
|
123
|
+
expiresAt: want.expiresAt
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
for (const [id, grant] of held) if (!wanted.has(id)) changes.push({
|
|
127
|
+
kind: "revoke",
|
|
128
|
+
grant
|
|
129
|
+
});
|
|
130
|
+
return changes;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The changes as the API's access patch for one project: each place it
|
|
134
|
+
* touches, and the role to hold there until when, or `null` for none.
|
|
135
|
+
*
|
|
136
|
+
* { "market": null, "market/dev": { "role": "developer", "until": "2026-12-31T23:59:59.000Z" } }
|
|
137
|
+
*
|
|
138
|
+
* A place holds one role, so where a level changes, the revoke of the old
|
|
139
|
+
* role and the create of the new land on the same place, and the new role
|
|
140
|
+
* wins: the server replaces one with the other, never passing through none.
|
|
141
|
+
*/
|
|
142
|
+
function accessPatch(project, changes) {
|
|
143
|
+
const place = (environmentSlug) => environmentSlug === null ? project : `${project}/${environmentSlug}`;
|
|
144
|
+
const holding = (role, expiresAt) => expiresAt === null ? role : {
|
|
145
|
+
role,
|
|
146
|
+
until: expiresAt
|
|
147
|
+
};
|
|
148
|
+
const patch = {};
|
|
149
|
+
for (const change of changes) if (change.kind === "revoke") patch[place(change.grant.environmentSlug)] = null;
|
|
150
|
+
for (const change of changes) {
|
|
151
|
+
if (change.kind === "expiry") patch[place(change.grant.environmentSlug)] = holding(change.grant.role, change.expiresAt);
|
|
152
|
+
if (change.kind === "create") patch[place(change.environmentSlug)] = holding(change.role, change.expiresAt);
|
|
153
|
+
}
|
|
154
|
+
return patch;
|
|
155
|
+
}
|
|
156
|
+
/** A date field's value as the instant access ends: the close of that day, UTC. */
|
|
157
|
+
function expiryFromDate(date) {
|
|
158
|
+
return date === "" ? null : (/* @__PURE__ */ new Date(`${date}T23:59:59Z`)).toISOString();
|
|
159
|
+
}
|
|
160
|
+
/** A date field's value for an expiry. Expiries are shown as UTC dates everywhere. */
|
|
161
|
+
function dateFromExpiry(expiresAt) {
|
|
162
|
+
return expiresAt === null ? "" : expiresAt.slice(0, 10);
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/components/principal-page.tsx
|
|
166
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
167
|
+
/**
|
|
168
|
+
* Everything one user's or token's page shows: who it is to the instance and
|
|
169
|
+
* what it has seen (owners only), and its grants on every project where you
|
|
170
|
+
* manage access.
|
|
171
|
+
*
|
|
172
|
+
* There is no "grants of this principal" call, so this asks each project you
|
|
173
|
+
* manage for its grants and keeps this principal's. Projects where you do not
|
|
174
|
+
* hold grant.manage are skipped rather than asked: the refusal would land in
|
|
175
|
+
* the audit log as a denial in your name. The report is only asked for
|
|
176
|
+
* instance owners, for the same reason.
|
|
177
|
+
*/
|
|
178
|
+
async function loadPrincipalPage(client, principalType, principalId, root) {
|
|
179
|
+
const managed = (root?.projects ?? []).filter((project) => project.permissions.includes("grant.manage"));
|
|
180
|
+
const [report, details] = await Promise.all([root?.capabilities.canManageGrants ? uiResult(async () => {
|
|
181
|
+
try {
|
|
182
|
+
return { report: await client.members.get(memberRef(principalType, principalId)) };
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if (statusOf(error) === 404) return { report: null };
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}) : Promise.resolve(null), Promise.all(managed.map((project) => loadProject(client, project.slug)))]);
|
|
188
|
+
return {
|
|
189
|
+
report,
|
|
190
|
+
access: details.flatMap((result) => result.ok ? [{
|
|
191
|
+
project: result.project,
|
|
192
|
+
grants: result.grants.filter((grant) => grant.principalType === principalType && grant.principalId === principalId),
|
|
193
|
+
grantsError: result.grantsError
|
|
194
|
+
}] : [])
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function PrincipalPage({ principalType, principalId, data }) {
|
|
198
|
+
const router = useRouter();
|
|
199
|
+
const { instanceRole } = useLoaderData({ from: "__root__" });
|
|
200
|
+
const { report, access } = data;
|
|
201
|
+
const kind = KIND[principalType];
|
|
202
|
+
const people = principalType === "user";
|
|
203
|
+
const list = people ? "/users" : "/tokens";
|
|
204
|
+
const found = report?.ok === true ? report.report : null;
|
|
205
|
+
const removed = found?.status === "removed";
|
|
206
|
+
const entry = found !== null && !removed ? {
|
|
207
|
+
principalType,
|
|
208
|
+
principalId,
|
|
209
|
+
instanceRole: found.instanceRole,
|
|
210
|
+
isRootAdmin: found.isRootAdmin,
|
|
211
|
+
tampered: found.status === "tampered"
|
|
212
|
+
} : void 0;
|
|
213
|
+
if (report?.ok === true && found === null || report === null && access.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClosedDoor, {
|
|
214
|
+
icon: people ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Users, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Key, { size: 18 }),
|
|
215
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
216
|
+
className: "mono",
|
|
217
|
+
children: principalId
|
|
218
|
+
}),
|
|
219
|
+
title: people ? "No such user for you" : "No such token for you",
|
|
220
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
|
|
221
|
+
className: "btn",
|
|
222
|
+
to: list,
|
|
223
|
+
children: ["All ", people ? "users" : "tokens"]
|
|
224
|
+
}),
|
|
225
|
+
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
|
+
});
|
|
227
|
+
const rows = access.flatMap(({ project, grants }) => grants.map((grant) => ({
|
|
228
|
+
project,
|
|
229
|
+
grant
|
|
230
|
+
})));
|
|
231
|
+
const errors = access.filter((entry) => entry.grantsError !== null);
|
|
232
|
+
const editable = removed ? [] : access.filter(({ project, grantsError }) => project.archivedAt === null && grantsError === null);
|
|
233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
234
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
|
|
235
|
+
lead: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalAvatar, {
|
|
236
|
+
type: principalType,
|
|
237
|
+
id: principalId,
|
|
238
|
+
size: "lg"
|
|
239
|
+
}),
|
|
240
|
+
title: principalId,
|
|
241
|
+
meta: removed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
242
|
+
className: "tag tag-red",
|
|
243
|
+
children: "Removed"
|
|
244
|
+
}) : entry?.principalType === "user" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InstanceRole, { principal: entry }),
|
|
245
|
+
actions: (editable.length > 0 || entry !== void 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [editable.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditAccess, {
|
|
246
|
+
principalType,
|
|
247
|
+
principalId,
|
|
248
|
+
access: editable
|
|
249
|
+
}), entry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalActions, {
|
|
250
|
+
principal: entry,
|
|
251
|
+
trigger: "btn btn-icon",
|
|
252
|
+
onRemoved: () => router.invalidate()
|
|
253
|
+
})] })
|
|
254
|
+
}),
|
|
255
|
+
report?.ok === false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
256
|
+
className: "report-notice",
|
|
257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Notice, {
|
|
258
|
+
tone: "bad",
|
|
259
|
+
children: report.error
|
|
260
|
+
})
|
|
261
|
+
}),
|
|
262
|
+
removed && found !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RemovedNotice, { report: found }),
|
|
263
|
+
!removed && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
264
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
|
|
265
|
+
className: "section-title",
|
|
266
|
+
children: "Project access"
|
|
267
|
+
}),
|
|
268
|
+
errors.map(({ project, grantsError }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
269
|
+
style: { marginBottom: "0.75rem" },
|
|
270
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Notice, {
|
|
271
|
+
tone: "bad",
|
|
272
|
+
children: [
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
274
|
+
className: "mono",
|
|
275
|
+
children: project.slug
|
|
276
|
+
}),
|
|
277
|
+
": ",
|
|
278
|
+
grantsError
|
|
279
|
+
]
|
|
280
|
+
})
|
|
281
|
+
}, project.slug)),
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", {
|
|
283
|
+
className: "card",
|
|
284
|
+
"aria-label": "Project access",
|
|
285
|
+
children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, {
|
|
286
|
+
title: "No project access yet",
|
|
287
|
+
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}.`
|
|
288
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GrantsTable, {
|
|
289
|
+
lead: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
290
|
+
className: "th",
|
|
291
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Folder, { size: 14 }), "Project"]
|
|
292
|
+
}),
|
|
293
|
+
children: rows.map(({ project, grant }, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GrantRowView, {
|
|
294
|
+
number: index + 1,
|
|
295
|
+
project: project.slug,
|
|
296
|
+
grant,
|
|
297
|
+
leadLabel: "Project",
|
|
298
|
+
lead: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
299
|
+
className: "cell-project",
|
|
300
|
+
children: [
|
|
301
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tile, { name: project.slug }),
|
|
302
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
|
|
303
|
+
className: "cell-link",
|
|
304
|
+
to: "/projects/$project",
|
|
305
|
+
params: { project: project.slug },
|
|
306
|
+
search: { tab: people ? "users" : "tokens" },
|
|
307
|
+
children: project.name
|
|
308
|
+
}),
|
|
309
|
+
project.archivedAt !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
310
|
+
className: "tag tag-red",
|
|
311
|
+
children: "archived"
|
|
312
|
+
})
|
|
313
|
+
]
|
|
314
|
+
})
|
|
315
|
+
}, grant.id))
|
|
316
|
+
})
|
|
317
|
+
}),
|
|
318
|
+
instanceRole !== "root-admin" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
319
|
+
className: "hint section-foot",
|
|
320
|
+
children: "Only projects where you manage access are listed."
|
|
321
|
+
})
|
|
322
|
+
] }),
|
|
323
|
+
found !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalReportCards, { report: found })
|
|
324
|
+
] });
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* One principal's access to every project you manage, edited in one place.
|
|
328
|
+
*
|
|
329
|
+
* Each project opens set to what the principal holds: a project-wide level,
|
|
330
|
+
* or read or write per environment, each with its own expiry. Saving sends
|
|
331
|
+
* only the difference, every project in one `access.set`: the server applies
|
|
332
|
+
* all of it in one transaction, or none of it.
|
|
333
|
+
*/
|
|
334
|
+
function EditAccess({ principalType, principalId, access }) {
|
|
335
|
+
const coffre = useCoffre();
|
|
336
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
337
|
+
const [edits, setEdits] = (0, import_react.useState)({});
|
|
338
|
+
const { pending, error, setError, run } = useAction();
|
|
339
|
+
const kind = KIND[principalType];
|
|
340
|
+
const rows = access.map(({ project, grants }) => {
|
|
341
|
+
const environments = project.environments.filter((environment) => environment.details !== null && environment.details.archivedAt === null).map((environment) => environment.slug);
|
|
342
|
+
const held = planFromGrants(grants, environments);
|
|
343
|
+
const plan = Object.hasOwn(edits, project.slug) ? edits[project.slug] : held;
|
|
344
|
+
return {
|
|
345
|
+
project,
|
|
346
|
+
grants,
|
|
347
|
+
environments,
|
|
348
|
+
held,
|
|
349
|
+
plan,
|
|
350
|
+
changes: accessChanges(grants, plan)
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
const changed = rows.filter((row) => row.changes.length > 0);
|
|
354
|
+
function close() {
|
|
355
|
+
setOpen(false);
|
|
356
|
+
setEdits({});
|
|
357
|
+
setError(null);
|
|
358
|
+
}
|
|
359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
360
|
+
className: "btn btn-primary",
|
|
361
|
+
onClick: () => setOpen(true),
|
|
362
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pencil, { size: 14 }), "Edit access"]
|
|
363
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Modal, {
|
|
364
|
+
open,
|
|
365
|
+
onOpenChange: (next) => next ? setOpen(true) : close(),
|
|
366
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["Edit access for ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
367
|
+
className: "mono",
|
|
368
|
+
children: principalId
|
|
369
|
+
})] }),
|
|
370
|
+
description: `Set what this ${kind} can reach on each project you manage, and until when. Saving applies only what you changed.`,
|
|
371
|
+
wide: true,
|
|
372
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
|
|
373
|
+
className: "form",
|
|
374
|
+
onSubmit: (event) => {
|
|
375
|
+
event.preventDefault();
|
|
376
|
+
run(() => coffre.access.set(memberRef(principalType, principalId), Object.assign({}, ...changed.map(({ project, changes }) => accessPatch(project.slug, changes)))), () => {
|
|
377
|
+
toast.success(`Updated ${principalId}’s access on ${changed.length} project${changed.length === 1 ? "" : "s"}`);
|
|
378
|
+
close();
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", {
|
|
383
|
+
className: "plan-list",
|
|
384
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
|
|
385
|
+
className: "plan-head",
|
|
386
|
+
"aria-hidden": "true",
|
|
387
|
+
children: [
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Project" }),
|
|
389
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Access" }),
|
|
390
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Expires" })
|
|
391
|
+
]
|
|
392
|
+
}), rows.map(({ project, grants, environments, held, plan, changes }) => {
|
|
393
|
+
const id = `plan-${project.slug}`;
|
|
394
|
+
const edit = (next) => setEdits((current) => ({
|
|
395
|
+
...current,
|
|
396
|
+
[project.slug]: next
|
|
397
|
+
}));
|
|
398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
|
|
399
|
+
className: `plan-row${changes.length > 0 ? " is-changed" : ""}`,
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
402
|
+
className: "plan-project",
|
|
403
|
+
htmlFor: id,
|
|
404
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tile, { name: project.slug }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
405
|
+
className: "plan-project-text",
|
|
406
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
407
|
+
className: "plan-project-name",
|
|
408
|
+
children: project.name
|
|
409
|
+
}), held.level === "custom" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
410
|
+
className: "plan-project-held",
|
|
411
|
+
children: ["Holds ", grants.map((grant) => projectAccessLabel(grant)).join(", ")]
|
|
412
|
+
})]
|
|
413
|
+
})]
|
|
414
|
+
}),
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
|
|
416
|
+
id,
|
|
417
|
+
className: "select select-sm",
|
|
418
|
+
value: plan.level,
|
|
419
|
+
onChange: (event) => edit(withLevel(plan, event.target.value, environments)),
|
|
420
|
+
children: [
|
|
421
|
+
held.level === "custom" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
422
|
+
value: "custom",
|
|
423
|
+
children: "Keep as is"
|
|
424
|
+
}),
|
|
425
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
426
|
+
value: "none",
|
|
427
|
+
children: "No access"
|
|
428
|
+
}),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
430
|
+
value: "owner",
|
|
431
|
+
children: "Owner"
|
|
432
|
+
}),
|
|
433
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
434
|
+
value: "viewer",
|
|
435
|
+
children: "Read: all"
|
|
436
|
+
}),
|
|
437
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
438
|
+
value: "developer",
|
|
439
|
+
children: "Write: all"
|
|
440
|
+
}),
|
|
441
|
+
environments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
442
|
+
value: "env",
|
|
443
|
+
children: "Per environment…"
|
|
444
|
+
})
|
|
445
|
+
]
|
|
446
|
+
}),
|
|
447
|
+
(plan.level === "owner" || plan.level === "viewer" || plan.level === "developer") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpiryField, {
|
|
448
|
+
label: `${project.name} expires`,
|
|
449
|
+
expiresAt: plan.expiresAt,
|
|
450
|
+
onChange: (expiresAt) => edit({
|
|
451
|
+
...plan,
|
|
452
|
+
expiresAt
|
|
453
|
+
})
|
|
454
|
+
}),
|
|
455
|
+
plan.level === "env" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
456
|
+
className: "plan-envs",
|
|
457
|
+
"aria-label": `Environments of ${project.name}`,
|
|
458
|
+
children: environments.map((slug) => {
|
|
459
|
+
const current = environmentAccess(plan, slug);
|
|
460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
|
|
461
|
+
className: "plan-env",
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
|
|
464
|
+
className: "mono",
|
|
465
|
+
htmlFor: `${id}-${slug}`,
|
|
466
|
+
children: slug
|
|
467
|
+
}),
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
|
|
469
|
+
id: `${id}-${slug}`,
|
|
470
|
+
className: "select select-sm",
|
|
471
|
+
value: current?.role ?? "",
|
|
472
|
+
onChange: (event) => {
|
|
473
|
+
const role = event.target.value;
|
|
474
|
+
edit(withEnvironment(plan, slug, role === "viewer" || role === "developer" ? {
|
|
475
|
+
role,
|
|
476
|
+
expiresAt: current?.expiresAt ?? null
|
|
477
|
+
} : null));
|
|
478
|
+
},
|
|
479
|
+
children: [
|
|
480
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
481
|
+
value: "",
|
|
482
|
+
children: "No access"
|
|
483
|
+
}),
|
|
484
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
485
|
+
value: "viewer",
|
|
486
|
+
children: "Read"
|
|
487
|
+
}),
|
|
488
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
489
|
+
value: "developer",
|
|
490
|
+
children: "Write"
|
|
491
|
+
})
|
|
492
|
+
]
|
|
493
|
+
}),
|
|
494
|
+
current !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpiryField, {
|
|
495
|
+
label: `${slug} of ${project.name} expires`,
|
|
496
|
+
expiresAt: current.expiresAt,
|
|
497
|
+
onChange: (expiresAt) => edit(withEnvironment(plan, slug, {
|
|
498
|
+
...current,
|
|
499
|
+
expiresAt
|
|
500
|
+
}))
|
|
501
|
+
})
|
|
502
|
+
]
|
|
503
|
+
}, slug);
|
|
504
|
+
})
|
|
505
|
+
}),
|
|
506
|
+
changes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
507
|
+
className: "plan-changes",
|
|
508
|
+
"aria-label": `Changes to ${project.name}`,
|
|
509
|
+
children: changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccessChangeTag, { change }) }, change.kind === "create" ? `+${change.role}@${change.environmentSlug ?? ""}` : change.grant.id))
|
|
510
|
+
})
|
|
511
|
+
]
|
|
512
|
+
}, project.slug);
|
|
513
|
+
})]
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
517
|
+
className: "dialog-actions",
|
|
518
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
519
|
+
className: "btn",
|
|
520
|
+
type: "button",
|
|
521
|
+
onClick: close,
|
|
522
|
+
children: "Cancel"
|
|
523
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
524
|
+
className: "btn btn-primary",
|
|
525
|
+
type: "submit",
|
|
526
|
+
disabled: pending || changed.length === 0,
|
|
527
|
+
children: [pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Save changes"]
|
|
528
|
+
})]
|
|
529
|
+
})
|
|
530
|
+
]
|
|
531
|
+
})
|
|
532
|
+
})] });
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* When one grant ends, as a date: access lasts through that day, UTC. Blank
|
|
536
|
+
* reads "Never" where the browser lets the empty field be restyled.
|
|
537
|
+
*/
|
|
538
|
+
function ExpiryField({ label, expiresAt, onChange }) {
|
|
539
|
+
const date = dateFromExpiry(expiresAt);
|
|
540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
541
|
+
className: `expiry${date === "" ? " is-never" : ""}`,
|
|
542
|
+
children: [
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
544
|
+
className: "input select-sm",
|
|
545
|
+
type: "date",
|
|
546
|
+
"aria-label": label,
|
|
547
|
+
min: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
548
|
+
value: date,
|
|
549
|
+
onChange: (event) => onChange(expiryFromDate(event.target.value))
|
|
550
|
+
}),
|
|
551
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
552
|
+
className: "expiry-never",
|
|
553
|
+
"aria-hidden": "true",
|
|
554
|
+
children: "Never"
|
|
555
|
+
}),
|
|
556
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
557
|
+
className: "btn btn-quiet btn-sm btn-icon",
|
|
558
|
+
type: "button",
|
|
559
|
+
"aria-label": `${label}: never`,
|
|
560
|
+
title: "Never expires",
|
|
561
|
+
onClick: () => onChange(null),
|
|
562
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(X, { size: 12 })
|
|
563
|
+
})
|
|
564
|
+
]
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function AccessChangeTag({ change }) {
|
|
568
|
+
const until = (expiresAt) => expiresAt === null ? "" : ` until ${dateFromExpiry(expiresAt)}`;
|
|
569
|
+
switch (change.kind) {
|
|
570
|
+
case "create": return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
571
|
+
className: "tag tag-green",
|
|
572
|
+
children: [
|
|
573
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
574
|
+
"aria-hidden": "true",
|
|
575
|
+
children: "+"
|
|
576
|
+
}),
|
|
577
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
578
|
+
className: "visually-hidden",
|
|
579
|
+
children: "Adds"
|
|
580
|
+
}),
|
|
581
|
+
projectAccessLabel({
|
|
582
|
+
...change,
|
|
583
|
+
roleName: change.role
|
|
584
|
+
}),
|
|
585
|
+
until(change.expiresAt)
|
|
586
|
+
]
|
|
587
|
+
});
|
|
588
|
+
case "expiry": return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
589
|
+
className: "tag tag-blue",
|
|
590
|
+
children: [
|
|
591
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Clock, { size: 12 }),
|
|
592
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
593
|
+
className: "visually-hidden",
|
|
594
|
+
children: "Moves the expiry of"
|
|
595
|
+
}),
|
|
596
|
+
projectAccessLabel(change.grant),
|
|
597
|
+
change.expiresAt === null ? ", no expiry" : until(change.expiresAt)
|
|
598
|
+
]
|
|
599
|
+
});
|
|
600
|
+
case "revoke": return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
601
|
+
className: "tag tag-red",
|
|
602
|
+
children: [
|
|
603
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
604
|
+
"aria-hidden": "true",
|
|
605
|
+
children: "−"
|
|
606
|
+
}),
|
|
607
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
608
|
+
className: "visually-hidden",
|
|
609
|
+
children: "Removes"
|
|
610
|
+
}),
|
|
611
|
+
projectAccessLabel(change.grant)
|
|
612
|
+
]
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
617
|
+
export { loadPrincipalPage as n, PrincipalPage as t };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/lib/project-environments.ts
|
|
2
|
+
function hasEnvironmentDetails(environment) {
|
|
3
|
+
return environment.details !== null;
|
|
4
|
+
}
|
|
5
|
+
function isActiveAccessibleEnvironment(environment) {
|
|
6
|
+
return environment.accessible && environment.details !== null && environment.details.archivedAt === null;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { isActiveAccessibleEnvironment as n, hasEnvironmentDetails as t };
|