@abinnovision/payloadcms-mcpx 2.0.0-beta.19 → 2.0.0-beta.22
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/README.md +2 -2
- package/dist/admin/capability-matrix.mjs +213 -316
- package/dist/admin/capability-toggles.mjs +24 -31
- package/dist/admin/confirmations-panel.mjs +61 -71
- package/dist/admin/confirmations.mjs +2 -1
- package/dist/admin/endpoint-url.mjs +7 -0
- package/dist/admin/setup-guide.d.mts +3 -3
- package/dist/admin/setup-guide.mjs +51 -33
- package/dist/api-keys/capability-matrix.d.mts +3 -6
- package/dist/api-keys/capability-matrix.mjs +9 -48
- package/dist/api-keys/collection.mjs +9 -7
- package/dist/api-keys/confirmation-view.mjs +2 -1
- package/dist/api-keys/fields.mjs +36 -66
- package/dist/auth/resolve.mjs +29 -10
- package/dist/capabilities.d.mts +2 -0
- package/dist/capabilities.mjs +62 -19
- package/dist/endpoint/confirmations.mjs +14 -14
- package/dist/endpoint/handler.mjs +6 -22
- package/dist/endpoint/http.mjs +27 -0
- package/dist/endpoint/upload.mjs +11 -43
- package/dist/grants/confirmation.mjs +11 -42
- package/dist/grants/grant.mjs +58 -40
- package/dist/guards.mjs +8 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/options.mjs +34 -54
- package/dist/plugin.mjs +2 -1
- package/dist/request.mjs +5 -1
- package/dist/result.mjs +11 -1
- package/dist/schema/admin-hidden.mjs +4 -4
- package/dist/schema/describe.mjs +12 -18
- package/dist/schema/index.mjs +5 -6
- package/dist/schema/lexical-pointer.mjs +8 -8
- package/dist/schema/lexical.mjs +15 -13
- package/dist/schema/outline.mjs +4 -5
- package/dist/schema/path.mjs +4 -1
- package/dist/schema/pointer.mjs +11 -17
- package/dist/schema/shape.mjs +38 -50
- package/dist/schema/walk.mjs +57 -18
- package/dist/tools/create-document.mjs +16 -44
- package/dist/tools/delete-document.mjs +14 -17
- package/dist/tools/describe-schema.mjs +7 -5
- package/dist/tools/document.mjs +130 -44
- package/dist/tools/duplicate-document.mjs +11 -10
- package/dist/tools/find-documents.mjs +15 -20
- package/dist/tools/find-versions.mjs +10 -14
- package/dist/tools/get-document.mjs +8 -12
- package/dist/tools/links.mjs +2 -1
- package/dist/tools/list-capabilities.mjs +2 -1
- package/dist/tools/patch-document.mjs +12 -44
- package/dist/tools/publish-document.mjs +9 -27
- package/dist/tools/query-paths.mjs +1 -1
- package/dist/tools/run-confirmed.mjs +38 -50
- package/dist/tools/shared.mjs +43 -41
- package/dist/tools/validate-document.mjs +4 -6
- package/dist/tools/versions.mjs +11 -6
- package/dist/types.d.mts +15 -28
- package/dist/upload/file.mjs +10 -18
- package/dist/write/draft-guard.mjs +20 -20
- package/dist/write/patch.mjs +4 -4
- package/dist/write/publish-intent.mjs +22 -28
- package/dist/write/row-ids.mjs +3 -1
- package/dist/write/write-data.mjs +18 -31
- package/package.json +7 -7
- package/dist/builtin-tool-names.mjs +0 -19
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ claude mcp add --transport http payload http://localhost:3000/api/mcpx \
|
|
|
82
82
|
|
|
83
83
|
Claude Desktop and the MCP Inspector are covered in
|
|
84
84
|
[`docs/integration.md`](./docs/integration.md#connecting-other-clients). Saved keys also have a
|
|
85
|
-
"Connect a client"
|
|
85
|
+
"Connect a client" button that opens ready-to-paste snippets.
|
|
86
86
|
|
|
87
87
|
## Options
|
|
88
88
|
|
|
@@ -96,7 +96,7 @@ Claude Desktop and the MCP Inspector are covered in
|
|
|
96
96
|
| `globals` | `{}` | Globals to expose, with `read`, `write` and `publish`. |
|
|
97
97
|
| `userCollection` | `config.admin.user`, then `users` | Auth collection whose users the keys act as. |
|
|
98
98
|
| `apiKeys.slug` | `mcpx-api-keys` | Slug of the key collection. |
|
|
99
|
-
| `apiKeys.setupGuide` | `true` | Add the "Connect a client"
|
|
99
|
+
| `apiKeys.setupGuide` | `true` | Add the "Connect a client" button to saved keys. |
|
|
100
100
|
| `apiKeys.overrideCollection` | none | Function that receives the key collection and returns it. |
|
|
101
101
|
| `endpoint.path` | `/mcpx` | Endpoint path below the API route. |
|
|
102
102
|
| `limits.maxLimit` | `25` | Highest `limit` a client may pass to a list tool. |
|
|
@@ -1,16 +1,69 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { CAPABILITIES_FIELD } from "../capabilities.mjs";
|
|
3
|
-
import {
|
|
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
|
-
}, ...
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
223
|
-
const title = locked ? APPROVED_ALWAYS : pressed ?
|
|
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:
|
|
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
|
-
|
|
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(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
/*#__PURE__*/ jsx(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
326
|
-
|
|
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
|
-
|
|
322
|
+
fieldName: row.fieldName,
|
|
323
|
+
mode: nextDeleteMode(mode)
|
|
332
324
|
});
|
|
333
325
|
},
|
|
334
326
|
readOnly,
|
|
335
|
-
state:
|
|
336
|
-
})
|
|
337
|
-
|
|
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: "
|
|
333
|
+
kind: "deleteMode",
|
|
366
334
|
namespace: namespace.id,
|
|
367
335
|
fieldName: row.fieldName,
|
|
368
|
-
|
|
336
|
+
mode: mode === "trash" ? "approve" : "trash"
|
|
369
337
|
});
|
|
370
338
|
},
|
|
371
|
-
|
|
372
|
-
readOnly
|
|
373
|
-
|
|
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
|
-
|
|
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(
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
371
|
+
className: `${BASE_CLASS}__hint`,
|
|
466
372
|
children: tool.description
|
|
467
373
|
})]
|
|
468
|
-
}), /*#__PURE__*/ jsx("td", {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
-
|
|
436
|
+
className: `${BASE_CLASS}__sections`,
|
|
540
437
|
children: [namespaces.map((namespace) => /*#__PURE__*/ jsx(NamespaceTable, {
|
|
541
438
|
matrix,
|
|
542
439
|
namespace,
|