@coffre/ui 0.14.5 → 0.15.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.
Files changed (115) hide show
  1. package/dist/chunks/{audit-sentence-JgJEwQEC.js → actions-log-DupYCEyV.js} +186 -21
  2. package/dist/chunks/actions-log-DupYCEyV.js.map +1 -0
  3. package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-CGUQlFMx.js} +5 -5
  4. package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-CGUQlFMx.js.map} +1 -1
  5. package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-CswZ-meh.js} +5 -5
  6. package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-CswZ-meh.js.map} +1 -1
  7. package/dist/chunks/{directory-BM8yoiJN.js → directory-DrswWQLT.js} +15 -15
  8. package/dist/chunks/directory-DrswWQLT.js.map +1 -0
  9. package/dist/chunks/environment-actions-8rL9Cw6X.js +576 -0
  10. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +1 -0
  11. package/dist/chunks/{folders-D3A1NGpt.js → folders-A6sbR_PG.js} +3 -3
  12. package/dist/chunks/{folders-D3A1NGpt.js.map → folders-A6sbR_PG.js.map} +1 -1
  13. package/dist/chunks/{grants-CjVmOgb2.js → grants-C0cb2oii.js} +8 -8
  14. package/dist/chunks/grants-C0cb2oii.js.map +1 -0
  15. package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-B3SEv1gq.js} +3 -3
  16. package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-B3SEv1gq.js.map} +1 -1
  17. package/dist/chunks/{offboarding-DbozhPym.js → offboarding-C1jbG_dk.js} +72 -67
  18. package/dist/chunks/offboarding-C1jbG_dk.js.map +1 -0
  19. package/dist/chunks/{page-JTORvh-N.js → page-CfhC9Hp1.js} +11 -6
  20. package/dist/chunks/page-CfhC9Hp1.js.map +1 -0
  21. package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-xC9wulhg.js} +5 -5
  22. package/dist/chunks/{personal-tokens-zWZOzLIC.js.map → personal-tokens-xC9wulhg.js.map} +1 -1
  23. package/dist/chunks/{principal-DFBswTBr.js → principal-CI17XK13.js} +2 -2
  24. package/dist/chunks/{principal-DFBswTBr.js.map → principal-CI17XK13.js.map} +1 -1
  25. package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-CdSeftGD.js} +17 -127
  26. package/dist/chunks/principal-page-CdSeftGD.js.map +1 -0
  27. package/dist/chunks/{project-page-BjwEoXfU.js → project-page-CHxjBE97.js} +3 -3
  28. package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-CHxjBE97.js.map} +1 -1
  29. package/dist/chunks/{queries-2jdgTwfZ.js → queries-D1JuimTu.js} +82 -26
  30. package/dist/chunks/queries-D1JuimTu.js.map +1 -0
  31. package/dist/chunks/{references-CRT2BsOS.js → references-D5llUGQL.js} +5 -5
  32. package/dist/chunks/{references-CRT2BsOS.js.map → references-D5llUGQL.js.map} +1 -1
  33. package/dist/chunks/{role-field-DswIpPqY.js → role-field-CoCv8wse.js} +5 -5
  34. package/dist/chunks/role-field-CoCv8wse.js.map +1 -0
  35. package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYH7kZHl.js} +3 -3
  36. package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYH7kZHl.js.map} +1 -1
  37. package/dist/chunks/{theme-Ck45wzWB.js → theme-rF44Wbmm.js} +3 -3
  38. package/dist/chunks/{theme-Ck45wzWB.js.map → theme-rF44Wbmm.js.map} +1 -1
  39. package/dist/chunks/{ui-D-blFWfx.js → ui-CGdORVzW.js} +2 -2
  40. package/dist/chunks/{ui-D-blFWfx.js.map → ui-CGdORVzW.js.map} +1 -1
  41. package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BxrHTBZw.js} +3 -3
  42. package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BxrHTBZw.js.map} +1 -1
  43. package/dist/chunks/{use-change-BC4xo02c.js → use-change-BorW2R6C.js} +4 -4
  44. package/dist/chunks/{use-change-BC4xo02c.js.map → use-change-BorW2R6C.js.map} +1 -1
  45. package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-BZnJ9Cq0.js} +56 -13
  46. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +1 -0
  47. package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-CPskgi1k.js} +3 -3
  48. package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-CPskgi1k.js.map} +1 -1
  49. package/dist/index.d.ts +46 -2
  50. package/dist/index.js +30 -11
  51. package/dist/index.js.map +1 -1
  52. package/dist/pages/account.js +11 -11
  53. package/dist/pages/account.js.map +1 -1
  54. package/dist/pages/approval.js +2 -2
  55. package/dist/pages/audit.js +55 -21
  56. package/dist/pages/audit.js.map +1 -1
  57. package/dist/pages/device-login.js +2 -2
  58. package/dist/pages/environment.js +228 -389
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +3 -3
  61. package/dist/pages/oauth-authorize.js +2 -2
  62. package/dist/pages/project-access.js +11 -11
  63. package/dist/pages/project-environments.js +28 -359
  64. package/dist/pages/project-environments.js.map +1 -1
  65. package/dist/pages/project-settings.js +8 -8
  66. package/dist/pages/project.js +3 -3
  67. package/dist/pages/projects.js +8 -8
  68. package/dist/pages/service-account.js +11 -10
  69. package/dist/pages/service-account.js.map +1 -1
  70. package/dist/pages/service-accounts.js +7 -6
  71. package/dist/pages/service-accounts.js.map +1 -1
  72. package/dist/pages/settings.d.ts +6 -1
  73. package/dist/pages/settings.js +284 -164
  74. package/dist/pages/settings.js.map +1 -1
  75. package/dist/pages/unregistered.js +2 -2
  76. package/dist/pages/user.js +7 -6
  77. package/dist/pages/user.js.map +1 -1
  78. package/dist/pages/users.js +7 -6
  79. package/dist/pages/users.js.map +1 -1
  80. package/package.json +3 -3
  81. package/src/components/actions-log.tsx +61 -8
  82. package/src/components/directory.tsx +5 -5
  83. package/src/components/environment-actions.tsx +508 -0
  84. package/src/components/grants.tsx +2 -2
  85. package/src/components/icons.tsx +2 -0
  86. package/src/components/offboarding.tsx +7 -0
  87. package/src/components/page.tsx +3 -2
  88. package/src/components/principal-page.tsx +1 -1
  89. package/src/components/protected.tsx +52 -39
  90. package/src/components/role-editor.tsx +99 -68
  91. package/src/components/role-field.tsx +1 -1
  92. package/src/lib/audit-sentences.ts +21 -18
  93. package/src/lib/queries.ts +85 -21
  94. package/src/lib/roles.ts +36 -10
  95. package/src/options.ts +19 -3
  96. package/src/pages/account.tsx +1 -1
  97. package/src/pages/audit.tsx +56 -16
  98. package/src/pages/environment.tsx +227 -352
  99. package/src/pages/project-environments.tsx +20 -322
  100. package/src/pages/service-accounts.tsx +1 -1
  101. package/src/pages/settings.tsx +129 -48
  102. package/src/pages/users.tsx +1 -1
  103. package/src/parity.ts +18 -11
  104. package/src/styles/globals.css +271 -89
  105. package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
  106. package/dist/chunks/directory-BM8yoiJN.js.map +0 -1
  107. package/dist/chunks/grants-CjVmOgb2.js.map +0 -1
  108. package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
  109. package/dist/chunks/page-JTORvh-N.js.map +0 -1
  110. package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
  111. package/dist/chunks/protected-y7KVhtHd.js +0 -77
  112. package/dist/chunks/protected-y7KVhtHd.js.map +0 -1
  113. package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
  114. package/dist/chunks/role-field-DswIpPqY.js.map +0 -1
  115. package/dist/chunks/use-roles-DswiNxBk.js.map +0 -1
@@ -1,10 +1,12 @@
1
- import { t as affects, x as queries } from "../chunks/queries-2jdgTwfZ.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-zpjE_MKh.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-DswiNxBk.js";
6
- import { n as ScopeField } from "../chunks/role-field-DswIpPqY.js";
7
- import { t as useAction } from "../chunks/use-action-CXEFFjx5.js";
1
+ import { n as affects, x as queries } from "../chunks/queries-D1JuimTu.js";
2
+ import { a as ErrorLine, c as Notice, f as Toggletip, l as Spinner, n as ConfirmDialog, s as Modal } from "../chunks/ui-CGdORVzW.js";
3
+ import { G as Pencil, J as RotateBack, K as Plus, M as Info, N as Key, R as Lock, X as Settings, Z as ShieldCheck, _ as Check, i as PageHeader, r as Fact, rt as Trash, t as Card, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
4
+ import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
5
+ import { t as PageTabs } from "../chunks/tabs-BmwKfUeK.js";
6
+ import { a as columnInWords, c as ordered, d as reachOf, f as roleIdFrom, g as toggle, h as sameDefinition, i as PERMISSION_WORDS, l as projectWide, n as CARD_ROWS, o as impactExamples, p as roleIdProblem, r as GRID_PERMISSIONS, s as impactInWords } from "../chunks/use-roles-BZnJ9Cq0.js";
7
+ import { n as ScopeField } from "../chunks/role-field-CoCv8wse.js";
8
+ import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
9
+ import { t as useAction } from "../chunks/use-action-BxrHTBZw.js";
8
10
  import { useId, useRef, useState } from "react";
9
11
  import { Link } from "@tanstack/react-router";
10
12
  import { toast } from "sonner";
@@ -13,90 +15,131 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
15
  import { useSuspenseQuery } from "@tanstack/react-query";
14
16
  import { CoffreError } from "@coffre/client";
15
17
  //#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
+ /**
19
+ * The instance's project roles, or its global roles (instance roles, in
20
+ * the code and the API): a card each, which opens its editor, under what
21
+ * switches between the two.
22
+ */
23
+ function RolesSettings({ kind, switcher }) {
18
24
  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
- })] });
25
+ if (!data.ok) return /* @__PURE__ */ jsx(ErrorLine, { error: `The roles could not be read. ${data.error}` });
26
+ return /* @__PURE__ */ jsx(RoleList, {
27
+ kind,
28
+ roles: kind === "role" ? data.roles : data.instanceRoles,
29
+ editable: data.editable,
30
+ switcher
31
+ }, kind);
36
32
  }
37
- function RoleList({ kind, roles, editable }) {
33
+ function RoleList({ kind, roles, editable, switcher }) {
38
34
  const [open, setOpen] = useState(null);
39
35
  const project = kind === "role";
40
36
  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"]
37
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
38
+ /* @__PURE__ */ jsxs("div", {
39
+ className: "section-actions",
40
+ children: [switcher, project && editable && /* @__PURE__ */ jsxs("button", {
41
+ className: "btn",
42
+ type: "button",
43
+ onClick: () => setOpen({ making: true }),
44
+ children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "New role"]
45
+ })]
50
46
  }),
51
- children: [/* @__PURE__ */ jsx("ul", {
52
- className: "role-list",
53
- "aria-label": project ? "Roles" : "Instance roles",
47
+ /* @__PURE__ */ jsxs("div", {
48
+ className: "roles-desc",
49
+ children: [/* @__PURE__ */ jsx("p", { children: project ? "Granted on a project or environment; a person or service account can hold several." : "One per person, across every project in its scope; assigned on Users." }), roles.some((role) => GRID_PERMISSIONS.some((permission) => reachOf(role, permission) === "unprotected")) && /* @__PURE__ */ jsxs("p", {
50
+ className: "role-legend",
51
+ "aria-hidden": true,
52
+ children: [/* @__PURE__ */ jsx(Lock, { size: 12 }), "Not in protected environments"]
53
+ })]
54
+ }),
55
+ /* @__PURE__ */ jsx("ul", {
56
+ className: "role-cards",
57
+ "aria-label": project ? "Project roles" : "Global roles",
54
58
  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
- })]
59
+ className: "role-card",
60
+ children: [
61
+ /* @__PURE__ */ jsxs("p", {
62
+ className: "role-card-title",
63
+ children: [role.name, /* @__PURE__ */ jsx(RoleBadges, { role })]
64
+ }),
65
+ !role.builtin && role.description !== "" && /* @__PURE__ */ jsx("p", {
66
+ className: "role-card-desc",
67
+ children: role.description
68
+ }),
69
+ /* @__PURE__ */ jsx(RoleReach, { role }),
70
+ /* @__PURE__ */ jsxs("div", {
71
+ className: "role-card-foot",
72
+ children: [/* @__PURE__ */ jsx("span", {
73
+ className: "role-card-count",
74
+ children: held(kind, role.grants)
75
+ }), /* @__PURE__ */ jsxs("button", {
76
+ className: "btn btn-sm",
77
+ type: "button",
78
+ "aria-label": `${editable && !role.fixed ? "Edit" : "View"} ${role.name}`,
79
+ onClick: () => setOpen({ role: role.id }),
80
+ children: [editable && !role.fixed && /* @__PURE__ */ jsx(Pencil, { size: 14 }), editable && !role.fixed ? "Edit…" : "View"]
81
+ })]
82
+ })
83
+ ]
85
84
  }, role.id))
86
- }), open !== null && opened !== void 0 && /* @__PURE__ */ jsx(RoleEditor, {
85
+ }),
86
+ open !== null && opened !== void 0 && /* @__PURE__ */ jsx(RoleEditor, {
87
87
  kind,
88
88
  role: opened,
89
89
  roles,
90
90
  editable: editable && (opened === null || !opened.fixed),
91
91
  onClose: () => setOpen(null)
92
- }, "making" in open ? "" : `role:${open.role}`)]
93
- });
92
+ }, "making" in open ? "" : `role:${open.role}`)
93
+ ] });
94
94
  }
95
95
  /** "3 grants", "1 person": who a role reaches now. */
96
96
  function held(kind, count) {
97
97
  if (kind === "instance-role") return count === 0 ? "Nobody" : count === 1 ? "1 person" : `${count} people`;
98
98
  return count === 0 ? "No grants" : count === 1 ? "1 grant" : `${count} grants`;
99
99
  }
100
+ /**
101
+ * What a role can do, on its card: every permission, in the same place on
102
+ * every card, held ones solid, the others a dashed outline, and a lock on
103
+ * one it holds only outside protected environments. A screen reader hears
104
+ * each in full: "Read values: yes, except in protected environments".
105
+ */
106
+ function RoleReach({ role }) {
107
+ return /* @__PURE__ */ jsx("dl", {
108
+ className: "role-reach",
109
+ children: CARD_ROWS.map((row) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: row.name }), /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx("ul", {
110
+ role: "list",
111
+ children: row.permissions.map((permission) => {
112
+ const reach = reachOf(role, permission);
113
+ const { label, short } = PERMISSION_WORDS[permission];
114
+ const words = reach === "nowhere" ? "no" : reach === "unprotected" ? "yes, except in protected environments" : "yes";
115
+ return /* @__PURE__ */ jsxs("li", {
116
+ className: `role-perm role-perm-${reach}`,
117
+ title: reach === "unprotected" ? `${label}, not in protected environments` : label,
118
+ children: [
119
+ /* @__PURE__ */ jsxs("span", {
120
+ className: "role-perm-shown",
121
+ "aria-hidden": true,
122
+ children: [short, reach === "unprotected" && /* @__PURE__ */ jsx(Lock, { size: 11 })]
123
+ }),
124
+ /* @__PURE__ */ jsxs("span", {
125
+ className: "role-perm-widest",
126
+ "aria-hidden": true,
127
+ children: [short, !projectWide(permission) && /* @__PURE__ */ jsx(Lock, { size: 11 })]
128
+ }),
129
+ /* @__PURE__ */ jsxs("span", {
130
+ className: "visually-hidden",
131
+ children: [
132
+ label,
133
+ ": ",
134
+ words
135
+ ]
136
+ })
137
+ ]
138
+ }, permission);
139
+ })
140
+ }) })] }, row.name))
141
+ });
142
+ }
100
143
  /** Where a role comes from, and whether it is as it shipped. */
101
144
  function RoleBadges({ role }) {
102
145
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -357,7 +400,7 @@ function RoleEditor({ kind, role, roles, editable, onClose }) {
357
400
  }),
358
401
  editable && /* @__PURE__ */ jsxs("p", {
359
402
  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." : ""]
403
+ children: ["Reading takes using, and a protected environment holds no more than any other: the boxes keep both true.", instance ? " A global role reaches every project its holder’s scope takes in." : ""]
361
404
  }),
362
405
  role !== null && role.edited && /* @__PURE__ */ jsxs(Notice, {
363
406
  tone: "info",
@@ -582,70 +625,132 @@ function RoleGrid({ name, columns, editable, onChange }) {
582
625
  }
583
626
  //#endregion
584
627
  //#region src/pages/settings.tsx
585
- /** The instance's settings. Your own are under Account, at the sidebar's foot. */
628
+ var Route = pageRoute();
629
+ /**
630
+ * The instance's settings, a tab each: General, the instance and who
631
+ * creates service accounts; Roles, the project roles or the global ones;
632
+ * Keys, for whoever runs the instance. Your own settings are under
633
+ * Account, at the sidebar's foot.
634
+ */
586
635
  function SettingsPage() {
636
+ const { tab, roles } = Route.useSearch();
637
+ const { capabilities } = useShell();
638
+ const current = {
639
+ exact: true,
640
+ includeSearch: true
641
+ };
642
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
643
+ /* @__PURE__ */ jsx(PageHeader, { title: "Settings" }),
644
+ /* @__PURE__ */ jsx(PageTabs, {
645
+ label: "Settings sections",
646
+ children: [
647
+ /* @__PURE__ */ jsxs(Link, {
648
+ to: "/settings",
649
+ search: {},
650
+ activeOptions: current,
651
+ children: [/* @__PURE__ */ jsx(Settings, { size: 15 }), "General"]
652
+ }, "general"),
653
+ /* @__PURE__ */ jsxs(Link, {
654
+ to: "/settings",
655
+ search: { tab: "roles" },
656
+ activeOptions: { includeSearch: true },
657
+ children: [/* @__PURE__ */ jsx(ShieldCheck, { size: 15 }), "Roles"]
658
+ }, "roles"),
659
+ capabilities.runsInstance && /* @__PURE__ */ jsxs(Link, {
660
+ to: "/settings",
661
+ search: { tab: "keys" },
662
+ activeOptions: current,
663
+ children: [/* @__PURE__ */ jsx(Key, { size: 15 }), "Keys"]
664
+ }, "keys")
665
+ ]
666
+ }),
667
+ tab === void 0 ? /* @__PURE__ */ jsx(General, {}) : tab === "keys" ? /* @__PURE__ */ jsx(KeysTab, {}) : /* @__PURE__ */ jsx(RolesSettings, {
668
+ kind: roles === "global" ? "instance-role" : "role",
669
+ switcher: /* @__PURE__ */ jsxs("nav", {
670
+ className: "segmented",
671
+ "aria-label": "Roles",
672
+ children: [/* @__PURE__ */ jsx(Link, {
673
+ to: "/settings",
674
+ search: { tab: "roles" },
675
+ activeOptions: current,
676
+ children: "Project roles"
677
+ }), /* @__PURE__ */ jsx(Link, {
678
+ to: "/settings",
679
+ search: {
680
+ tab: "roles",
681
+ roles: "global"
682
+ },
683
+ activeOptions: current,
684
+ children: "Global roles"
685
+ })]
686
+ })
687
+ })
688
+ ] });
689
+ }
690
+ /** The instance, as its deployment set it up, and who creates service accounts. */
691
+ function General() {
587
692
  const { auth, capabilities } = useShell();
588
693
  const client = useCoffre();
589
694
  const { data: directory } = useSuspenseQuery(queries.directory(client, capabilities.canManageGrants));
590
- const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.runsInstance));
591
695
  const { data: settings } = useSuspenseQuery(queries.settings(client, capabilities.runsInstance));
592
696
  const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
593
697
  const principals = directory?.ok === true ? directory.principals : null;
594
698
  const users = principals?.filter((entry) => entry.principalType === "user").length ?? 0;
595
699
  const tokens = principals?.filter((entry) => entry.principalType === "service").length ?? 0;
596
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
597
- /* @__PURE__ */ jsx(PageHeader, { title: "Settings" }),
598
- /* @__PURE__ */ jsx(Card, {
599
- labelledBy: "instance",
600
- title: "Instance",
601
- description: "Set in the deployment's configuration, not here.",
602
- children: /* @__PURE__ */ jsxs("dl", {
603
- className: "facts",
604
- children: [/* @__PURE__ */ jsx(Fact, {
605
- label: "Sign-in",
606
- children: /* @__PURE__ */ jsxs("span", { children: [auth?.signin ? providers.join(", ") : "Cloudflare Access", /* @__PURE__ */ jsx(Toggletip, {
607
- label: auth?.signin ? "coffre’s own sign-in. Only invited members get in." : "Cloudflare Access signs people in, and coffre verifies each request.",
608
- children: /* @__PURE__ */ jsx("button", {
609
- type: "button",
610
- className: "fact-tip",
611
- "aria-label": "About sign-in",
612
- children: /* @__PURE__ */ jsx(Info, { size: 14 })
613
- })
614
- })] })
615
- }), principals !== null && /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Fact, {
616
- label: "Directory",
617
- children: /* @__PURE__ */ jsxs("span", { children: [
618
- /* @__PURE__ */ jsxs(Link, {
619
- to: "/users",
620
- children: [
621
- users,
622
- " user",
623
- users === 1 ? "" : "s"
624
- ]
625
- }),
626
- " · ",
627
- /* @__PURE__ */ jsxs(Link, {
628
- to: "/service-accounts",
629
- children: [
630
- tokens,
631
- " service account",
632
- tokens === 1 ? "" : "s"
633
- ]
634
- })
635
- ] })
636
- }) })]
637
- })
638
- }),
639
- /* @__PURE__ */ jsx(RolesSettings, {}),
640
- settings?.ok === true && /* @__PURE__ */ jsx(ServiceSetup, { scope: settings.serviceAccounts }),
641
- keys?.ok === true && /* @__PURE__ */ jsx(Keys, { keys })
642
- ] });
700
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Card, {
701
+ labelledBy: "instance",
702
+ title: "Instance",
703
+ description: "Set in the deployment's configuration, not here.",
704
+ children: /* @__PURE__ */ jsxs("dl", {
705
+ className: "facts",
706
+ children: [/* @__PURE__ */ jsx(Fact, {
707
+ label: "Sign-in",
708
+ children: /* @__PURE__ */ jsxs("span", { children: [auth?.signin ? providers.join(", ") : "Cloudflare Access", /* @__PURE__ */ jsx(Toggletip, {
709
+ label: auth?.signin ? "coffre’s own sign-in. Only invited members get in." : "Cloudflare Access signs people in, and coffre verifies each request.",
710
+ children: /* @__PURE__ */ jsx("button", {
711
+ type: "button",
712
+ className: "fact-tip",
713
+ "aria-label": "About sign-in",
714
+ children: /* @__PURE__ */ jsx(Info, { size: 14 })
715
+ })
716
+ })] })
717
+ }), principals !== null && /* @__PURE__ */ jsx(Fact, {
718
+ label: "Directory",
719
+ children: /* @__PURE__ */ jsxs("span", { children: [
720
+ /* @__PURE__ */ jsxs(Link, {
721
+ to: "/users",
722
+ children: [
723
+ users,
724
+ " user",
725
+ users === 1 ? "" : "s"
726
+ ]
727
+ }),
728
+ " · ",
729
+ /* @__PURE__ */ jsxs(Link, {
730
+ to: "/service-accounts",
731
+ children: [
732
+ tokens,
733
+ " service account",
734
+ tokens === 1 ? "" : "s"
735
+ ]
736
+ })
737
+ ] })
738
+ })]
739
+ })
740
+ }), settings?.ok === true && /* @__PURE__ */ jsx(ServiceSetup, { scope: settings.serviceAccounts })] });
643
741
  }
644
742
  /**
645
- * Who sets up service accounts without running the instance: anyone who
646
- * holds access, inside this scope, giving one at most what they hold there.
647
- * Narrowed, the rest takes an Admin whose own scope reaches it.
743
+ * Who creates service accounts without running the instance, and where:
744
+ * anyone who holds access, inside this scope, giving one at most what they
745
+ * hold there. Narrowed, the rest takes an Admin whose own scope reaches it.
648
746
  */
747
+ function serviceSetupInWords(scope) {
748
+ if (unscoped(scope)) return "Anyone with access, in every project and environment";
749
+ const { projects, environments } = scope;
750
+ if (projects !== "all" && "only" in projects && projects.only.length === 0 || environments !== "all" && "only" in environments && environments.only.length === 0) return "Admins only";
751
+ const where = scopeInWords(scope);
752
+ return `Anyone with access, in ${where.charAt(0).toLowerCase()}${where.slice(1)}; elsewhere, Admins`;
753
+ }
649
754
  function ServiceSetup({ scope }) {
650
755
  const client = useCoffre();
651
756
  const [open, setOpen] = useState(false);
@@ -659,24 +764,24 @@ function ServiceSetup({ scope }) {
659
764
  return /* @__PURE__ */ jsxs(Card, {
660
765
  labelledBy: "service-setup",
661
766
  title: "Service accounts",
662
- description: "Anyone who holds access sets up service accounts for CI where this lets them: the account, its tokens and its OIDC trust, giving it at most what they hold. Elsewhere, an Admin whose scope reaches it does.",
663
- actions: /* @__PURE__ */ jsxs("button", {
664
- className: "btn",
665
- type: "button",
666
- onClick: () => setOpen(true),
667
- children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Edit"]
668
- }),
669
767
  children: [/* @__PURE__ */ jsx("dl", {
670
768
  className: "facts",
671
769
  children: /* @__PURE__ */ jsx(Fact, {
672
- label: "Set up by people in",
673
- children: /* @__PURE__ */ jsx("span", { children: unscoped(scope) ? "Every project and environment" : scopeInWords(scope) })
770
+ label: "Who creates them",
771
+ action: /* @__PURE__ */ jsxs("button", {
772
+ className: "btn btn-sm",
773
+ type: "button",
774
+ onClick: () => setOpen(true),
775
+ "aria-label": "Edit who creates service accounts",
776
+ children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Edit"]
777
+ }),
778
+ children: /* @__PURE__ */ jsx("span", { children: serviceSetupInWords(scope) })
674
779
  })
675
780
  }), /* @__PURE__ */ jsx(Modal, {
676
781
  open,
677
782
  onOpenChange: (next) => next ? setOpen(true) : close(),
678
- title: "Who sets up service accounts",
679
- description: "People set up service accounts, and give them what they hold, in these projects and environments. All except prod keeps prod's to Admins.",
783
+ title: "Who creates service accounts",
784
+ description: "Anyone with access creates service accounts in these projects and environments, giving them at most what they hold there; elsewhere, Admins do. All except prod keeps prod's to Admins.",
680
785
  children: /* @__PURE__ */ jsxs("form", {
681
786
  className: "form",
682
787
  onSubmit: (event) => {
@@ -684,7 +789,7 @@ function ServiceSetup({ scope }) {
684
789
  run(() => client.settings.set({ serviceAccounts: draft }), {
685
790
  affects: affects.settings(),
686
791
  onSuccess: () => {
687
- toast.success("Saved where people set up service accounts");
792
+ toast.success("Saved who creates service accounts");
688
793
  setOpen(false);
689
794
  setError(null);
690
795
  }
@@ -716,6 +821,26 @@ function ServiceSetup({ scope }) {
716
821
  })]
717
822
  });
718
823
  }
824
+ function KeysTab() {
825
+ const { capabilities } = useShell();
826
+ const { data: keys } = useSuspenseQuery(queries.auditKeys(useCoffre(), capabilities.runsInstance));
827
+ if (keys === null) return null;
828
+ return keys.ok ? /* @__PURE__ */ jsx(Keys, { keys }) : /* @__PURE__ */ jsx(ErrorLine, { error: `The keys could not be read. ${keys.error}` });
829
+ }
830
+ /** Where a vault key is kept, in words: the deployment's own, or a key service's. */
831
+ function keptIn(provider) {
832
+ if (provider === "local") return "kept in the deployment's configuration";
833
+ if (provider === "aws-kms") return "kept in AWS KMS";
834
+ return `kept in ${provider}`;
835
+ }
836
+ /** A key's identifier by its end, `…3f9a2c`, enough to tell it from another; the whole of it a hover away. */
837
+ function KeyId({ id }) {
838
+ return /* @__PURE__ */ jsx("span", {
839
+ className: "mono",
840
+ title: id,
841
+ children: id.length <= 8 ? id : `…${id.slice(-6)}`
842
+ });
843
+ }
719
844
  /**
720
845
  * What the keys you keep are checked against: no secret, so shown. The keys
721
846
  * themselves are checked by `coffre verify keys`, on your machine: a vault
@@ -730,37 +855,32 @@ function Keys({ keys }) {
730
855
  description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
731
856
  "To check your vault key and app key against these, run ",
732
857
  /* @__PURE__ */ jsx("code", { children: "coffre verify keys" }),
733
- ". It reads them on your machine and sends neither."
858
+ "."
734
859
  ] }),
735
860
  children: /* @__PURE__ */ jsxs("dl", {
736
861
  className: "facts",
737
- children: [
738
- /* @__PURE__ */ jsx(Fact, {
739
- label: "Vault ID",
740
- children: /* @__PURE__ */ jsx("span", {
741
- className: "mono",
742
- children: current.vaultId
743
- })
744
- }),
745
- /* @__PURE__ */ jsx(Fact, {
746
- label: "Vault key",
747
- children: /* @__PURE__ */ jsxs("span", { children: [
748
- "Held by ",
749
- /* @__PURE__ */ jsx("span", {
750
- className: "mono",
751
- children: current.provider
752
- }),
753
- replaced > 0 && `; ${replaced} earlier vault key${replaced === 1 ? "" : "s"} still checkable`
754
- ] })
755
- }),
756
- /* @__PURE__ */ jsx(Fact, {
757
- label: "App key",
758
- children: /* @__PURE__ */ jsx("span", {
759
- className: "mono",
760
- children: keys.app.keyId
862
+ children: [/* @__PURE__ */ jsxs(Fact, {
863
+ label: "Vault key",
864
+ children: [/* @__PURE__ */ jsxs("span", { children: [
865
+ /* @__PURE__ */ jsx(KeyId, { id: current.vaultId }),
866
+ " ",
867
+ /* @__PURE__ */ jsxs("span", {
868
+ className: "muted",
869
+ children: ["· ", keptIn(current.provider)]
761
870
  })
762
- })
763
- ]
871
+ ] }), replaced > 0 && /* @__PURE__ */ jsxs("span", {
872
+ className: "muted",
873
+ children: [
874
+ replaced,
875
+ " earlier vault key",
876
+ replaced === 1 ? "" : "s",
877
+ " still checkable"
878
+ ]
879
+ })]
880
+ }), /* @__PURE__ */ jsx(Fact, {
881
+ label: "App key",
882
+ children: /* @__PURE__ */ jsx(KeyId, { id: keys.app.keyId })
883
+ })]
764
884
  })
765
885
  });
766
886
  }