@abinnovision/payloadcms-mcpx 2.0.0-beta.19 → 2.0.0-beta.20

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 (63) hide show
  1. package/dist/admin/capability-matrix.mjs +213 -316
  2. package/dist/admin/capability-toggles.mjs +24 -31
  3. package/dist/admin/confirmations-panel.mjs +61 -71
  4. package/dist/admin/confirmations.mjs +2 -1
  5. package/dist/admin/endpoint-url.mjs +7 -0
  6. package/dist/admin/setup-guide.mjs +2 -1
  7. package/dist/api-keys/capability-matrix.d.mts +3 -6
  8. package/dist/api-keys/capability-matrix.mjs +9 -48
  9. package/dist/api-keys/collection.mjs +2 -5
  10. package/dist/api-keys/confirmation-view.mjs +2 -1
  11. package/dist/api-keys/fields.mjs +33 -55
  12. package/dist/auth/resolve.mjs +29 -10
  13. package/dist/capabilities.d.mts +2 -0
  14. package/dist/capabilities.mjs +62 -19
  15. package/dist/endpoint/confirmations.mjs +14 -14
  16. package/dist/endpoint/handler.mjs +6 -22
  17. package/dist/endpoint/http.mjs +27 -0
  18. package/dist/endpoint/upload.mjs +11 -43
  19. package/dist/grants/confirmation.mjs +11 -42
  20. package/dist/grants/grant.mjs +58 -40
  21. package/dist/guards.mjs +8 -1
  22. package/dist/index.d.mts +2 -2
  23. package/dist/index.mjs +1 -1
  24. package/dist/options.mjs +34 -54
  25. package/dist/plugin.mjs +2 -1
  26. package/dist/request.mjs +5 -1
  27. package/dist/result.mjs +11 -1
  28. package/dist/schema/admin-hidden.mjs +4 -4
  29. package/dist/schema/describe.mjs +12 -18
  30. package/dist/schema/index.mjs +5 -6
  31. package/dist/schema/lexical-pointer.mjs +8 -8
  32. package/dist/schema/lexical.mjs +15 -13
  33. package/dist/schema/outline.mjs +4 -5
  34. package/dist/schema/path.mjs +4 -1
  35. package/dist/schema/pointer.mjs +11 -17
  36. package/dist/schema/shape.mjs +38 -50
  37. package/dist/schema/walk.mjs +57 -18
  38. package/dist/tools/create-document.mjs +16 -44
  39. package/dist/tools/delete-document.mjs +14 -17
  40. package/dist/tools/describe-schema.mjs +7 -5
  41. package/dist/tools/document.mjs +130 -44
  42. package/dist/tools/duplicate-document.mjs +11 -10
  43. package/dist/tools/find-documents.mjs +15 -20
  44. package/dist/tools/find-versions.mjs +10 -14
  45. package/dist/tools/get-document.mjs +8 -12
  46. package/dist/tools/links.mjs +2 -1
  47. package/dist/tools/list-capabilities.mjs +2 -1
  48. package/dist/tools/patch-document.mjs +12 -44
  49. package/dist/tools/publish-document.mjs +9 -27
  50. package/dist/tools/query-paths.mjs +1 -1
  51. package/dist/tools/run-confirmed.mjs +38 -50
  52. package/dist/tools/shared.mjs +43 -41
  53. package/dist/tools/validate-document.mjs +4 -6
  54. package/dist/tools/versions.mjs +11 -6
  55. package/dist/types.d.mts +12 -26
  56. package/dist/upload/file.mjs +10 -18
  57. package/dist/write/draft-guard.mjs +20 -20
  58. package/dist/write/patch.mjs +4 -4
  59. package/dist/write/publish-intent.mjs +22 -28
  60. package/dist/write/row-ids.mjs +3 -1
  61. package/dist/write/write-data.mjs +18 -31
  62. package/package.json +5 -5
  63. package/dist/builtin-tool-names.mjs +0 -19
@@ -1,16 +1,69 @@
1
1
  "use client";
2
- import { CAPABILITIES_FIELD } from "../capabilities.mjs";
3
- import { CAPABILITY_OPERATIONS, capabilityPaths, toolPath } from "../api-keys/capability-matrix.mjs";
2
+ import { ACCESS_CHAIN, CAPABILITIES_FIELD } from "../capabilities.mjs";
3
+ import { capabilityPaths, toolPath } from "../api-keys/capability-matrix.mjs";
4
4
  import { translateStatic } from "../i18n.mjs";
5
5
  import { accessLevelOf, accessLevelsOf, allAccessLevel, allDeleteMode, buildToggleActions, deleteModeOf, toolsState } from "./capability-toggles.mjs";
6
- import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { Button, CheckboxInput, FieldDescription, FieldLabel, Pill, useConfig, useForm, useFormFields, useTranslation } from "@payloadcms/ui";
8
8
  import { useCallback, useMemo } from "react";
9
9
  //#region src/admin/capability-matrix.tsx
10
10
  const BASE_CLASS = "mcpx-capabilities";
11
11
  const LIVE_WRITE = "Writes go live immediately.";
12
+ const cx = (...names) => names.filter(Boolean).join(" ");
12
13
  const SHEET = `
13
14
  .${BASE_CLASS} tbody tr:hover { background: var(--theme-elevation-50); }
15
+ .${BASE_CLASS}__sections {
16
+ display: flex;
17
+ flex-wrap: wrap;
18
+ gap: var(--base) calc(var(--base) * 2);
19
+ align-items: flex-start;
20
+ }
21
+ .${BASE_CLASS}__table {
22
+ table-layout: fixed;
23
+ width: auto;
24
+ border-collapse: separate;
25
+ border-spacing: 0;
26
+ text-align: left;
27
+ }
28
+ .${BASE_CLASS}__table thead { background: var(--theme-elevation-50); }
29
+ .${BASE_CLASS}__table th,
30
+ .${BASE_CLASS}__table td {
31
+ padding: calc(var(--base) * 0.6);
32
+ vertical-align: middle;
33
+ font-weight: normal;
34
+ text-align: center;
35
+ }
36
+ .${BASE_CLASS}__table thead th { color: var(--theme-elevation-400); }
37
+ .${BASE_CLASS}__table .${BASE_CLASS}__head { white-space: nowrap; }
38
+ .${BASE_CLASS}__table .${BASE_CLASS}__start { text-align: start; }
39
+ .${BASE_CLASS}__table .${BASE_CLASS}__row,
40
+ .${BASE_CLASS}__table .${BASE_CLASS}__title {
41
+ padding-inline-start: calc(var(--base) * 0.8);
42
+ text-align: inherit;
43
+ }
44
+ .${BASE_CLASS}__table .${BASE_CLASS}__row { word-break: break-word; }
45
+ .${BASE_CLASS}__table thead .${BASE_CLASS}__row { color: var(--theme-elevation-500); }
46
+ .${BASE_CLASS}__table .${BASE_CLASS}__title {
47
+ font-size: 0.8em;
48
+ letter-spacing: 0.08em;
49
+ text-transform: uppercase;
50
+ }
51
+ .${BASE_CLASS}__table td:last-child { padding-inline-end: calc(var(--base) * 0.8); }
52
+ .${BASE_CLASS}__table thead tr:first-child th:first-child { border-start-start-radius: var(--style-radius-s); }
53
+ .${BASE_CLASS}__table thead tr:first-child th:last-child { border-start-end-radius: var(--style-radius-s); }
54
+ .${BASE_CLASS}__table thead tr:last-child > * { border-bottom: 1px solid var(--theme-border-color); }
55
+ .${BASE_CLASS}__hint { display: block; color: var(--theme-elevation-400); }
56
+ .${BASE_CLASS}__badge {
57
+ display: inline-flex;
58
+ margin-inline-start: calc(var(--base) * 0.4);
59
+ vertical-align: middle;
60
+ cursor: help;
61
+ }
62
+ .${BASE_CLASS}__delete {
63
+ display: inline-flex;
64
+ align-items: center;
65
+ gap: calc(var(--base) * 0.4);
66
+ }
14
67
  .${BASE_CLASS}__segments {
15
68
  display: inline-flex;
16
69
  border: 1px solid var(--theme-elevation-150);
@@ -38,90 +91,6 @@ const SHEET = `
38
91
  .${BASE_CLASS}__shield:disabled { cursor: not-allowed; opacity: 0.6; }
39
92
  .${BASE_CLASS}__shield.${BASE_CLASS}__danger { color: var(--theme-error-500); }
40
93
  `;
41
- const CELL_PADDING = "calc(var(--base) * 0.6)";
42
- const EDGE_PADDING = "calc(var(--base) * 0.8)";
43
- const styles = {
44
- sections: {
45
- display: "flex",
46
- flexWrap: "wrap",
47
- gap: "var(--base) calc(var(--base) * 2)",
48
- alignItems: "flex-start"
49
- },
50
- table: {
51
- tableLayout: "fixed",
52
- width: "auto",
53
- borderCollapse: "separate",
54
- borderSpacing: 0,
55
- textAlign: "left"
56
- },
57
- head: { background: "var(--theme-elevation-50)" },
58
- headTitle: {
59
- padding: `${CELL_PADDING} ${CELL_PADDING} ${CELL_PADDING} ${EDGE_PADDING}`,
60
- verticalAlign: "middle",
61
- fontSize: "0.8em",
62
- letterSpacing: "0.08em",
63
- textTransform: "uppercase",
64
- color: "var(--theme-elevation-400)",
65
- fontWeight: "normal"
66
- },
67
- headOperation: {
68
- padding: CELL_PADDING,
69
- verticalAlign: "middle",
70
- color: "var(--theme-elevation-400)",
71
- fontWeight: "normal",
72
- textAlign: "center",
73
- whiteSpace: "nowrap"
74
- },
75
- headLabel: {
76
- padding: `${CELL_PADDING} ${CELL_PADDING} ${CELL_PADDING} ${EDGE_PADDING}`,
77
- verticalAlign: "middle",
78
- color: "var(--theme-elevation-500)",
79
- fontWeight: "normal"
80
- },
81
- rule: { borderBottom: "1px solid var(--theme-border-color)" },
82
- topStart: { borderStartStartRadius: "var(--style-radius-s)" },
83
- topEnd: { borderStartEndRadius: "var(--style-radius-s)" },
84
- rowHeader: {
85
- padding: `${CELL_PADDING} ${CELL_PADDING} ${CELL_PADDING} ${EDGE_PADDING}`,
86
- verticalAlign: "middle",
87
- fontWeight: "normal",
88
- wordBreak: "break-word"
89
- },
90
- hint: {
91
- display: "block",
92
- color: "var(--theme-elevation-400)"
93
- },
94
- badge: {
95
- display: "inline-flex",
96
- marginInlineStart: "calc(var(--base) * 0.4)",
97
- verticalAlign: "middle",
98
- cursor: "help"
99
- },
100
- visuallyHidden: {
101
- position: "absolute",
102
- width: "1px",
103
- height: "1px",
104
- overflow: "hidden",
105
- clip: "rect(0 0 0 0)",
106
- whiteSpace: "nowrap"
107
- },
108
- cell: {
109
- padding: CELL_PADDING,
110
- verticalAlign: "middle",
111
- textAlign: "center"
112
- },
113
- controlCell: {
114
- padding: CELL_PADDING,
115
- verticalAlign: "middle",
116
- textAlign: "start"
117
- },
118
- lastCell: { paddingInlineEnd: EDGE_PADDING },
119
- deleteControls: {
120
- display: "inline-flex",
121
- alignItems: "center",
122
- gap: "calc(var(--base) * 0.4)"
123
- }
124
- };
125
94
  const Box = ({ label, onChange, readOnly, state }) => /*#__PURE__*/ jsx(CheckboxInput, {
126
95
  checked: state === "on",
127
96
  name: label,
@@ -129,11 +98,13 @@ const Box = ({ label, onChange, readOnly, state }) => /*#__PURE__*/ jsx(Checkbox
129
98
  partialChecked: state === "mixed",
130
99
  readOnly
131
100
  });
101
+ const deleteBoxState = (mode) => mode === void 0 ? "mixed" : mode === "off" ? "off" : "on";
102
+ const nextDeleteMode = (mode) => mode === "off" || mode === void 0 ? "approve" : "off";
132
103
  const ACCESS_OPTIONS = [{
133
104
  id: "none",
134
105
  label: "None",
135
106
  title: "No access"
136
- }, ...CAPABILITY_OPERATIONS.filter((operation) => operation.id !== "delete").map((operation) => ({
107
+ }, ...ACCESS_CHAIN.map((operation) => ({
137
108
  id: operation.id,
138
109
  label: operation.label,
139
110
  title: operation.description
@@ -194,17 +165,8 @@ const LABEL_WIDTH = "calc(var(--base) * 11)";
194
165
  const OPERATION_WIDTH = "calc(var(--base) * 3.5)";
195
166
  const ACCESS_WIDTH = "calc(var(--base) * 13)";
196
167
  const DELETE_WIDTH = "calc(var(--base) * 4)";
197
- const Columns = ({ widths }) => /*#__PURE__*/ jsxs("colgroup", { children: [/*#__PURE__*/ jsx("col", { style: { width: LABEL_WIDTH } }), widths.map((width, index) => /*#__PURE__*/ jsx("col", { style: { width } }, index))] });
198
- const lastCellStyle = {
199
- ...styles.cell,
200
- ...styles.lastCell
201
- };
202
- const controlStyle = (isLast) => isLast ? {
203
- ...styles.controlCell,
204
- ...styles.lastCell
205
- } : styles.controlCell;
206
168
  const LiveBadge = () => /*#__PURE__*/ jsx("span", {
207
- style: styles.badge,
169
+ className: `${BASE_CLASS}__badge`,
208
170
  title: LIVE_WRITE,
209
171
  children: /*#__PURE__*/ jsxs(Pill, {
210
172
  pillStyle: "warning",
@@ -213,17 +175,17 @@ const LiveBadge = () => /*#__PURE__*/ jsx("span", {
213
175
  "aria-hidden": "true",
214
176
  children: "Live"
215
177
  }), /*#__PURE__*/ jsx("span", {
216
- style: styles.visuallyHidden,
178
+ className: "sr-only",
217
179
  children: LIVE_WRITE
218
180
  })]
219
181
  })
220
182
  });
221
183
  const APPROVED_ALWAYS = "Always approved: the plugin config does not allow unattended deletes";
222
- const ApprovalToggle = ({ label, locked = false, onToggle, operation, pressed, readOnly }) => {
223
- const title = locked ? APPROVED_ALWAYS : pressed ? `A person approves each ${operation}` : `Each ${operation} runs without approval`;
184
+ const ApprovalToggle = ({ label, locked = false, onToggle, pressed, readOnly }) => {
185
+ const title = locked ? APPROVED_ALWAYS : pressed ? "A person approves each delete" : "Each delete runs without approval";
224
186
  return /*#__PURE__*/ jsxs("button", {
225
187
  "aria-pressed": pressed,
226
- className: [`${BASE_CLASS}__shield`, !pressed && `${BASE_CLASS}__danger`].filter(Boolean).join(" "),
188
+ className: cx(`${BASE_CLASS}__shield`, !pressed && `${BASE_CLASS}__danger`),
227
189
  disabled: readOnly || locked,
228
190
  onClick: onToggle,
229
191
  title,
@@ -240,11 +202,31 @@ const ApprovalToggle = ({ label, locked = false, onToggle, operation, pressed, r
240
202
  width: "16",
241
203
  children: [/*#__PURE__*/ jsx("path", { d: "M12 3l8 3v6c0 4.5-3.2 8-8 9-4.8-1-8-4.5-8-9V6z" }), pressed ? /*#__PURE__*/ jsx("path", { d: "M9 12l2 2 4-4" }) : null]
242
204
  }), /*#__PURE__*/ jsx("span", {
243
- style: styles.visuallyHidden,
205
+ className: "sr-only",
244
206
  children: `${label}: ${title}`
245
207
  })]
246
208
  });
247
209
  };
210
+ const MatrixTable = ({ all, children, heads, start = false, title, widths }) => /*#__PURE__*/ jsx("section", { children: /*#__PURE__*/ jsxs("table", {
211
+ className: `${BASE_CLASS}__table`,
212
+ children: [
213
+ /*#__PURE__*/ jsxs("colgroup", { children: [/*#__PURE__*/ jsx("col", { style: { width: LABEL_WIDTH } }), widths.map((width, index) => /*#__PURE__*/ jsx("col", { style: { width } }, index))] }),
214
+ /*#__PURE__*/ jsxs("thead", { children: [/*#__PURE__*/ jsxs("tr", { children: [/*#__PURE__*/ jsx("th", {
215
+ className: `${BASE_CLASS}__title`,
216
+ scope: "col",
217
+ children: title
218
+ }), heads.map((head) => /*#__PURE__*/ jsx("th", {
219
+ className: `${BASE_CLASS}__head${start ? ` ${BASE_CLASS}__start` : ""}`,
220
+ scope: "col",
221
+ children: head
222
+ }, head))] }), /*#__PURE__*/ jsxs("tr", { children: [/*#__PURE__*/ jsx("th", {
223
+ className: `${BASE_CLASS}__row`,
224
+ scope: "row",
225
+ children: "All"
226
+ }), all] })] }),
227
+ /*#__PURE__*/ jsx("tbody", { children })
228
+ ]
229
+ }) });
248
230
  const NamespaceTable = ({ matrix, namespace, path, readOnly, toggle, values }) => {
249
231
  const rows = matrix[namespace.id];
250
232
  const withDelete = rows.some((row) => row.delete);
@@ -255,233 +237,154 @@ const NamespaceTable = ({ matrix, namespace, path, readOnly, toggle, values }) =
255
237
  const { getEntityConfig } = useConfig();
256
238
  const nameOf = (row) => translateStatic(namespace.id === "collections" ? getEntityConfig({ collectionSlug: row.slug }).labels.plural : getEntityConfig({ globalSlug: row.slug }).label, i18n) ?? row.slug;
257
239
  const allDelete = allDeleteMode(matrix, path, namespace.id, values);
258
- return /*#__PURE__*/ jsx("section", { children: /*#__PURE__*/ jsxs("table", {
259
- style: styles.table,
260
- children: [
261
- /*#__PURE__*/ jsx(Columns, { widths: withDelete ? [ACCESS_WIDTH, DELETE_WIDTH] : [ACCESS_WIDTH] }),
262
- /*#__PURE__*/ jsxs("thead", {
263
- style: styles.head,
264
- children: [/*#__PURE__*/ jsxs("tr", { children: [
265
- /*#__PURE__*/ jsx("th", {
266
- scope: "col",
267
- style: {
268
- ...styles.headTitle,
269
- ...styles.topStart
270
- },
271
- children: namespace.title
272
- }),
273
- /*#__PURE__*/ jsx("th", {
274
- scope: "col",
275
- style: {
276
- ...styles.headOperation,
277
- textAlign: "start",
278
- ...withDelete ? {} : styles.topEnd
279
- },
280
- children: "Access"
281
- }),
282
- withDelete ? /*#__PURE__*/ jsx("th", {
283
- scope: "col",
284
- style: {
285
- ...styles.headOperation,
286
- textAlign: "start",
287
- ...styles.topEnd
288
- },
289
- children: "Delete"
290
- }) : null
291
- ] }), /*#__PURE__*/ jsxs("tr", { children: [
292
- /*#__PURE__*/ jsx("th", {
293
- scope: "row",
294
- style: {
295
- ...styles.headLabel,
296
- ...styles.rule
297
- },
298
- children: "All"
299
- }),
300
- /*#__PURE__*/ jsx("td", {
301
- style: {
302
- ...controlStyle(!withDelete),
303
- ...styles.rule
304
- },
305
- children: /*#__PURE__*/ jsx(Segments, {
306
- included: includedBelow(allOptions, allLevel),
307
- label: `Access for every ${entries} entry`,
308
- onSelect: (level) => {
309
- toggle({
310
- kind: "access",
311
- namespace: namespace.id,
312
- level
313
- });
314
- },
315
- options: allOptions,
316
- readOnly,
317
- selected: allLevel
240
+ return /*#__PURE__*/ jsx(MatrixTable, {
241
+ all: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx("td", {
242
+ className: `${BASE_CLASS}__start`,
243
+ children: /*#__PURE__*/ jsx(Segments, {
244
+ included: includedBelow(allOptions, allLevel),
245
+ label: `Access for every ${entries} entry`,
246
+ onSelect: (level) => {
247
+ toggle({
248
+ kind: "access",
249
+ namespace: namespace.id,
250
+ level
251
+ });
252
+ },
253
+ options: allOptions,
254
+ readOnly,
255
+ selected: allLevel
256
+ })
257
+ }), withDelete ? /*#__PURE__*/ jsx("td", {
258
+ className: `${BASE_CLASS}__start`,
259
+ children: /*#__PURE__*/ jsx(Box, {
260
+ label: `Delete for every ${entries} entry`,
261
+ onChange: () => {
262
+ toggle({
263
+ kind: "deleteMode",
264
+ namespace: namespace.id,
265
+ mode: nextDeleteMode(allDelete)
266
+ });
267
+ },
268
+ readOnly,
269
+ state: deleteBoxState(allDelete)
270
+ })
271
+ }) : null] }),
272
+ heads: withDelete ? ["Access", "Delete"] : ["Access"],
273
+ start: true,
274
+ title: namespace.title,
275
+ widths: withDelete ? [ACCESS_WIDTH, DELETE_WIDTH] : [ACCESS_WIDTH],
276
+ children: rows.map((row) => {
277
+ const options = accessOptions([row]);
278
+ const level = accessLevelOf(path, namespace.id, row, values);
279
+ const mode = deleteModeOf(path, namespace.id, row, values);
280
+ const name = nameOf(row);
281
+ return /*#__PURE__*/ jsxs("tr", { children: [
282
+ /*#__PURE__*/ jsxs("th", {
283
+ className: `${BASE_CLASS}__row`,
284
+ scope: "row",
285
+ children: [
286
+ name,
287
+ row.live ? /*#__PURE__*/ jsx(LiveBadge, {}) : null,
288
+ name === row.slug ? null : /*#__PURE__*/ jsx("span", {
289
+ className: `${BASE_CLASS}__hint`,
290
+ children: row.slug
318
291
  })
319
- }),
320
- withDelete ? /*#__PURE__*/ jsx("td", {
321
- style: {
322
- ...controlStyle(true),
323
- ...styles.rule
292
+ ]
293
+ }),
294
+ /*#__PURE__*/ jsx("td", {
295
+ className: `${BASE_CLASS}__start`,
296
+ children: /*#__PURE__*/ jsx(Segments, {
297
+ included: includedBelow(options, level),
298
+ label: `Access for ${name}`,
299
+ onSelect: (next) => {
300
+ toggle({
301
+ kind: "access",
302
+ namespace: namespace.id,
303
+ fieldName: row.fieldName,
304
+ level: next
305
+ });
324
306
  },
325
- children: /*#__PURE__*/ jsx(Box, {
326
- label: `Delete for every ${entries} entry`,
307
+ options,
308
+ readOnly,
309
+ selected: level
310
+ })
311
+ }),
312
+ withDelete ? /*#__PURE__*/ jsx("td", {
313
+ className: `${BASE_CLASS}__start`,
314
+ children: row.delete ? /*#__PURE__*/ jsxs("span", {
315
+ className: `${BASE_CLASS}__delete`,
316
+ children: [/*#__PURE__*/ jsx(Box, {
317
+ label: `Delete ${name}`,
327
318
  onChange: () => {
328
319
  toggle({
329
320
  kind: "deleteMode",
330
321
  namespace: namespace.id,
331
- mode: allDelete === "off" || allDelete === void 0 ? "approve" : "off"
322
+ fieldName: row.fieldName,
323
+ mode: nextDeleteMode(mode)
332
324
  });
333
325
  },
334
326
  readOnly,
335
- state: allDelete === void 0 ? "mixed" : allDelete === "off" ? "off" : "on"
336
- })
337
- }) : null
338
- ] })]
339
- }),
340
- /*#__PURE__*/ jsx("tbody", { children: rows.map((row) => {
341
- const options = accessOptions([row]);
342
- const level = accessLevelOf(path, namespace.id, row, values);
343
- const mode = deleteModeOf(path, namespace.id, row, values);
344
- const name = nameOf(row);
345
- return /*#__PURE__*/ jsxs("tr", { children: [
346
- /*#__PURE__*/ jsxs("th", {
347
- scope: "row",
348
- style: styles.rowHeader,
349
- children: [
350
- name,
351
- row.live ? /*#__PURE__*/ jsx(LiveBadge, {}) : null,
352
- name === row.slug ? null : /*#__PURE__*/ jsx("span", {
353
- style: styles.hint,
354
- children: row.slug
355
- })
356
- ]
357
- }),
358
- /*#__PURE__*/ jsx("td", {
359
- style: controlStyle(!withDelete),
360
- children: /*#__PURE__*/ jsx(Segments, {
361
- included: includedBelow(options, level),
362
- label: `Access for ${name}`,
363
- onSelect: (next) => {
327
+ state: deleteBoxState(mode)
328
+ }), mode === "off" ? null : /*#__PURE__*/ jsx(ApprovalToggle, {
329
+ label: `Approval for deleting ${name}`,
330
+ locked: !row.deleteUnattended,
331
+ onToggle: () => {
364
332
  toggle({
365
- kind: "access",
333
+ kind: "deleteMode",
366
334
  namespace: namespace.id,
367
335
  fieldName: row.fieldName,
368
- level: next
336
+ mode: mode === "trash" ? "approve" : "trash"
369
337
  });
370
338
  },
371
- options,
372
- readOnly,
373
- selected: level
374
- })
375
- }),
376
- withDelete ? /*#__PURE__*/ jsx("td", {
377
- style: controlStyle(true),
378
- children: row.delete ? /*#__PURE__*/ jsxs("span", {
379
- style: styles.deleteControls,
380
- children: [/*#__PURE__*/ jsx(Box, {
381
- label: `Delete ${name}`,
382
- onChange: () => {
383
- toggle({
384
- kind: "deleteMode",
385
- namespace: namespace.id,
386
- fieldName: row.fieldName,
387
- mode: mode === "off" ? "approve" : "off"
388
- });
389
- },
390
- readOnly,
391
- state: mode === "off" ? "off" : "on"
392
- }), mode === "off" ? null : /*#__PURE__*/ jsx(ApprovalToggle, {
393
- label: `Approval for deleting ${name}`,
394
- locked: !row.deleteUnattended,
395
- onToggle: () => {
396
- toggle({
397
- kind: "deleteMode",
398
- namespace: namespace.id,
399
- fieldName: row.fieldName,
400
- mode: mode === "trash" ? "approve" : "trash"
401
- });
402
- },
403
- operation: "delete",
404
- pressed: mode !== "trash",
405
- readOnly
406
- })]
407
- }) : null
339
+ pressed: mode !== "trash",
340
+ readOnly
341
+ })]
408
342
  }) : null
409
- ] }, row.fieldName);
410
- }) })
411
- ]
412
- }) });
343
+ }) : null
344
+ ] }, row.fieldName);
345
+ })
346
+ });
413
347
  };
414
348
  const ToolsTable = ({ matrix, path, readOnly, toggle, values }) => {
415
349
  const toolState = toolsState(matrix, path, values);
416
- return /*#__PURE__*/ jsx("section", { children: /*#__PURE__*/ jsxs("table", {
417
- style: styles.table,
418
- children: [
419
- /*#__PURE__*/ jsx(Columns, { widths: [OPERATION_WIDTH] }),
420
- /*#__PURE__*/ jsxs("thead", {
421
- style: styles.head,
422
- children: [/*#__PURE__*/ jsxs("tr", { children: [/*#__PURE__*/ jsx("th", {
423
- scope: "col",
424
- style: {
425
- ...styles.headTitle,
426
- ...styles.topStart
427
- },
428
- children: "Tools"
429
- }), /*#__PURE__*/ jsx("th", {
430
- scope: "col",
431
- style: {
432
- ...styles.headOperation,
433
- ...styles.topEnd
434
- },
435
- children: "Enabled"
436
- })] }), /*#__PURE__*/ jsxs("tr", { children: [/*#__PURE__*/ jsx("th", {
437
- scope: "row",
438
- style: {
439
- ...styles.headLabel,
440
- ...styles.rule
441
- },
442
- children: "All"
443
- }), /*#__PURE__*/ jsx("td", {
444
- style: {
445
- ...lastCellStyle,
446
- ...styles.rule
447
- },
448
- children: /*#__PURE__*/ jsx(Box, {
449
- label: "Enable every tool",
450
- onChange: () => {
451
- toggle({
452
- kind: "tools",
453
- value: toolState !== "on"
454
- });
455
- },
456
- readOnly,
457
- state: toolState
458
- })
459
- })] })]
460
- }),
461
- /*#__PURE__*/ jsx("tbody", { children: matrix.tools.map((tool) => /*#__PURE__*/ jsxs("tr", { children: [/*#__PURE__*/ jsxs("th", {
350
+ return /*#__PURE__*/ jsx(MatrixTable, {
351
+ all: /*#__PURE__*/ jsx("td", { children: /*#__PURE__*/ jsx(Box, {
352
+ label: "Enable every tool",
353
+ onChange: () => {
354
+ toggle({
355
+ kind: "tools",
356
+ value: toolState !== "on"
357
+ });
358
+ },
359
+ readOnly,
360
+ state: toolState
361
+ }) }),
362
+ heads: ["Enabled"],
363
+ title: "Tools",
364
+ widths: [OPERATION_WIDTH],
365
+ children: matrix.tools.map((tool) => {
366
+ const granted = values[toolPath(path, tool.name)] === true;
367
+ return /*#__PURE__*/ jsxs("tr", { children: [/*#__PURE__*/ jsxs("th", {
368
+ className: `${BASE_CLASS}__row`,
462
369
  scope: "row",
463
- style: styles.rowHeader,
464
370
  children: [tool.name, /*#__PURE__*/ jsx("span", {
465
- style: styles.hint,
371
+ className: `${BASE_CLASS}__hint`,
466
372
  children: tool.description
467
373
  })]
468
- }), /*#__PURE__*/ jsx("td", {
469
- style: lastCellStyle,
470
- children: /*#__PURE__*/ jsx(Box, {
471
- label: `Enable ${tool.name}`,
472
- onChange: () => {
473
- toggle({
474
- kind: "tool",
475
- name: tool.name,
476
- value: values[toolPath(path, tool.name)] !== true
477
- });
478
- },
479
- readOnly,
480
- state: values[toolPath(path, tool.name)] === true ? "on" : "off"
481
- })
482
- })] }, tool.name)) })
483
- ]
484
- }) });
374
+ }), /*#__PURE__*/ jsx("td", { children: /*#__PURE__*/ jsx(Box, {
375
+ label: `Enable ${tool.name}`,
376
+ onChange: () => {
377
+ toggle({
378
+ kind: "tool",
379
+ name: tool.name,
380
+ value: !granted
381
+ });
382
+ },
383
+ readOnly,
384
+ state: granted ? "on" : "off"
385
+ }) })] }, tool.name);
386
+ })
387
+ });
485
388
  };
486
389
  /**
487
390
  * What an API key may do, as one table per namespace: a row per entity with
@@ -514,13 +417,7 @@ const ToolsTable = ({ matrix, path, readOnly, toggle, values }) => {
514
417
  title: "Globals"
515
418
  }].filter((namespace) => matrix[namespace.id].length > 0);
516
419
  return /*#__PURE__*/ jsxs("div", {
517
- className: [
518
- "field-type",
519
- "group-field",
520
- "group-field--top-level",
521
- withinTab && "group-field--within-tab",
522
- BASE_CLASS
523
- ].filter(Boolean).join(" "),
420
+ className: cx("field-type", "group-field", "group-field--top-level", withinTab && "group-field--within-tab", BASE_CLASS),
524
421
  children: [/*#__PURE__*/ jsx("style", { children: SHEET }), /*#__PURE__*/ jsxs("div", {
525
422
  className: "group-field__wrap",
526
423
  children: [/*#__PURE__*/ jsx("div", {
@@ -536,7 +433,7 @@ const ToolsTable = ({ matrix, path, readOnly, toggle, values }) => {
536
433
  path
537
434
  }) : null] })
538
435
  }), /*#__PURE__*/ jsxs("div", {
539
- style: styles.sections,
436
+ className: `${BASE_CLASS}__sections`,
540
437
  children: [namespaces.map((namespace) => /*#__PURE__*/ jsx(NamespaceTable, {
541
438
  matrix,
542
439
  namespace,