@byline/ui 2.4.0 → 2.4.2
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/react.d.ts +10 -18
- package/dist/react.js +2 -15
- package/dist/{admin/components/collections → widgets/diff-viewer}/diff-modal.d.ts +8 -1
- package/dist/{admin/components/collections → widgets/diff-viewer}/diff-modal.js +4 -6
- package/dist/widgets/diff-viewer/diff-modal.module.js +14 -0
- package/dist/{admin/components/collections → widgets/diff-viewer}/diff-modal_module.css +9 -9
- package/dist/{admin/components/collections → widgets/status-badge}/status-badge.js +1 -1
- package/dist/{admin/components/collections → widgets/status-badge}/status-badge.module.js +3 -3
- package/dist/{admin/components/collections → widgets/status-badge}/status-badge_module.css +3 -3
- package/package.json +2 -4
- package/src/react.ts +12 -34
- package/src/{admin/components/collections → widgets/diff-viewer}/diff-modal.tsx +16 -5
- package/src/{admin/components/collections → widgets/status-badge}/status-badge.tsx +1 -1
- package/dist/admin/components/admin-account/change-password.d.ts +0 -8
- package/dist/admin/components/admin-account/change-password.js +0 -192
- package/dist/admin/components/admin-account/change-password.module.js +0 -8
- package/dist/admin/components/admin-account/change-password_module.css +0 -27
- package/dist/admin/components/admin-account/container.d.ts +0 -29
- package/dist/admin/components/admin-account/container.js +0 -299
- package/dist/admin/components/admin-account/container.module.js +0 -28
- package/dist/admin/components/admin-account/container_module.css +0 -106
- package/dist/admin/components/admin-account/update.d.ts +0 -8
- package/dist/admin/components/admin-account/update.js +0 -207
- package/dist/admin/components/admin-account/update.module.js +0 -8
- package/dist/admin/components/admin-account/update_module.css +0 -27
- package/dist/admin/components/admin-permissions/inspector.d.ts +0 -4
- package/dist/admin/components/admin-permissions/inspector.js +0 -284
- package/dist/admin/components/admin-permissions/inspector.module.js +0 -56
- package/dist/admin/components/admin-permissions/inspector_module.css +0 -238
- package/dist/admin/components/admin-roles/create.d.ts +0 -7
- package/dist/admin/components/admin-roles/create.js +0 -177
- package/dist/admin/components/admin-roles/create.module.js +0 -8
- package/dist/admin/components/admin-roles/create_module.css +0 -27
- package/dist/admin/components/admin-roles/permissions.d.ts +0 -10
- package/dist/admin/components/admin-roles/permissions.js +0 -303
- package/dist/admin/components/admin-roles/permissions.module.js +0 -44
- package/dist/admin/components/admin-roles/permissions_module.css +0 -192
- package/dist/admin/components/admin-roles/update.d.ts +0 -8
- package/dist/admin/components/admin-roles/update.js +0 -166
- package/dist/admin/components/admin-roles/update.module.js +0 -8
- package/dist/admin/components/admin-roles/update_module.css +0 -27
- package/dist/admin/components/admin-users/create.d.ts +0 -8
- package/dist/admin/components/admin-users/create.js +0 -268
- package/dist/admin/components/admin-users/create.module.js +0 -10
- package/dist/admin/components/admin-users/create_module.css +0 -45
- package/dist/admin/components/admin-users/roles.d.ts +0 -11
- package/dist/admin/components/admin-users/roles.js +0 -148
- package/dist/admin/components/admin-users/roles.module.js +0 -18
- package/dist/admin/components/admin-users/roles_module.css +0 -75
- package/dist/admin/components/admin-users/set-password.d.ts +0 -8
- package/dist/admin/components/admin-users/set-password.js +0 -170
- package/dist/admin/components/admin-users/set-password.module.js +0 -9
- package/dist/admin/components/admin-users/set-password_module.css +0 -31
- package/dist/admin/components/admin-users/update.d.ts +0 -8
- package/dist/admin/components/admin-users/update.js +0 -254
- package/dist/admin/components/admin-users/update.module.js +0 -9
- package/dist/admin/components/admin-users/update_module.css +0 -34
- package/dist/admin/components/auth/sign-in-form.d.ts +0 -12
- package/dist/admin/components/auth/sign-in-form.js +0 -115
- package/dist/admin/components/auth/sign-in-form.module.js +0 -12
- package/dist/admin/components/auth/sign-in-form_module.css +0 -41
- package/dist/admin/components/collections/diff-modal.module.js +0 -14
- package/dist/services/admin-services-context.d.ts +0 -16
- package/dist/services/admin-services-context.js +0 -13
- package/dist/services/admin-services-types.d.ts +0 -129
- package/dist/services/admin-services-types.js +0 -1
- package/src/admin/components/admin-account/change-password.module.css +0 -40
- package/src/admin/components/admin-account/change-password.tsx +0 -232
- package/src/admin/components/admin-account/container.module.css +0 -158
- package/src/admin/components/admin-account/container.tsx +0 -230
- package/src/admin/components/admin-account/update.module.css +0 -40
- package/src/admin/components/admin-account/update.tsx +0 -263
- package/src/admin/components/admin-permissions/inspector.module.css +0 -326
- package/src/admin/components/admin-permissions/inspector.tsx +0 -298
- package/src/admin/components/admin-roles/create.module.css +0 -40
- package/src/admin/components/admin-roles/create.tsx +0 -218
- package/src/admin/components/admin-roles/permissions.module.css +0 -279
- package/src/admin/components/admin-roles/permissions.tsx +0 -396
- package/src/admin/components/admin-roles/update.module.css +0 -40
- package/src/admin/components/admin-roles/update.tsx +0 -218
- package/src/admin/components/admin-users/create.module.css +0 -63
- package/src/admin/components/admin-users/create.tsx +0 -323
- package/src/admin/components/admin-users/roles.module.css +0 -119
- package/src/admin/components/admin-users/roles.tsx +0 -172
- package/src/admin/components/admin-users/set-password.module.css +0 -46
- package/src/admin/components/admin-users/set-password.tsx +0 -199
- package/src/admin/components/admin-users/update.module.css +0 -49
- package/src/admin/components/admin-users/update.tsx +0 -328
- package/src/admin/components/auth/sign-in-form.module.css +0 -62
- package/src/admin/components/auth/sign-in-form.tsx +0 -132
- package/src/services/admin-services-context.tsx +0 -35
- package/src/services/admin-services-types.ts +0 -177
- /package/dist/{admin/components/collections → widgets/status-badge}/status-badge.d.ts +0 -0
- /package/src/{admin/components/collections → widgets/diff-viewer}/diff-modal.module.css +0 -0
- /package/src/{admin/components/collections → widgets/status-badge}/status-badge.module.css +0 -0
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { revalidateLogic, useForm } from "@tanstack/react-form-start";
|
|
5
|
-
import classnames from "classnames";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { useBylineAdminServices } from "../../../services/admin-services-context.js";
|
|
8
|
-
import { Alert, Button, Input, LoaderEllipsis } from "../../../uikit.js";
|
|
9
|
-
import update_module from "./update.module.js";
|
|
10
|
-
const updateAccountSchema = z.object({
|
|
11
|
-
given_name: z.string().max(100, 'Given name must not exceed 100 characters'),
|
|
12
|
-
family_name: z.string().max(100, 'Family name must not exceed 100 characters'),
|
|
13
|
-
username: z.string().max(100, 'Username must not exceed 100 characters'),
|
|
14
|
-
email: z.email({
|
|
15
|
-
message: 'Enter a valid email address'
|
|
16
|
-
}).min(3).max(254, 'Email must not exceed 254 characters')
|
|
17
|
-
});
|
|
18
|
-
function defaultsFrom(account) {
|
|
19
|
-
return {
|
|
20
|
-
given_name: account.given_name ?? '',
|
|
21
|
-
family_name: account.family_name ?? '',
|
|
22
|
-
username: account.username ?? '',
|
|
23
|
-
email: account.email
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function buildPatch(values, account) {
|
|
27
|
-
const patch = {};
|
|
28
|
-
const normaliseText = (value)=>value.trim().length > 0 ? value : null;
|
|
29
|
-
const nextGiven = normaliseText(values.given_name);
|
|
30
|
-
const nextFamily = normaliseText(values.family_name);
|
|
31
|
-
const nextUsername = normaliseText(values.username);
|
|
32
|
-
if (nextGiven !== account.given_name) patch.given_name = nextGiven;
|
|
33
|
-
if (nextFamily !== account.family_name) patch.family_name = nextFamily;
|
|
34
|
-
if (nextUsername !== account.username) patch.username = nextUsername;
|
|
35
|
-
if (values.email !== account.email) patch.email = values.email;
|
|
36
|
-
return patch;
|
|
37
|
-
}
|
|
38
|
-
function UpdateAccount({ account, onClose, onSuccess }) {
|
|
39
|
-
const { updateAccount } = useBylineAdminServices();
|
|
40
|
-
const [formError, setFormError] = useState(null);
|
|
41
|
-
const [successMessage, setSuccessMessage] = useState(null);
|
|
42
|
-
const form = useForm({
|
|
43
|
-
defaultValues: defaultsFrom(account),
|
|
44
|
-
validationLogic: revalidateLogic({
|
|
45
|
-
mode: 'blur',
|
|
46
|
-
modeAfterSubmission: 'change'
|
|
47
|
-
}),
|
|
48
|
-
validators: {
|
|
49
|
-
onDynamic: updateAccountSchema
|
|
50
|
-
},
|
|
51
|
-
onSubmit: async ({ value })=>{
|
|
52
|
-
setFormError(null);
|
|
53
|
-
setSuccessMessage(null);
|
|
54
|
-
const patch = buildPatch(value, account);
|
|
55
|
-
if (0 === Object.keys(patch).length) return void setSuccessMessage('No changes to save.');
|
|
56
|
-
try {
|
|
57
|
-
const updated = await updateAccount({
|
|
58
|
-
data: {
|
|
59
|
-
vid: account.vid,
|
|
60
|
-
patch
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
setSuccessMessage('Saved.');
|
|
64
|
-
onSuccess?.(updated);
|
|
65
|
-
} catch (err) {
|
|
66
|
-
const code = getErrorCode(err);
|
|
67
|
-
if ('admin.users.emailInUse' === code) return void form.setFieldMeta('email', (meta)=>({
|
|
68
|
-
...meta,
|
|
69
|
-
errorMap: {
|
|
70
|
-
...meta.errorMap,
|
|
71
|
-
onServer: 'This email is already in use.'
|
|
72
|
-
},
|
|
73
|
-
errors: [
|
|
74
|
-
'This email is already in use.'
|
|
75
|
-
]
|
|
76
|
-
}));
|
|
77
|
-
if ('admin.users.versionConflict' === code) return void setFormError('Your account has been modified elsewhere since you opened this form. Reload to refresh and try again.');
|
|
78
|
-
if ('admin.account.notFound' === code) return void setFormError('Your admin account could not be found. Please sign in again.');
|
|
79
|
-
setFormError('Could not save changes. Please try again.');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return /*#__PURE__*/ jsx("div", {
|
|
84
|
-
className: classnames('byline-account-update-wrap', update_module.wrap),
|
|
85
|
-
children: /*#__PURE__*/ jsxs("form", {
|
|
86
|
-
noValidate: true,
|
|
87
|
-
onSubmit: (event)=>{
|
|
88
|
-
event.preventDefault();
|
|
89
|
-
event.stopPropagation();
|
|
90
|
-
form.handleSubmit();
|
|
91
|
-
},
|
|
92
|
-
className: classnames('byline-account-update-form', update_module.form),
|
|
93
|
-
children: [
|
|
94
|
-
formError ? /*#__PURE__*/ jsx(Alert, {
|
|
95
|
-
intent: "danger",
|
|
96
|
-
children: formError
|
|
97
|
-
}) : null,
|
|
98
|
-
successMessage ? /*#__PURE__*/ jsx(Alert, {
|
|
99
|
-
intent: "success",
|
|
100
|
-
children: successMessage
|
|
101
|
-
}) : null,
|
|
102
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
103
|
-
name: "given_name",
|
|
104
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
105
|
-
label: "Given name",
|
|
106
|
-
id: "given_name",
|
|
107
|
-
name: field.name,
|
|
108
|
-
value: field.state.value,
|
|
109
|
-
onBlur: field.handleBlur,
|
|
110
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
111
|
-
error: field.state.meta.errors.length > 0,
|
|
112
|
-
errorText: firstError(field.state.meta.errors),
|
|
113
|
-
autoComplete: "given-name"
|
|
114
|
-
})
|
|
115
|
-
}),
|
|
116
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
117
|
-
name: "family_name",
|
|
118
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
119
|
-
label: "Family name",
|
|
120
|
-
id: "family_name",
|
|
121
|
-
name: field.name,
|
|
122
|
-
value: field.state.value,
|
|
123
|
-
onBlur: field.handleBlur,
|
|
124
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
125
|
-
error: field.state.meta.errors.length > 0,
|
|
126
|
-
errorText: firstError(field.state.meta.errors),
|
|
127
|
-
autoComplete: "family-name"
|
|
128
|
-
})
|
|
129
|
-
}),
|
|
130
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
131
|
-
name: "username",
|
|
132
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
133
|
-
label: "Username",
|
|
134
|
-
id: "username",
|
|
135
|
-
name: field.name,
|
|
136
|
-
value: field.state.value,
|
|
137
|
-
onBlur: field.handleBlur,
|
|
138
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
139
|
-
error: field.state.meta.errors.length > 0,
|
|
140
|
-
errorText: firstError(field.state.meta.errors),
|
|
141
|
-
helpText: "Optional. Leave blank to clear.",
|
|
142
|
-
autoComplete: "username"
|
|
143
|
-
})
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
146
|
-
name: "email",
|
|
147
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
148
|
-
label: "Email",
|
|
149
|
-
id: "email",
|
|
150
|
-
name: field.name,
|
|
151
|
-
type: "email",
|
|
152
|
-
value: field.state.value,
|
|
153
|
-
onBlur: field.handleBlur,
|
|
154
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
155
|
-
error: field.state.meta.errors.length > 0,
|
|
156
|
-
errorText: firstError(field.state.meta.errors),
|
|
157
|
-
autoComplete: "email",
|
|
158
|
-
required: true
|
|
159
|
-
})
|
|
160
|
-
}),
|
|
161
|
-
/*#__PURE__*/ jsxs("div", {
|
|
162
|
-
className: classnames('byline-account-update-actions', update_module.actions),
|
|
163
|
-
children: [
|
|
164
|
-
/*#__PURE__*/ jsx(Button, {
|
|
165
|
-
type: "button",
|
|
166
|
-
intent: "secondary",
|
|
167
|
-
size: "sm",
|
|
168
|
-
onClick: onClose,
|
|
169
|
-
className: classnames('byline-account-update-action', update_module.action),
|
|
170
|
-
children: successMessage ? 'Close' : 'Cancel'
|
|
171
|
-
}),
|
|
172
|
-
/*#__PURE__*/ jsx(form.Subscribe, {
|
|
173
|
-
selector: (state)=>({
|
|
174
|
-
canSubmit: state.canSubmit,
|
|
175
|
-
isSubmitting: state.isSubmitting,
|
|
176
|
-
isDirty: state.isDirty
|
|
177
|
-
}),
|
|
178
|
-
children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
|
|
179
|
-
size: "sm",
|
|
180
|
-
intent: "primary",
|
|
181
|
-
type: "submit",
|
|
182
|
-
disabled: !canSubmit || isSubmitting,
|
|
183
|
-
className: classnames('byline-account-update-action', update_module.action),
|
|
184
|
-
children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
|
|
185
|
-
size: 42
|
|
186
|
-
}) : 'Save'
|
|
187
|
-
})
|
|
188
|
-
})
|
|
189
|
-
]
|
|
190
|
-
})
|
|
191
|
-
]
|
|
192
|
-
})
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function firstError(errors) {
|
|
196
|
-
for (const err of errors){
|
|
197
|
-
if ('string' == typeof err) return err;
|
|
198
|
-
if (err && 'object' == typeof err && 'message' in err) {
|
|
199
|
-
const msg = err.message;
|
|
200
|
-
if ('string' == typeof msg) return msg;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function getErrorCode(err) {
|
|
205
|
-
return 'string' == typeof err?.code ? err.code : null;
|
|
206
|
-
}
|
|
207
|
-
export { UpdateAccount };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
:is(.wrap-qSOtam, .byline-account-update-wrap) {
|
|
2
|
-
gap: var(--spacing-8);
|
|
3
|
-
padding: var(--spacing-4);
|
|
4
|
-
margin-top: var(--spacing-4);
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
display: flex;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
:is(.form-DEvqGV, .byline-account-update-form) {
|
|
10
|
-
gap: var(--spacing-16);
|
|
11
|
-
padding-top: var(--spacing-8);
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
display: flex;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
:is(.actions-Eg0XQA, .byline-account-update-actions) {
|
|
17
|
-
justify-content: flex-end;
|
|
18
|
-
align-items: center;
|
|
19
|
-
gap: var(--spacing-8);
|
|
20
|
-
margin-top: var(--spacing-16);
|
|
21
|
-
display: flex;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
:is(.action-CSfiVK, .byline-account-update-action) {
|
|
25
|
-
min-width: 4rem;
|
|
26
|
-
}
|
|
27
|
-
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import classnames from "classnames";
|
|
5
|
-
import { useBylineAdminServices } from "../../../services/admin-services-context.js";
|
|
6
|
-
import { Button, Container, LoaderRing, Section } from "../../../uikit.js";
|
|
7
|
-
import inspector_module from "./inspector.module.js";
|
|
8
|
-
function sourceVariant(source) {
|
|
9
|
-
switch(source){
|
|
10
|
-
case 'collection':
|
|
11
|
-
return {
|
|
12
|
-
global: 'byline-inspector-row-source-collection',
|
|
13
|
-
local: inspector_module["row-source-collection"]
|
|
14
|
-
};
|
|
15
|
-
case 'admin':
|
|
16
|
-
return {
|
|
17
|
-
global: 'byline-inspector-row-source-admin',
|
|
18
|
-
local: inspector_module["row-source-admin"]
|
|
19
|
-
};
|
|
20
|
-
case 'plugin':
|
|
21
|
-
return {
|
|
22
|
-
global: 'byline-inspector-row-source-plugin',
|
|
23
|
-
local: inspector_module["row-source-plugin"]
|
|
24
|
-
};
|
|
25
|
-
case 'core':
|
|
26
|
-
return {
|
|
27
|
-
global: 'byline-inspector-row-source-core',
|
|
28
|
-
local: inspector_module["row-source-core"]
|
|
29
|
-
};
|
|
30
|
-
default:
|
|
31
|
-
return {
|
|
32
|
-
global: 'byline-inspector-row-source-unknown',
|
|
33
|
-
local: inspector_module["row-source-unknown"]
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function displayUser(user) {
|
|
38
|
-
const parts = [
|
|
39
|
-
user.given_name,
|
|
40
|
-
user.family_name
|
|
41
|
-
].filter((p)=>'string' == typeof p && p.length > 0);
|
|
42
|
-
return parts.length > 0 ? `${parts.join(' ')} (${user.email})` : user.email;
|
|
43
|
-
}
|
|
44
|
-
function MatrixPanel({ matrix }) {
|
|
45
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
46
|
-
className: classnames('byline-inspector-matrix', inspector_module.matrix),
|
|
47
|
-
children: [
|
|
48
|
-
/*#__PURE__*/ jsxs("div", {
|
|
49
|
-
children: [
|
|
50
|
-
/*#__PURE__*/ jsxs("h4", {
|
|
51
|
-
className: classnames('byline-inspector-matrix-title', inspector_module["matrix-title"]),
|
|
52
|
-
children: [
|
|
53
|
-
"Roles (",
|
|
54
|
-
matrix.roles.length,
|
|
55
|
-
")"
|
|
56
|
-
]
|
|
57
|
-
}),
|
|
58
|
-
0 === matrix.roles.length ? /*#__PURE__*/ jsx("p", {
|
|
59
|
-
className: classnames('muted', 'byline-inspector-matrix-empty', inspector_module["matrix-empty"]),
|
|
60
|
-
children: "No role grants this ability."
|
|
61
|
-
}) : /*#__PURE__*/ jsx("ul", {
|
|
62
|
-
className: classnames('byline-inspector-matrix-list', inspector_module["matrix-list"]),
|
|
63
|
-
children: matrix.roles.map((role)=>/*#__PURE__*/ jsxs("li", {
|
|
64
|
-
className: classnames('byline-inspector-matrix-item', inspector_module["matrix-item"]),
|
|
65
|
-
children: [
|
|
66
|
-
/*#__PURE__*/ jsx("span", {
|
|
67
|
-
className: classnames('byline-inspector-matrix-name', inspector_module["matrix-name"]),
|
|
68
|
-
children: role.name
|
|
69
|
-
}),
|
|
70
|
-
/*#__PURE__*/ jsxs("span", {
|
|
71
|
-
className: "muted",
|
|
72
|
-
children: [
|
|
73
|
-
"\xa0\xb7\xa0",
|
|
74
|
-
role.machine_name
|
|
75
|
-
]
|
|
76
|
-
})
|
|
77
|
-
]
|
|
78
|
-
}, role.id))
|
|
79
|
-
})
|
|
80
|
-
]
|
|
81
|
-
}),
|
|
82
|
-
/*#__PURE__*/ jsxs("div", {
|
|
83
|
-
children: [
|
|
84
|
-
/*#__PURE__*/ jsxs("h4", {
|
|
85
|
-
className: classnames('byline-inspector-matrix-title', inspector_module["matrix-title"]),
|
|
86
|
-
children: [
|
|
87
|
-
"Admin users (",
|
|
88
|
-
matrix.users.length,
|
|
89
|
-
")"
|
|
90
|
-
]
|
|
91
|
-
}),
|
|
92
|
-
0 === matrix.users.length ? /*#__PURE__*/ jsx("p", {
|
|
93
|
-
className: classnames('muted', 'byline-inspector-matrix-empty', inspector_module["matrix-empty"]),
|
|
94
|
-
children: "No admin user holds this ability."
|
|
95
|
-
}) : /*#__PURE__*/ jsx("ul", {
|
|
96
|
-
className: classnames('byline-inspector-matrix-list', inspector_module["matrix-list"]),
|
|
97
|
-
children: matrix.users.map((user)=>/*#__PURE__*/ jsx("li", {
|
|
98
|
-
className: classnames('byline-inspector-matrix-item', inspector_module["matrix-item"]),
|
|
99
|
-
children: displayUser(user)
|
|
100
|
-
}, user.id))
|
|
101
|
-
})
|
|
102
|
-
]
|
|
103
|
-
})
|
|
104
|
-
]
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function AbilityRow({ ability, matrix, loading, onToggle, expanded }) {
|
|
108
|
-
const sv = sourceVariant(ability.source);
|
|
109
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
110
|
-
className: classnames('byline-inspector-row', inspector_module.row),
|
|
111
|
-
children: [
|
|
112
|
-
/*#__PURE__*/ jsxs("div", {
|
|
113
|
-
className: classnames('byline-inspector-row-head', inspector_module["row-head"]),
|
|
114
|
-
children: [
|
|
115
|
-
/*#__PURE__*/ jsxs("div", {
|
|
116
|
-
className: classnames('byline-inspector-row-info', inspector_module["row-info"]),
|
|
117
|
-
children: [
|
|
118
|
-
/*#__PURE__*/ jsxs("div", {
|
|
119
|
-
className: classnames('byline-inspector-row-meta', inspector_module["row-meta"]),
|
|
120
|
-
children: [
|
|
121
|
-
/*#__PURE__*/ jsx("code", {
|
|
122
|
-
className: classnames('byline-inspector-row-key', inspector_module["row-key"]),
|
|
123
|
-
children: ability.key
|
|
124
|
-
}),
|
|
125
|
-
/*#__PURE__*/ jsx("span", {
|
|
126
|
-
className: classnames('byline-inspector-row-source', inspector_module["row-source"], sv.global, sv.local),
|
|
127
|
-
children: ability.source ?? 'unknown'
|
|
128
|
-
})
|
|
129
|
-
]
|
|
130
|
-
}),
|
|
131
|
-
/*#__PURE__*/ jsx("p", {
|
|
132
|
-
className: classnames('byline-inspector-row-label', inspector_module["row-label"]),
|
|
133
|
-
children: ability.label
|
|
134
|
-
}),
|
|
135
|
-
ability.description ? /*#__PURE__*/ jsx("p", {
|
|
136
|
-
className: classnames('muted', "byline-inspector-row-description", inspector_module["row-description"]),
|
|
137
|
-
children: ability.description
|
|
138
|
-
}) : null
|
|
139
|
-
]
|
|
140
|
-
}),
|
|
141
|
-
/*#__PURE__*/ jsx(Button, {
|
|
142
|
-
size: "xs",
|
|
143
|
-
intent: "secondary",
|
|
144
|
-
onClick: onToggle,
|
|
145
|
-
children: expanded ? 'Hide' : 'Holders'
|
|
146
|
-
})
|
|
147
|
-
]
|
|
148
|
-
}),
|
|
149
|
-
expanded ? loading ? /*#__PURE__*/ jsxs("div", {
|
|
150
|
-
className: classnames('byline-inspector-loader', inspector_module.loader),
|
|
151
|
-
children: [
|
|
152
|
-
/*#__PURE__*/ jsx(LoaderRing, {
|
|
153
|
-
size: 20,
|
|
154
|
-
color: "#888"
|
|
155
|
-
}),
|
|
156
|
-
/*#__PURE__*/ jsx("span", {
|
|
157
|
-
className: "muted",
|
|
158
|
-
children: "Loading…"
|
|
159
|
-
})
|
|
160
|
-
]
|
|
161
|
-
}) : matrix ? /*#__PURE__*/ jsx(MatrixPanel, {
|
|
162
|
-
matrix: matrix
|
|
163
|
-
}) : null : null
|
|
164
|
-
]
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function GroupSection({ group, matrices, loading, expanded, onToggle }) {
|
|
168
|
-
return /*#__PURE__*/ jsxs("details", {
|
|
169
|
-
open: true,
|
|
170
|
-
className: classnames('byline-inspector-group', inspector_module.group),
|
|
171
|
-
children: [
|
|
172
|
-
/*#__PURE__*/ jsxs("summary", {
|
|
173
|
-
className: classnames('byline-inspector-group-summary', inspector_module["group-summary"]),
|
|
174
|
-
children: [
|
|
175
|
-
/*#__PURE__*/ jsx("span", {
|
|
176
|
-
className: classnames('byline-inspector-group-name', inspector_module["group-name"]),
|
|
177
|
-
children: group.group
|
|
178
|
-
}),
|
|
179
|
-
/*#__PURE__*/ jsxs("span", {
|
|
180
|
-
className: classnames('muted', 'byline-inspector-group-count', inspector_module["group-count"]),
|
|
181
|
-
children: [
|
|
182
|
-
group.abilities.length,
|
|
183
|
-
" abilities"
|
|
184
|
-
]
|
|
185
|
-
})
|
|
186
|
-
]
|
|
187
|
-
}),
|
|
188
|
-
/*#__PURE__*/ jsx("div", {
|
|
189
|
-
className: classnames('byline-inspector-group-body', inspector_module["group-body"]),
|
|
190
|
-
children: group.abilities.map((ability)=>/*#__PURE__*/ jsx(AbilityRow, {
|
|
191
|
-
ability: ability,
|
|
192
|
-
matrix: matrices[ability.key],
|
|
193
|
-
loading: loading.has(ability.key),
|
|
194
|
-
expanded: expanded.has(ability.key),
|
|
195
|
-
onToggle: ()=>onToggle(ability.key)
|
|
196
|
-
}, ability.key))
|
|
197
|
-
})
|
|
198
|
-
]
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
function AbilitiesInspector({ data }) {
|
|
202
|
-
const { whoHasAbility } = useBylineAdminServices();
|
|
203
|
-
const [expanded, setExpanded] = useState(new Set());
|
|
204
|
-
const [loading, setLoading] = useState(new Set());
|
|
205
|
-
const [matrices, setMatrices] = useState({});
|
|
206
|
-
async function handleToggle(abilityKey) {
|
|
207
|
-
setExpanded((current)=>{
|
|
208
|
-
const next = new Set(current);
|
|
209
|
-
if (next.has(abilityKey)) next.delete(abilityKey);
|
|
210
|
-
else next.add(abilityKey);
|
|
211
|
-
return next;
|
|
212
|
-
});
|
|
213
|
-
if (!matrices[abilityKey] && !loading.has(abilityKey)) {
|
|
214
|
-
setLoading((current)=>new Set(current).add(abilityKey));
|
|
215
|
-
try {
|
|
216
|
-
const result = await whoHasAbility({
|
|
217
|
-
data: {
|
|
218
|
-
ability: abilityKey
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
setMatrices((current)=>({
|
|
222
|
-
...current,
|
|
223
|
-
[abilityKey]: result
|
|
224
|
-
}));
|
|
225
|
-
} finally{
|
|
226
|
-
setLoading((current)=>{
|
|
227
|
-
const next = new Set(current);
|
|
228
|
-
next.delete(abilityKey);
|
|
229
|
-
return next;
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return /*#__PURE__*/ jsx(Section, {
|
|
235
|
-
children: /*#__PURE__*/ jsxs(Container, {
|
|
236
|
-
children: [
|
|
237
|
-
/*#__PURE__*/ jsxs("div", {
|
|
238
|
-
className: classnames('byline-inspector-head', inspector_module.head),
|
|
239
|
-
children: [
|
|
240
|
-
/*#__PURE__*/ jsx("h1", {
|
|
241
|
-
className: classnames('byline-inspector-title', inspector_module.title),
|
|
242
|
-
children: "Abilities Inspector"
|
|
243
|
-
}),
|
|
244
|
-
/*#__PURE__*/ jsxs("span", {
|
|
245
|
-
className: classnames('byline-inspector-count-pill', inspector_module["count-pill"]),
|
|
246
|
-
children: [
|
|
247
|
-
data.total,
|
|
248
|
-
" registered"
|
|
249
|
-
]
|
|
250
|
-
})
|
|
251
|
-
]
|
|
252
|
-
}),
|
|
253
|
-
/*#__PURE__*/ jsxs("p", {
|
|
254
|
-
className: classnames('muted', 'byline-inspector-lead', inspector_module.lead),
|
|
255
|
-
children: [
|
|
256
|
-
"Read-only view of every ability registered through ",
|
|
257
|
-
/*#__PURE__*/ jsx("code", {
|
|
258
|
-
children: "bylineCore.abilities"
|
|
259
|
-
}),
|
|
260
|
-
". Collections auto-register CRUD + workflow abilities; admin subsystems contribute their own keys at composition root via ",
|
|
261
|
-
/*#__PURE__*/ jsx("code", {
|
|
262
|
-
children: "registerAdminAbilities"
|
|
263
|
-
}),
|
|
264
|
-
"."
|
|
265
|
-
]
|
|
266
|
-
}),
|
|
267
|
-
0 === data.groups.length ? /*#__PURE__*/ jsx("p", {
|
|
268
|
-
className: classnames('muted', 'byline-inspector-empty', inspector_module.empty),
|
|
269
|
-
children: "No abilities are registered."
|
|
270
|
-
}) : /*#__PURE__*/ jsx("div", {
|
|
271
|
-
className: classnames('byline-inspector-groups', inspector_module.groups),
|
|
272
|
-
children: data.groups.map((group)=>/*#__PURE__*/ jsx(GroupSection, {
|
|
273
|
-
group: group,
|
|
274
|
-
matrices: matrices,
|
|
275
|
-
loading: loading,
|
|
276
|
-
expanded: expanded,
|
|
277
|
-
onToggle: (key)=>void handleToggle(key)
|
|
278
|
-
}, group.group))
|
|
279
|
-
})
|
|
280
|
-
]
|
|
281
|
-
})
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
export { AbilitiesInspector };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import "./inspector_module.css";
|
|
2
|
-
const inspector_module = {
|
|
3
|
-
head: "head-I3FXon",
|
|
4
|
-
title: "title-CYjHqj",
|
|
5
|
-
"count-pill": "count-pill-_lI0zE",
|
|
6
|
-
countPill: "count-pill-_lI0zE",
|
|
7
|
-
lead: "lead-oILWDF",
|
|
8
|
-
groups: "groups-tu0nDc",
|
|
9
|
-
group: "group-EtyMYe",
|
|
10
|
-
"group-summary": "group-summary-DtWUME",
|
|
11
|
-
groupSummary: "group-summary-DtWUME",
|
|
12
|
-
"group-name": "group-name-YVnU_1",
|
|
13
|
-
groupName: "group-name-YVnU_1",
|
|
14
|
-
"group-count": "group-count-EVyCua",
|
|
15
|
-
groupCount: "group-count-EVyCua",
|
|
16
|
-
"group-body": "group-body-BWpBH0",
|
|
17
|
-
groupBody: "group-body-BWpBH0",
|
|
18
|
-
row: "row-iqBBtL",
|
|
19
|
-
"row-head": "row-head-AxLDWZ",
|
|
20
|
-
rowHead: "row-head-AxLDWZ",
|
|
21
|
-
"row-info": "row-info-fqTyrl",
|
|
22
|
-
rowInfo: "row-info-fqTyrl",
|
|
23
|
-
"row-meta": "row-meta-jR8B7R",
|
|
24
|
-
rowMeta: "row-meta-jR8B7R",
|
|
25
|
-
"row-key": "row-key-Fqj4Xg",
|
|
26
|
-
rowKey: "row-key-Fqj4Xg",
|
|
27
|
-
"row-source": "row-source-dNn5Bv",
|
|
28
|
-
rowSource: "row-source-dNn5Bv",
|
|
29
|
-
"row-source-collection": "row-source-collection-GdjAWo",
|
|
30
|
-
rowSourceCollection: "row-source-collection-GdjAWo",
|
|
31
|
-
"row-source-admin": "row-source-admin-RSLuvi",
|
|
32
|
-
rowSourceAdmin: "row-source-admin-RSLuvi",
|
|
33
|
-
"row-source-plugin": "row-source-plugin-IHE6mA",
|
|
34
|
-
rowSourcePlugin: "row-source-plugin-IHE6mA",
|
|
35
|
-
"row-source-core": "row-source-core-MzfMU8",
|
|
36
|
-
rowSourceCore: "row-source-core-MzfMU8",
|
|
37
|
-
"row-source-unknown": "row-source-unknown-uGsgjP",
|
|
38
|
-
rowSourceUnknown: "row-source-unknown-uGsgjP",
|
|
39
|
-
"row-label": "row-label-wAkro2",
|
|
40
|
-
rowLabel: "row-label-wAkro2",
|
|
41
|
-
"row-description": "row-description-To0P2i",
|
|
42
|
-
rowDescription: "row-description-To0P2i",
|
|
43
|
-
loader: "loader-CBbfLX",
|
|
44
|
-
matrix: "matrix-wUBTNq",
|
|
45
|
-
"matrix-title": "matrix-title-UANgg0",
|
|
46
|
-
matrixTitle: "matrix-title-UANgg0",
|
|
47
|
-
"matrix-empty": "matrix-empty-j1eaHq",
|
|
48
|
-
matrixEmpty: "matrix-empty-j1eaHq",
|
|
49
|
-
"matrix-list": "matrix-list-k00LgN",
|
|
50
|
-
matrixList: "matrix-list-k00LgN",
|
|
51
|
-
"matrix-item": "matrix-item-ON61fX",
|
|
52
|
-
matrixItem: "matrix-item-ON61fX",
|
|
53
|
-
"matrix-name": "matrix-name-FxgVBJ",
|
|
54
|
-
matrixName: "matrix-name-FxgVBJ"
|
|
55
|
-
};
|
|
56
|
-
export default inspector_module;
|