@coffre/ui 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{audit-sentence-JrQIUq6j.js → audit-sentence-DpYySuqg.js} +74 -7
- package/dist/chunks/audit-sentence-DpYySuqg.js.map +1 -0
- package/dist/chunks/{connected-apps-Dr8UgjK7.js → connected-apps-D48SFJsG.js} +4 -4
- package/dist/chunks/{connected-apps-Dr8UgjK7.js.map → connected-apps-D48SFJsG.js.map} +1 -1
- package/dist/chunks/{delete-place-CQCDHkne.js → delete-place-Cg_M6rAq.js} +4 -4
- package/dist/chunks/{delete-place-CQCDHkne.js.map → delete-place-Cg_M6rAq.js.map} +1 -1
- package/dist/chunks/{directory-XcSbDRJv.js → directory-_LTgdiIM.js} +11 -9
- package/dist/chunks/directory-_LTgdiIM.js.map +1 -0
- package/dist/chunks/{folders-Dw240WMJ.js → folders-D3A1NGpt.js} +2 -2
- package/dist/chunks/{folders-Dw240WMJ.js.map → folders-D3A1NGpt.js.map} +1 -1
- package/dist/chunks/{grants-CmdZjKYU.js → grants-CNM913EY.js} +6 -6
- package/dist/chunks/{grants-CmdZjKYU.js.map → grants-CNM913EY.js.map} +1 -1
- package/dist/chunks/{multi-combobox-CsIXihuc.js → multi-combobox-B0JzP1QN.js} +2 -2
- package/dist/chunks/{multi-combobox-CsIXihuc.js.map → multi-combobox-B0JzP1QN.js.map} +1 -1
- package/dist/chunks/{offboarding-CrgwaetA.js → offboarding-BeaNM3sf.js} +3 -3
- package/dist/chunks/{offboarding-CrgwaetA.js.map → offboarding-BeaNM3sf.js.map} +1 -1
- package/dist/chunks/{personal-tokens-Dvl1FktE.js → personal-tokens-KsXajpx4.js} +4 -4
- package/dist/chunks/{personal-tokens-Dvl1FktE.js.map → personal-tokens-KsXajpx4.js.map} +1 -1
- package/dist/chunks/{principal-page-bOaEYWJB.js → principal-page-BaiZXh6D.js} +94 -78
- package/dist/chunks/principal-page-BaiZXh6D.js.map +1 -0
- package/dist/chunks/{project-page-BI--vjt3.js → project-page-CYZ_MkfX.js} +2 -2
- package/dist/chunks/{project-page-BI--vjt3.js.map → project-page-CYZ_MkfX.js.map} +1 -1
- package/dist/chunks/protected-BL_DsZO6.js +22 -0
- package/dist/chunks/protected-BL_DsZO6.js.map +1 -0
- package/dist/chunks/{queries-epz4MIuW.js → queries-Danu0o75.js} +99 -31
- package/dist/chunks/queries-Danu0o75.js.map +1 -0
- package/dist/chunks/{references-DImfw0cz.js → references-BK2aPXae.js} +4 -4
- package/dist/chunks/{references-DImfw0cz.js.map → references-BK2aPXae.js.map} +1 -1
- package/dist/chunks/{role-field-C1KhNaIR.js → role-field-DIJiRz9B.js} +8 -5
- package/dist/chunks/role-field-DIJiRz9B.js.map +1 -0
- package/dist/chunks/{row-state-BsIHspy4.js → row-state-xtRGFnDc.js} +2 -2
- package/dist/chunks/{row-state-BsIHspy4.js.map → row-state-xtRGFnDc.js.map} +1 -1
- package/dist/chunks/{theme-3b4DnCow.js → theme-Ck45wzWB.js} +2 -2
- package/dist/chunks/{theme-3b4DnCow.js.map → theme-Ck45wzWB.js.map} +1 -1
- package/dist/chunks/{ui-2kwXXfrX.js → ui-D-blFWfx.js} +29 -5
- package/dist/chunks/{ui-2kwXXfrX.js.map → ui-D-blFWfx.js.map} +1 -1
- package/dist/chunks/{use-action-BB-RcHo1.js → use-action-BafZVwux.js} +2 -2
- package/dist/chunks/{use-action-BB-RcHo1.js.map → use-action-BafZVwux.js.map} +1 -1
- package/dist/chunks/{use-change-BY6KPmnJ.js → use-change-DhV6i_Ge.js} +218 -101
- package/dist/chunks/use-change-DhV6i_Ge.js.map +1 -0
- package/dist/chunks/use-roles-Daje0ikO.js +224 -0
- package/dist/chunks/use-roles-Daje0ikO.js.map +1 -0
- package/dist/chunks/{use-shell-C_NmvCt_.js → use-shell-BX9mzfaL.js} +2 -2
- package/dist/chunks/{use-shell-C_NmvCt_.js.map → use-shell-BX9mzfaL.js.map} +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +29 -15
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +9 -9
- package/dist/pages/approval.js +1 -1
- package/dist/pages/audit.js +96 -34
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +1 -1
- package/dist/pages/environment.js +255 -115
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +2 -2
- package/dist/pages/oauth-authorize.js +1 -1
- package/dist/pages/project-access.js +79 -46
- package/dist/pages/project-access.js.map +1 -1
- package/dist/pages/project-environments.js +79 -30
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +7 -7
- package/dist/pages/project.js +2 -2
- package/dist/pages/projects.js +26 -14
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.js +22 -15
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +4 -4
- package/dist/pages/settings.js +580 -8
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +1 -1
- package/dist/pages/user.js +5 -5
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/directory.tsx +5 -2
- package/src/components/grants.tsx +1 -1
- package/src/components/principal-page.tsx +38 -23
- package/src/components/protected.tsx +17 -0
- package/src/components/role-editor.tsx +582 -0
- package/src/components/role-field.tsx +7 -3
- package/src/components/scope-picker.tsx +19 -9
- package/src/components/shell.tsx +7 -1
- package/src/components/ui.tsx +25 -2
- package/src/lib/access-plan.ts +35 -36
- package/src/lib/audit-sentences.ts +75 -9
- package/src/lib/changes.ts +46 -8
- package/src/lib/project-access.ts +4 -78
- package/src/lib/queries.ts +97 -29
- package/src/lib/roles.ts +201 -0
- package/src/lib/row-reads.ts +12 -0
- package/src/lib/secret-edit-batch.ts +147 -56
- package/src/lib/sensitivity.ts +50 -0
- package/src/lib/service-setup.ts +20 -8
- package/src/lib/use-roles.ts +17 -0
- package/src/options.ts +2 -3
- package/src/pages/audit.tsx +99 -26
- package/src/pages/environment.tsx +264 -101
- package/src/pages/project-access.tsx +49 -19
- package/src/pages/project-environments.tsx +62 -3
- package/src/pages/projects.tsx +3 -1
- package/src/pages/settings.tsx +2 -0
- package/src/parity.ts +42 -5
- package/src/shared/models.ts +2 -9
- package/src/styles/globals.css +322 -25
- package/dist/chunks/audit-sentence-JrQIUq6j.js.map +0 -1
- package/dist/chunks/directory-XcSbDRJv.js.map +0 -1
- package/dist/chunks/principal-page-bOaEYWJB.js.map +0 -1
- package/dist/chunks/queries-epz4MIuW.js.map +0 -1
- package/dist/chunks/role-field-C1KhNaIR.js.map +0 -1
- package/dist/chunks/use-change-BY6KPmnJ.js.map +0 -1
package/dist/pages/settings.js
CHANGED
|
@@ -1,15 +1,586 @@
|
|
|
1
|
-
import { t as affects,
|
|
2
|
-
import { a as ErrorLine, f as Toggletip, l as Spinner, s as Modal } from "../chunks/ui-
|
|
3
|
-
import { W as Pencil, i as PageHeader, j as Info, r as Fact, t as Card, u as useCoffre } from "../chunks/page-JTORvh-N.js";
|
|
4
|
-
import { t as useShell } from "../chunks/use-shell-
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { t as affects, x as queries } from "../chunks/queries-Danu0o75.js";
|
|
2
|
+
import { a as ErrorLine, c as Notice, f as Toggletip, l as Spinner, n as ConfirmDialog, s as Modal } from "../chunks/ui-D-blFWfx.js";
|
|
3
|
+
import { G as Plus, L as Lock, W as Pencil, _ as Check, i as PageHeader, j as Info, nt as Trash, q as RotateBack, r as Fact, t as Card, u as useCoffre } from "../chunks/page-JTORvh-N.js";
|
|
4
|
+
import { t as useShell } from "../chunks/use-shell-BX9mzfaL.js";
|
|
5
|
+
import { a as impactExamples, c as projectWide, d as roleIdProblem, i as columnInWords, m as toggle, n as GRID_PERMISSIONS, o as impactInWords, p as sameDefinition, r as PERMISSION_WORDS, s as ordered, u as roleIdFrom } from "../chunks/use-roles-Daje0ikO.js";
|
|
6
|
+
import { n as ScopeField } from "../chunks/role-field-DIJiRz9B.js";
|
|
7
|
+
import { t as useAction } from "../chunks/use-action-BafZVwux.js";
|
|
8
|
+
import { useId, useRef, useState } from "react";
|
|
8
9
|
import { Link } from "@tanstack/react-router";
|
|
9
10
|
import { toast } from "sonner";
|
|
10
|
-
import { scopeInWords, unscoped } from "@coffre/core/access";
|
|
11
|
+
import { definitionProblem, scopeInWords, unscoped } from "@coffre/core/access";
|
|
11
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
14
|
+
import { CoffreError } from "@coffre/client";
|
|
15
|
+
//#region src/components/role-editor.tsx
|
|
16
|
+
/** The instance's roles and instance roles, each a card of rows that open its editor. */
|
|
17
|
+
function RolesSettings() {
|
|
18
|
+
const { data } = useSuspenseQuery(queries.roles(useCoffre()));
|
|
19
|
+
if (!data.ok) return /* @__PURE__ */ jsx(Card, {
|
|
20
|
+
labelledBy: "roles",
|
|
21
|
+
title: "Roles",
|
|
22
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
23
|
+
className: "card-row",
|
|
24
|
+
children: /* @__PURE__ */ jsx(ErrorLine, { error: `The roles could not be read. ${data.error}` })
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RoleList, {
|
|
28
|
+
kind: "role",
|
|
29
|
+
roles: data.roles,
|
|
30
|
+
editable: data.editable
|
|
31
|
+
}), /* @__PURE__ */ jsx(RoleList, {
|
|
32
|
+
kind: "instance-role",
|
|
33
|
+
roles: data.instanceRoles,
|
|
34
|
+
editable: data.editable
|
|
35
|
+
})] });
|
|
36
|
+
}
|
|
37
|
+
function RoleList({ kind, roles, editable }) {
|
|
38
|
+
const [open, setOpen] = useState(null);
|
|
39
|
+
const project = kind === "role";
|
|
40
|
+
const opened = open === null || "making" in open ? null : roles.find((role) => role.id === open.role);
|
|
41
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
42
|
+
labelledBy: project ? "roles" : "instance-roles",
|
|
43
|
+
title: project ? "Roles" : "Instance roles",
|
|
44
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [project ? "What a grant gives, on a project or one of its environments. In a protected environment a person holds the second column; a service account always holds the first." : "What a person holds, by their instance role, in every project its scope takes in, before any grant adds to it.", !editable && " Only an Owner of the whole instance edits them."] }),
|
|
45
|
+
actions: project && editable && /* @__PURE__ */ jsxs("button", {
|
|
46
|
+
className: "btn",
|
|
47
|
+
type: "button",
|
|
48
|
+
onClick: () => setOpen({ making: true }),
|
|
49
|
+
children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "New role"]
|
|
50
|
+
}),
|
|
51
|
+
children: [/* @__PURE__ */ jsx("ul", {
|
|
52
|
+
className: "role-list",
|
|
53
|
+
"aria-label": project ? "Roles" : "Instance roles",
|
|
54
|
+
children: roles.map((role) => /* @__PURE__ */ jsxs("li", {
|
|
55
|
+
className: "card-row role-row",
|
|
56
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
57
|
+
className: "role-row-text",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsxs("p", {
|
|
60
|
+
className: "card-row-title role-row-title",
|
|
61
|
+
children: [role.name, /* @__PURE__ */ jsx(RoleBadges, { role })]
|
|
62
|
+
}),
|
|
63
|
+
role.description !== "" && /* @__PURE__ */ jsx("p", {
|
|
64
|
+
className: "card-row-desc",
|
|
65
|
+
children: role.description
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ jsxs("dl", {
|
|
68
|
+
className: "role-columns",
|
|
69
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "Holds" }), /* @__PURE__ */ jsx("dd", { children: columnInWords(role.permissions) })] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("dt", { children: [/* @__PURE__ */ jsx(Lock, { size: 12 }), "In protected environments"] }), /* @__PURE__ */ jsx("dd", { children: columnInWords(role.protected) })] })]
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
73
|
+
className: "role-row-side",
|
|
74
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
75
|
+
className: "role-row-count",
|
|
76
|
+
children: held(kind, role.grants)
|
|
77
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
78
|
+
className: "btn btn-sm",
|
|
79
|
+
type: "button",
|
|
80
|
+
"aria-label": `${editable && !role.fixed ? "Edit" : "View"} ${role.name}`,
|
|
81
|
+
onClick: () => setOpen({ role: role.id }),
|
|
82
|
+
children: [editable && !role.fixed && /* @__PURE__ */ jsx(Pencil, { size: 14 }), editable && !role.fixed ? "Edit…" : "View"]
|
|
83
|
+
})]
|
|
84
|
+
})]
|
|
85
|
+
}, role.id))
|
|
86
|
+
}), open !== null && opened !== void 0 && /* @__PURE__ */ jsx(RoleEditor, {
|
|
87
|
+
kind,
|
|
88
|
+
role: opened,
|
|
89
|
+
roles,
|
|
90
|
+
editable: editable && (opened === null || !opened.fixed),
|
|
91
|
+
onClose: () => setOpen(null)
|
|
92
|
+
}, "making" in open ? "" : `role:${open.role}`)]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** "3 grants", "1 person": who a role reaches now. */
|
|
96
|
+
function held(kind, count) {
|
|
97
|
+
if (kind === "instance-role") return count === 0 ? "Nobody" : count === 1 ? "1 person" : `${count} people`;
|
|
98
|
+
return count === 0 ? "No grants" : count === 1 ? "1 grant" : `${count} grants`;
|
|
99
|
+
}
|
|
100
|
+
/** Where a role comes from, and whether it is as it shipped. */
|
|
101
|
+
function RoleBadges({ role }) {
|
|
102
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
103
|
+
role.builtin ? /* @__PURE__ */ jsx("span", {
|
|
104
|
+
className: "tag tag-outline",
|
|
105
|
+
children: "Built-in"
|
|
106
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: "tag tag-blue",
|
|
108
|
+
children: "Custom"
|
|
109
|
+
}),
|
|
110
|
+
role.edited && /* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "tag tag-amber",
|
|
112
|
+
children: "Edited"
|
|
113
|
+
}),
|
|
114
|
+
role.fixed && /* @__PURE__ */ jsxs("span", {
|
|
115
|
+
className: "tag",
|
|
116
|
+
children: [/* @__PURE__ */ jsx(Lock, { size: 11 }), "Fixed"]
|
|
117
|
+
})
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* One role's editor, or a new one's: its name, description and grid, and
|
|
122
|
+
* Save, Reset to default for a built-in one edited, Delete for one an Owner
|
|
123
|
+
* made. Each asks the server what it would do first and says it, then does
|
|
124
|
+
* it once confirmed. Read-only to anyone who does not edit roles, and for
|
|
125
|
+
* Owner and Member, which hold everything and nothing, always.
|
|
126
|
+
*/
|
|
127
|
+
function RoleEditor({ kind, role, roles, editable, onClose }) {
|
|
128
|
+
const coffre = useCoffre();
|
|
129
|
+
const instance = kind === "instance-role";
|
|
130
|
+
const [draft, setDraft] = useState(() => role === null ? {
|
|
131
|
+
id: "",
|
|
132
|
+
name: "",
|
|
133
|
+
description: "",
|
|
134
|
+
permissions: [],
|
|
135
|
+
protected: []
|
|
136
|
+
} : {
|
|
137
|
+
id: role.id,
|
|
138
|
+
name: role.name,
|
|
139
|
+
description: role.description,
|
|
140
|
+
...ordered(role)
|
|
141
|
+
});
|
|
142
|
+
const [idTyped, setIdTyped] = useState(false);
|
|
143
|
+
const [pending, setPending] = useState(null);
|
|
144
|
+
const [asking, setAsking] = useState(false);
|
|
145
|
+
const weigh = useAction();
|
|
146
|
+
const apply = useAction();
|
|
147
|
+
const ids = {
|
|
148
|
+
name: useId(),
|
|
149
|
+
id: useId(),
|
|
150
|
+
description: useId(),
|
|
151
|
+
start: useId()
|
|
152
|
+
};
|
|
153
|
+
const made = role === null;
|
|
154
|
+
const label = role?.name ?? (draft.name.trim() || "New role");
|
|
155
|
+
const idError = made ? roleIdProblem(draft.id, roles.map((each) => each.id)) : null;
|
|
156
|
+
const definitionError = draft.name.trim() === "" ? "A role needs a name." : definitionProblem(draft);
|
|
157
|
+
const changed = role === null || !sameDefinition(draft, role);
|
|
158
|
+
const definition = {
|
|
159
|
+
name: draft.name.trim(),
|
|
160
|
+
description: draft.description,
|
|
161
|
+
permissions: draft.permissions,
|
|
162
|
+
protected: draft.protected
|
|
163
|
+
};
|
|
164
|
+
const latest = useRef({
|
|
165
|
+
id: draft.id,
|
|
166
|
+
definition
|
|
167
|
+
});
|
|
168
|
+
latest.current = {
|
|
169
|
+
id: draft.id,
|
|
170
|
+
definition
|
|
171
|
+
};
|
|
172
|
+
const busy = weigh.pending || apply.pending;
|
|
173
|
+
const set = (permission, column, on) => setDraft((current) => ({
|
|
174
|
+
...current,
|
|
175
|
+
...toggle(current, permission, column, on)
|
|
176
|
+
}));
|
|
177
|
+
const startFrom = (id) => {
|
|
178
|
+
const source = roles.find((each) => each.id === id);
|
|
179
|
+
setDraft((current) => ({
|
|
180
|
+
...current,
|
|
181
|
+
...source === void 0 ? {
|
|
182
|
+
permissions: [],
|
|
183
|
+
protected: []
|
|
184
|
+
} : ordered(source)
|
|
185
|
+
}));
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Ask what an action would do; the confirmation shows it, for what was
|
|
189
|
+
* weighed. One the grid changed under while it was weighed is weighed
|
|
190
|
+
* again, as the grid is now. Busy until it has its answer, the weighing
|
|
191
|
+
* again included.
|
|
192
|
+
*/
|
|
193
|
+
function ask(action, again = false) {
|
|
194
|
+
const asked = latest.current;
|
|
195
|
+
return weigh.run(() => action === "save" ? coffre.roles.preview(asked.id, asked.definition, { instance }) : coffre.roles.previewReset(asked.id, { instance }), {
|
|
196
|
+
affects: [],
|
|
197
|
+
onSuccess: (impact) => {
|
|
198
|
+
if (JSON.stringify(latest.current) !== JSON.stringify(asked)) return ask(action, again);
|
|
199
|
+
setPending({
|
|
200
|
+
action,
|
|
201
|
+
...asked,
|
|
202
|
+
impact,
|
|
203
|
+
again
|
|
204
|
+
});
|
|
205
|
+
setAsking(true);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/** Do what was confirmed, as it was weighed: the policy changed since, it is weighed again, and asked again. */
|
|
210
|
+
function confirm({ action, id, definition: weighed, impact }) {
|
|
211
|
+
const name = action === "save" ? weighed.name : label;
|
|
212
|
+
const confirmed = {
|
|
213
|
+
instance,
|
|
214
|
+
revision: impact.revision
|
|
215
|
+
};
|
|
216
|
+
apply.run(async () => {
|
|
217
|
+
try {
|
|
218
|
+
await (action === "save" ? coffre.roles.set(id, weighed, confirmed) : coffre.roles.reset(id, confirmed));
|
|
219
|
+
return true;
|
|
220
|
+
} catch (failure) {
|
|
221
|
+
if (failure instanceof CoffreError && failure.reason === "policy_changed") return false;
|
|
222
|
+
throw failure;
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
affects: affects.roles(),
|
|
226
|
+
onSuccess: (saved) => {
|
|
227
|
+
if (!saved) return ask(action, true);
|
|
228
|
+
toast.success(action === "delete" ? `Deleted the ${name} role` : action === "reset" ? `${name} is as it ships again` : made ? `Made the ${name} role` : `Saved the ${name} role`);
|
|
229
|
+
onClose();
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const granted = role !== null && !role.builtin && role.grants > 0;
|
|
234
|
+
const error = weigh.error ?? apply.error;
|
|
235
|
+
return /* @__PURE__ */ jsxs(Modal, {
|
|
236
|
+
open: true,
|
|
237
|
+
onOpenChange: (next) => !next && !busy && onClose(),
|
|
238
|
+
wide: true,
|
|
239
|
+
title: made ? "New role" : editable ? /* @__PURE__ */ jsxs(Fragment$1, { children: ["Edit ", role.name] }) : role.name,
|
|
240
|
+
description: !editable && role !== null ? role.fixed ? `${role.name} holds ${role.id === "member" ? "nothing" : "everything"}, always: nobody edits it.` : "Only an Owner of the whole instance edits roles." : made ? "A project role, granted as any is. You can delete it while no grant names it." : void 0,
|
|
241
|
+
children: [/* @__PURE__ */ jsxs("form", {
|
|
242
|
+
className: "form",
|
|
243
|
+
onSubmit: (event) => {
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
ask("save");
|
|
246
|
+
},
|
|
247
|
+
children: [
|
|
248
|
+
editable && /* @__PURE__ */ jsxs("div", {
|
|
249
|
+
className: "form-row",
|
|
250
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
251
|
+
className: "field",
|
|
252
|
+
htmlFor: ids.name,
|
|
253
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
254
|
+
className: "label",
|
|
255
|
+
children: "Name"
|
|
256
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
257
|
+
id: ids.name,
|
|
258
|
+
className: "input",
|
|
259
|
+
autoFocus: made,
|
|
260
|
+
maxLength: 40,
|
|
261
|
+
autoComplete: "off",
|
|
262
|
+
placeholder: made ? "Release manager" : void 0,
|
|
263
|
+
value: draft.name,
|
|
264
|
+
onChange: (event) => {
|
|
265
|
+
const name = event.target.value;
|
|
266
|
+
setDraft((current) => ({
|
|
267
|
+
...current,
|
|
268
|
+
name,
|
|
269
|
+
...made && !idTyped ? { id: roleIdFrom(name) } : {}
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
})]
|
|
273
|
+
}), made && /* @__PURE__ */ jsxs("label", {
|
|
274
|
+
className: "field",
|
|
275
|
+
htmlFor: ids.id,
|
|
276
|
+
children: [
|
|
277
|
+
/* @__PURE__ */ jsx("span", {
|
|
278
|
+
className: "label",
|
|
279
|
+
children: "Id"
|
|
280
|
+
}),
|
|
281
|
+
/* @__PURE__ */ jsx("input", {
|
|
282
|
+
id: ids.id,
|
|
283
|
+
className: "input input-mono",
|
|
284
|
+
spellCheck: false,
|
|
285
|
+
autoComplete: "off",
|
|
286
|
+
maxLength: 32,
|
|
287
|
+
placeholder: "release-manager",
|
|
288
|
+
value: draft.id,
|
|
289
|
+
"aria-invalid": draft.id !== "" && idError !== null,
|
|
290
|
+
"aria-describedby": `${ids.id}-hint`,
|
|
291
|
+
onChange: (event) => {
|
|
292
|
+
setIdTyped(true);
|
|
293
|
+
setDraft((current) => ({
|
|
294
|
+
...current,
|
|
295
|
+
id: event.target.value
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
}),
|
|
299
|
+
/* @__PURE__ */ jsx("span", {
|
|
300
|
+
id: `${ids.id}-hint`,
|
|
301
|
+
className: `hint${draft.id !== "" && idError !== null ? " edit-note-error" : ""}`,
|
|
302
|
+
children: draft.id !== "" && idError !== null ? idError : "What the CLI and grants name it. It never changes."
|
|
303
|
+
})
|
|
304
|
+
]
|
|
305
|
+
})]
|
|
306
|
+
}),
|
|
307
|
+
editable && /* @__PURE__ */ jsxs("label", {
|
|
308
|
+
className: "field",
|
|
309
|
+
htmlFor: ids.description,
|
|
310
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
311
|
+
className: "label",
|
|
312
|
+
children: ["Description ", /* @__PURE__ */ jsx("span", {
|
|
313
|
+
className: "hint",
|
|
314
|
+
children: "(optional)"
|
|
315
|
+
})]
|
|
316
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
317
|
+
id: ids.description,
|
|
318
|
+
className: "input",
|
|
319
|
+
maxLength: 200,
|
|
320
|
+
autoComplete: "off",
|
|
321
|
+
value: draft.description,
|
|
322
|
+
onChange: (event) => setDraft((current) => ({
|
|
323
|
+
...current,
|
|
324
|
+
description: event.target.value
|
|
325
|
+
}))
|
|
326
|
+
})]
|
|
327
|
+
}),
|
|
328
|
+
made && /* @__PURE__ */ jsxs("label", {
|
|
329
|
+
className: "field",
|
|
330
|
+
htmlFor: ids.start,
|
|
331
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
332
|
+
className: "label",
|
|
333
|
+
children: "Start from"
|
|
334
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
335
|
+
id: ids.start,
|
|
336
|
+
className: "select",
|
|
337
|
+
defaultValue: "",
|
|
338
|
+
onChange: (event) => startFrom(event.target.value),
|
|
339
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
340
|
+
value: "",
|
|
341
|
+
children: "Nothing"
|
|
342
|
+
}), roles.map((each) => /* @__PURE__ */ jsx("option", {
|
|
343
|
+
value: each.id,
|
|
344
|
+
children: each.name
|
|
345
|
+
}, each.id))]
|
|
346
|
+
})]
|
|
347
|
+
}),
|
|
348
|
+
!editable && role !== null && role.description !== "" && /* @__PURE__ */ jsx("p", {
|
|
349
|
+
className: "dialog-body",
|
|
350
|
+
children: role.description
|
|
351
|
+
}),
|
|
352
|
+
/* @__PURE__ */ jsx(RoleGrid, {
|
|
353
|
+
name: label,
|
|
354
|
+
columns: draft,
|
|
355
|
+
editable,
|
|
356
|
+
onChange: set
|
|
357
|
+
}),
|
|
358
|
+
editable && /* @__PURE__ */ jsxs("p", {
|
|
359
|
+
className: "hint",
|
|
360
|
+
children: ["Reading takes using, and a protected environment holds no more than any other: the boxes keep both true.", instance ? " An instance role reaches every project its holder’s scope takes in." : ""]
|
|
361
|
+
}),
|
|
362
|
+
role !== null && role.edited && /* @__PURE__ */ jsxs(Notice, {
|
|
363
|
+
tone: "info",
|
|
364
|
+
children: [
|
|
365
|
+
"Edited. As it ships, it holds ",
|
|
366
|
+
columnInWords(role.default?.permissions ?? []),
|
|
367
|
+
"; in protected environments,",
|
|
368
|
+
" ",
|
|
369
|
+
columnInWords(role.default?.protected ?? []),
|
|
370
|
+
"."
|
|
371
|
+
]
|
|
372
|
+
}),
|
|
373
|
+
editable && changed && definitionError !== null && draft.name.trim() !== "" && /* @__PURE__ */ jsx("p", {
|
|
374
|
+
className: "hint edit-note-error",
|
|
375
|
+
children: definitionError
|
|
376
|
+
}),
|
|
377
|
+
/* @__PURE__ */ jsx(ErrorLine, { error }),
|
|
378
|
+
/* @__PURE__ */ jsxs("div", {
|
|
379
|
+
className: "dialog-actions role-editor-actions",
|
|
380
|
+
children: [
|
|
381
|
+
editable && role !== null && (role.builtin ? role.edited : true) && /* @__PURE__ */ jsxs("div", {
|
|
382
|
+
className: "role-editor-aside",
|
|
383
|
+
children: [role.builtin ? /* @__PURE__ */ jsxs("button", {
|
|
384
|
+
className: "btn",
|
|
385
|
+
type: "button",
|
|
386
|
+
disabled: busy,
|
|
387
|
+
onClick: () => void ask("reset"),
|
|
388
|
+
children: [/* @__PURE__ */ jsx(RotateBack, { size: 14 }), "Reset to default"]
|
|
389
|
+
}) : /* @__PURE__ */ jsxs("button", {
|
|
390
|
+
className: "btn btn-danger-outline",
|
|
391
|
+
type: "button",
|
|
392
|
+
disabled: busy || granted,
|
|
393
|
+
"aria-describedby": granted ? `${ids.name}-granted` : void 0,
|
|
394
|
+
onClick: () => void ask("delete"),
|
|
395
|
+
children: [/* @__PURE__ */ jsx(Trash, { size: 14 }), "Delete…"]
|
|
396
|
+
}), granted && /* @__PURE__ */ jsxs("span", {
|
|
397
|
+
id: `${ids.name}-granted`,
|
|
398
|
+
className: "hint",
|
|
399
|
+
children: [
|
|
400
|
+
role.grants === 1 ? "1 grant names it" : `${role.grants} grants name it`,
|
|
401
|
+
": revoke ",
|
|
402
|
+
role.grants === 1 ? "it" : "them",
|
|
403
|
+
" first."
|
|
404
|
+
]
|
|
405
|
+
})]
|
|
406
|
+
}),
|
|
407
|
+
/* @__PURE__ */ jsx("button", {
|
|
408
|
+
className: "btn",
|
|
409
|
+
type: "button",
|
|
410
|
+
disabled: busy,
|
|
411
|
+
onClick: onClose,
|
|
412
|
+
children: editable ? "Cancel" : "Close"
|
|
413
|
+
}),
|
|
414
|
+
editable && /* @__PURE__ */ jsxs("button", {
|
|
415
|
+
className: "btn btn-primary",
|
|
416
|
+
type: "submit",
|
|
417
|
+
disabled: busy || !changed || definitionError !== null || idError !== null,
|
|
418
|
+
children: [weigh.pending && /* @__PURE__ */ jsx(Spinner, {}), made ? "Make role…" : "Save…"]
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
})
|
|
422
|
+
]
|
|
423
|
+
}), /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
424
|
+
open: asking,
|
|
425
|
+
onOpenChange: setAsking,
|
|
426
|
+
title: pending?.action === "delete" ? `Delete the ${label} role?` : pending?.action === "reset" ? `Reset ${label} to its default?` : made ? `Make the ${pending?.definition.name ?? definition.name} role?` : `Save the ${label} role?`,
|
|
427
|
+
body: pending === null ? "" : impactLead(pending),
|
|
428
|
+
detail: pending !== null && pending.impact.impact.length > 0 && /* @__PURE__ */ jsx(ImpactList, { impact: pending.impact }),
|
|
429
|
+
confirmLabel: pending?.action === "delete" ? "Delete" : pending?.action === "reset" ? "Reset" : "Save",
|
|
430
|
+
destructive: pending?.action === "delete",
|
|
431
|
+
onConfirm: () => pending !== null && confirm(pending)
|
|
432
|
+
})]
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
/** What a change does, before its lines: whether it reaches anyone now, and, weighed again, why. */
|
|
436
|
+
function impactLead(pending) {
|
|
437
|
+
const lead = impactNow(pending);
|
|
438
|
+
return pending.again === true ? `The roles or protected environments changed since you asked: this is what it does now. ${lead}` : lead;
|
|
439
|
+
}
|
|
440
|
+
function impactNow({ action, impact }) {
|
|
441
|
+
const logged = "It is logged, with the role as it was.";
|
|
442
|
+
if (impact.impact.length === 0) return action === "delete" ? `No grant names it, so nobody loses anything. ${logged}` : `Nobody holds more or less for it today: it applies to whoever holds the role from now on. ${logged}`;
|
|
443
|
+
return `It applies at once to everyone the role reaches, people and service accounts; tokens issued before keep at most what they held. ${logged}`;
|
|
444
|
+
}
|
|
445
|
+
/** A change's impact, line by line, with whom each reaches. */
|
|
446
|
+
function ImpactList({ impact }) {
|
|
447
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
448
|
+
className: "impact-list",
|
|
449
|
+
children: impact.impact.map((line) => {
|
|
450
|
+
const who = impactExamples(line);
|
|
451
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
452
|
+
className: `impact-line impact-${line.change}`,
|
|
453
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
454
|
+
className: `tag ${line.change === "widens" ? "tag-amber" : "tag-blue"}`,
|
|
455
|
+
children: line.change === "widens" ? "Widens" : "Narrows"
|
|
456
|
+
}), /* @__PURE__ */ jsxs("span", { children: [impactInWords(line), who !== null && /* @__PURE__ */ jsx("span", {
|
|
457
|
+
className: "impact-who",
|
|
458
|
+
children: who
|
|
459
|
+
})] })]
|
|
460
|
+
}, `${line.change} ${line.permission} ${line.protected}`);
|
|
461
|
+
})
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* The grid: a row per permission, a column for environments and one for
|
|
466
|
+
* protected ones, real checkboxes each named in full for a screen reader
|
|
467
|
+
* ("Developer: Read values in protected environments"). Project-wide
|
|
468
|
+
* permissions have the first column alone, under a heading of their own.
|
|
469
|
+
*/
|
|
470
|
+
function RoleGrid({ name, columns, editable, onChange }) {
|
|
471
|
+
const cell = (permission, column) => {
|
|
472
|
+
const on = (column === "normal" ? columns.permissions : columns.protected).includes(permission);
|
|
473
|
+
const where = projectWide(permission) ? ", on the whole project" : column === "normal" ? " in environments" : " in protected environments";
|
|
474
|
+
const words = `${name}: ${PERMISSION_WORDS[permission].label}${where}`;
|
|
475
|
+
if (!editable) return on ? /* @__PURE__ */ jsxs("span", {
|
|
476
|
+
className: "role-grid-yes",
|
|
477
|
+
title: words,
|
|
478
|
+
children: [/* @__PURE__ */ jsx(Check, { size: 15 }), /* @__PURE__ */ jsxs("span", {
|
|
479
|
+
className: "visually-hidden",
|
|
480
|
+
children: [words, ": yes"]
|
|
481
|
+
})]
|
|
482
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
483
|
+
className: "role-grid-no",
|
|
484
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
485
|
+
"aria-hidden": true,
|
|
486
|
+
children: "–"
|
|
487
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
488
|
+
className: "visually-hidden",
|
|
489
|
+
children: [words, ": no"]
|
|
490
|
+
})]
|
|
491
|
+
});
|
|
492
|
+
return /* @__PURE__ */ jsx("label", {
|
|
493
|
+
className: "role-grid-hit",
|
|
494
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
495
|
+
type: "checkbox",
|
|
496
|
+
className: "role-grid-box",
|
|
497
|
+
"aria-label": words,
|
|
498
|
+
checked: on,
|
|
499
|
+
onChange: (event) => onChange(permission, column, event.target.checked)
|
|
500
|
+
})
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
const values = GRID_PERMISSIONS.filter((permission) => !projectWide(permission));
|
|
504
|
+
const wide = GRID_PERMISSIONS.filter(projectWide);
|
|
505
|
+
const row = (permission) => {
|
|
506
|
+
const { label, note } = PERMISSION_WORDS[permission];
|
|
507
|
+
return /* @__PURE__ */ jsxs("tr", { children: [
|
|
508
|
+
/* @__PURE__ */ jsxs("th", {
|
|
509
|
+
scope: "row",
|
|
510
|
+
children: [label, note !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
511
|
+
className: "role-grid-note",
|
|
512
|
+
children: note
|
|
513
|
+
})]
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ jsx("td", { children: cell(permission, "normal") }),
|
|
516
|
+
projectWide(permission) ? /* @__PURE__ */ jsx("td", {}) : /* @__PURE__ */ jsx("td", { children: cell(permission, "protected") })
|
|
517
|
+
] }, permission);
|
|
518
|
+
};
|
|
519
|
+
return /* @__PURE__ */ jsx("div", {
|
|
520
|
+
className: "role-grid-wrap",
|
|
521
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
522
|
+
className: "role-grid",
|
|
523
|
+
children: [
|
|
524
|
+
/* @__PURE__ */ jsxs("caption", {
|
|
525
|
+
className: "visually-hidden",
|
|
526
|
+
children: [
|
|
527
|
+
"What ",
|
|
528
|
+
name,
|
|
529
|
+
" holds, in environments and in protected ones"
|
|
530
|
+
]
|
|
531
|
+
}),
|
|
532
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
533
|
+
/* @__PURE__ */ jsx("th", {
|
|
534
|
+
scope: "col",
|
|
535
|
+
children: "Permission"
|
|
536
|
+
}),
|
|
537
|
+
/* @__PURE__ */ jsxs("th", {
|
|
538
|
+
scope: "col",
|
|
539
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
540
|
+
className: "role-grid-long",
|
|
541
|
+
children: "Environments"
|
|
542
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
543
|
+
className: "role-grid-short",
|
|
544
|
+
"aria-hidden": true,
|
|
545
|
+
children: "Normal"
|
|
546
|
+
})]
|
|
547
|
+
}),
|
|
548
|
+
/* @__PURE__ */ jsx("th", {
|
|
549
|
+
scope: "col",
|
|
550
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
551
|
+
className: "th",
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ jsx(Lock, { size: 12 }),
|
|
554
|
+
/* @__PURE__ */ jsx("span", {
|
|
555
|
+
className: "role-grid-long",
|
|
556
|
+
children: "Protected environments"
|
|
557
|
+
}),
|
|
558
|
+
/* @__PURE__ */ jsx("span", {
|
|
559
|
+
className: "role-grid-short",
|
|
560
|
+
"aria-hidden": true,
|
|
561
|
+
children: "Protected"
|
|
562
|
+
})
|
|
563
|
+
]
|
|
564
|
+
})
|
|
565
|
+
})
|
|
566
|
+
] }) }),
|
|
567
|
+
/* @__PURE__ */ jsx("tbody", { children: values.map(row) }),
|
|
568
|
+
/* @__PURE__ */ jsxs("tbody", { children: [/* @__PURE__ */ jsx("tr", {
|
|
569
|
+
className: "role-grid-group",
|
|
570
|
+
children: /* @__PURE__ */ jsxs("th", {
|
|
571
|
+
scope: "rowgroup",
|
|
572
|
+
colSpan: 3,
|
|
573
|
+
children: ["Project-wide ", /* @__PURE__ */ jsx("span", {
|
|
574
|
+
className: "role-grid-note",
|
|
575
|
+
children: "one column: a project is never protected"
|
|
576
|
+
})]
|
|
577
|
+
})
|
|
578
|
+
}), wide.map(row)] })
|
|
579
|
+
]
|
|
580
|
+
})
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
//#endregion
|
|
13
584
|
//#region src/pages/settings.tsx
|
|
14
585
|
/** The instance's settings. Your own are under Account, at the sidebar's foot. */
|
|
15
586
|
function SettingsPage() {
|
|
@@ -65,6 +636,7 @@ function SettingsPage() {
|
|
|
65
636
|
}) })]
|
|
66
637
|
})
|
|
67
638
|
}),
|
|
639
|
+
/* @__PURE__ */ jsx(RolesSettings, {}),
|
|
68
640
|
settings?.ok === true && /* @__PURE__ */ jsx(ServiceSetup, { scope: settings.serviceAccounts }),
|
|
69
641
|
keys?.ok === true && /* @__PURE__ */ jsx(Keys, { keys })
|
|
70
642
|
] });
|