@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,166 +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, TextArea } from "../../../uikit.js";
|
|
9
|
-
import update_module from "./update.module.js";
|
|
10
|
-
const updateRoleSchema = z.object({
|
|
11
|
-
name: z.string().min(1, 'Name is required').max(128, 'Name must not exceed 128 characters'),
|
|
12
|
-
description: z.string().max(2000, "Description must not exceed 2000 characters")
|
|
13
|
-
});
|
|
14
|
-
function defaultsFrom(role) {
|
|
15
|
-
return {
|
|
16
|
-
name: role.name,
|
|
17
|
-
description: role.description ?? ''
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function buildPatch(values, role) {
|
|
21
|
-
const patch = {};
|
|
22
|
-
const normaliseText = (value)=>value.trim().length > 0 ? value : null;
|
|
23
|
-
const nextDescription = normaliseText(values.description);
|
|
24
|
-
const nextName = values.name.trim();
|
|
25
|
-
if (nextName !== role.name) patch.name = nextName;
|
|
26
|
-
if (nextDescription !== role.description) patch.description = nextDescription;
|
|
27
|
-
return patch;
|
|
28
|
-
}
|
|
29
|
-
function UpdateRole({ role, onClose, onSuccess }) {
|
|
30
|
-
const { updateAdminRole } = useBylineAdminServices();
|
|
31
|
-
const [formError, setFormError] = useState(null);
|
|
32
|
-
const [successMessage, setSuccessMessage] = useState(null);
|
|
33
|
-
const form = useForm({
|
|
34
|
-
defaultValues: defaultsFrom(role),
|
|
35
|
-
validationLogic: revalidateLogic({
|
|
36
|
-
mode: 'blur',
|
|
37
|
-
modeAfterSubmission: 'change'
|
|
38
|
-
}),
|
|
39
|
-
validators: {
|
|
40
|
-
onDynamic: updateRoleSchema
|
|
41
|
-
},
|
|
42
|
-
onSubmit: async ({ value })=>{
|
|
43
|
-
setFormError(null);
|
|
44
|
-
setSuccessMessage(null);
|
|
45
|
-
const patch = buildPatch(value, role);
|
|
46
|
-
if (0 === Object.keys(patch).length) return void setSuccessMessage('No changes to save.');
|
|
47
|
-
try {
|
|
48
|
-
const updated = await updateAdminRole({
|
|
49
|
-
data: {
|
|
50
|
-
id: role.id,
|
|
51
|
-
vid: role.vid,
|
|
52
|
-
patch
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
setSuccessMessage('Saved.');
|
|
56
|
-
onSuccess?.(updated);
|
|
57
|
-
} catch (err) {
|
|
58
|
-
const code = getErrorCode(err);
|
|
59
|
-
if ('admin.roles.versionConflict' === code) return void setFormError('This role has been modified elsewhere since you opened this form. Reload to get the latest values and try again.');
|
|
60
|
-
if ('admin.roles.notFound' === code) return void setFormError('This role no longer exists.');
|
|
61
|
-
setFormError('Could not save changes. Please try again.');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return /*#__PURE__*/ jsx("div", {
|
|
66
|
-
className: classnames('byline-role-update-wrap', update_module.wrap),
|
|
67
|
-
children: /*#__PURE__*/ jsxs("form", {
|
|
68
|
-
noValidate: true,
|
|
69
|
-
onSubmit: (event)=>{
|
|
70
|
-
event.preventDefault();
|
|
71
|
-
event.stopPropagation();
|
|
72
|
-
form.handleSubmit();
|
|
73
|
-
},
|
|
74
|
-
className: classnames('byline-role-update-form', update_module.form),
|
|
75
|
-
children: [
|
|
76
|
-
formError ? /*#__PURE__*/ jsx(Alert, {
|
|
77
|
-
intent: "danger",
|
|
78
|
-
children: formError
|
|
79
|
-
}) : null,
|
|
80
|
-
successMessage ? /*#__PURE__*/ jsx(Alert, {
|
|
81
|
-
intent: "success",
|
|
82
|
-
children: successMessage
|
|
83
|
-
}) : null,
|
|
84
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
85
|
-
name: "name",
|
|
86
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
87
|
-
label: "Name",
|
|
88
|
-
id: "role-name",
|
|
89
|
-
name: field.name,
|
|
90
|
-
value: field.state.value,
|
|
91
|
-
onBlur: field.handleBlur,
|
|
92
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
93
|
-
error: field.state.meta.errors.length > 0,
|
|
94
|
-
errorText: firstError(field.state.meta.errors),
|
|
95
|
-
required: true
|
|
96
|
-
})
|
|
97
|
-
}),
|
|
98
|
-
/*#__PURE__*/ jsx(Input, {
|
|
99
|
-
label: "Machine name",
|
|
100
|
-
id: "role-machine-name",
|
|
101
|
-
name: "machine_name",
|
|
102
|
-
value: role.machine_name,
|
|
103
|
-
readOnly: true,
|
|
104
|
-
disabled: true,
|
|
105
|
-
helpText: "The stable code-side handle. Cannot be changed after creation."
|
|
106
|
-
}),
|
|
107
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
108
|
-
name: "description",
|
|
109
|
-
children: (field)=>/*#__PURE__*/ jsx(TextArea, {
|
|
110
|
-
label: "Description",
|
|
111
|
-
id: "role-description",
|
|
112
|
-
name: field.name,
|
|
113
|
-
value: field.state.value,
|
|
114
|
-
onBlur: field.handleBlur,
|
|
115
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
116
|
-
error: field.state.meta.errors.length > 0,
|
|
117
|
-
errorText: firstError(field.state.meta.errors),
|
|
118
|
-
rows: 3
|
|
119
|
-
})
|
|
120
|
-
}),
|
|
121
|
-
/*#__PURE__*/ jsxs("div", {
|
|
122
|
-
className: classnames('byline-role-update-actions', update_module.actions),
|
|
123
|
-
children: [
|
|
124
|
-
/*#__PURE__*/ jsx(Button, {
|
|
125
|
-
type: "button",
|
|
126
|
-
intent: "secondary",
|
|
127
|
-
size: "sm",
|
|
128
|
-
onClick: onClose,
|
|
129
|
-
className: classnames('byline-role-update-action', update_module.action),
|
|
130
|
-
children: successMessage ? 'Close' : 'Cancel'
|
|
131
|
-
}),
|
|
132
|
-
/*#__PURE__*/ jsx(form.Subscribe, {
|
|
133
|
-
selector: (state)=>({
|
|
134
|
-
canSubmit: state.canSubmit,
|
|
135
|
-
isSubmitting: state.isSubmitting
|
|
136
|
-
}),
|
|
137
|
-
children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
|
|
138
|
-
size: "sm",
|
|
139
|
-
intent: "primary",
|
|
140
|
-
type: "submit",
|
|
141
|
-
disabled: !canSubmit || isSubmitting,
|
|
142
|
-
className: classnames('byline-role-update-action', update_module.action),
|
|
143
|
-
children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
|
|
144
|
-
size: 42
|
|
145
|
-
}) : 'Save'
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
]
|
|
149
|
-
})
|
|
150
|
-
]
|
|
151
|
-
})
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function firstError(errors) {
|
|
155
|
-
for (const err of errors){
|
|
156
|
-
if ('string' == typeof err) return err;
|
|
157
|
-
if (err && 'object' == typeof err && 'message' in err) {
|
|
158
|
-
const msg = err.message;
|
|
159
|
-
if ('string' == typeof msg) return msg;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function getErrorCode(err) {
|
|
164
|
-
return 'string' == typeof err?.code ? err.code : null;
|
|
165
|
-
}
|
|
166
|
-
export { UpdateRole };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
:is(.wrap-mfIMVS, .byline-role-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-aniFJU, .byline-role-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-b9qrxi, .byline-role-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-h2ZUf2, .byline-role-update-action) {
|
|
25
|
-
min-width: 4rem;
|
|
26
|
-
}
|
|
27
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AdminUserResponse } from '@byline/admin/admin-users';
|
|
2
|
-
interface CreateAdminUserProps {
|
|
3
|
-
onClose?: () => void;
|
|
4
|
-
/** Called on successful create with the new user so the parent can navigate. */
|
|
5
|
-
onSuccess?: (user: AdminUserResponse) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare function CreateAdminUser({ onClose, onSuccess }: CreateAdminUserProps): import("react").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,268 +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 { passwordSchema } from "@byline/core/validation";
|
|
6
|
-
import classnames from "classnames";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { useBylineAdminServices } from "../../../services/admin-services-context.js";
|
|
9
|
-
import { Alert, Button, Checkbox, Input, LoaderEllipsis } from "../../../uikit.js";
|
|
10
|
-
import create_module from "./create.module.js";
|
|
11
|
-
const createAdminUserFormSchema = z.object({
|
|
12
|
-
email: z.email({
|
|
13
|
-
message: 'Enter a valid email address'
|
|
14
|
-
}).min(3).max(254, 'Email must not exceed 254 characters'),
|
|
15
|
-
password: passwordSchema,
|
|
16
|
-
given_name: z.string().max(100, 'Given name must not exceed 100 characters'),
|
|
17
|
-
family_name: z.string().max(100, 'Family name must not exceed 100 characters'),
|
|
18
|
-
username: z.string().max(100, 'Username must not exceed 100 characters'),
|
|
19
|
-
is_super_admin: z.boolean(),
|
|
20
|
-
is_enabled: z.boolean(),
|
|
21
|
-
is_email_verified: z.boolean()
|
|
22
|
-
});
|
|
23
|
-
const initialValues = {
|
|
24
|
-
email: '',
|
|
25
|
-
password: '',
|
|
26
|
-
given_name: '',
|
|
27
|
-
family_name: '',
|
|
28
|
-
username: '',
|
|
29
|
-
is_super_admin: false,
|
|
30
|
-
is_enabled: true,
|
|
31
|
-
is_email_verified: false
|
|
32
|
-
};
|
|
33
|
-
function normaliseText(value) {
|
|
34
|
-
return value.trim().length > 0 ? value : null;
|
|
35
|
-
}
|
|
36
|
-
function CreateAdminUser({ onClose, onSuccess }) {
|
|
37
|
-
const { createAdminUser } = useBylineAdminServices();
|
|
38
|
-
const [formError, setFormError] = useState(null);
|
|
39
|
-
const form = useForm({
|
|
40
|
-
defaultValues: initialValues,
|
|
41
|
-
validationLogic: revalidateLogic({
|
|
42
|
-
mode: 'blur',
|
|
43
|
-
modeAfterSubmission: 'change'
|
|
44
|
-
}),
|
|
45
|
-
validators: {
|
|
46
|
-
onDynamic: createAdminUserFormSchema
|
|
47
|
-
},
|
|
48
|
-
onSubmit: async ({ value })=>{
|
|
49
|
-
setFormError(null);
|
|
50
|
-
try {
|
|
51
|
-
const created = await createAdminUser({
|
|
52
|
-
data: {
|
|
53
|
-
email: value.email,
|
|
54
|
-
password: value.password,
|
|
55
|
-
given_name: normaliseText(value.given_name),
|
|
56
|
-
family_name: normaliseText(value.family_name),
|
|
57
|
-
username: normaliseText(value.username),
|
|
58
|
-
is_super_admin: value.is_super_admin,
|
|
59
|
-
is_enabled: value.is_enabled,
|
|
60
|
-
is_email_verified: value.is_email_verified
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
form.reset(initialValues);
|
|
64
|
-
onSuccess?.(created);
|
|
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
|
-
setFormError('Could not create this admin user. Please try again.');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return /*#__PURE__*/ jsx("div", {
|
|
82
|
-
className: classnames('byline-user-create-wrap', create_module.wrap),
|
|
83
|
-
children: /*#__PURE__*/ jsxs("form", {
|
|
84
|
-
noValidate: true,
|
|
85
|
-
onSubmit: (event)=>{
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
form.handleSubmit();
|
|
89
|
-
},
|
|
90
|
-
className: classnames('byline-user-create-form', create_module.form),
|
|
91
|
-
children: [
|
|
92
|
-
formError ? /*#__PURE__*/ jsx(Alert, {
|
|
93
|
-
intent: "danger",
|
|
94
|
-
children: formError
|
|
95
|
-
}) : null,
|
|
96
|
-
/*#__PURE__*/ jsxs("div", {
|
|
97
|
-
className: classnames('byline-user-create-grid', create_module.grid),
|
|
98
|
-
children: [
|
|
99
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
100
|
-
name: "given_name",
|
|
101
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
102
|
-
label: "Given name",
|
|
103
|
-
id: "new-given-name",
|
|
104
|
-
name: field.name,
|
|
105
|
-
value: field.state.value,
|
|
106
|
-
onBlur: field.handleBlur,
|
|
107
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
108
|
-
error: field.state.meta.errors.length > 0,
|
|
109
|
-
errorText: firstError(field.state.meta.errors),
|
|
110
|
-
autoComplete: "given-name"
|
|
111
|
-
})
|
|
112
|
-
}),
|
|
113
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
114
|
-
name: "family_name",
|
|
115
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
116
|
-
label: "Family name",
|
|
117
|
-
id: "new-family-name",
|
|
118
|
-
name: field.name,
|
|
119
|
-
value: field.state.value,
|
|
120
|
-
onBlur: field.handleBlur,
|
|
121
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
122
|
-
error: field.state.meta.errors.length > 0,
|
|
123
|
-
errorText: firstError(field.state.meta.errors),
|
|
124
|
-
autoComplete: "family-name"
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
]
|
|
128
|
-
}),
|
|
129
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
130
|
-
name: "username",
|
|
131
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
132
|
-
label: "Username",
|
|
133
|
-
id: "new-username",
|
|
134
|
-
name: field.name,
|
|
135
|
-
value: field.state.value,
|
|
136
|
-
onBlur: field.handleBlur,
|
|
137
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
138
|
-
error: field.state.meta.errors.length > 0,
|
|
139
|
-
errorText: firstError(field.state.meta.errors),
|
|
140
|
-
helpText: "Optional.",
|
|
141
|
-
autoComplete: "username"
|
|
142
|
-
})
|
|
143
|
-
}),
|
|
144
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
145
|
-
name: "email",
|
|
146
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
147
|
-
label: "Email",
|
|
148
|
-
id: "new-email",
|
|
149
|
-
name: field.name,
|
|
150
|
-
type: "email",
|
|
151
|
-
value: field.state.value,
|
|
152
|
-
onBlur: field.handleBlur,
|
|
153
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
154
|
-
error: field.state.meta.errors.length > 0,
|
|
155
|
-
errorText: firstError(field.state.meta.errors),
|
|
156
|
-
autoComplete: "email",
|
|
157
|
-
required: true
|
|
158
|
-
})
|
|
159
|
-
}),
|
|
160
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
161
|
-
name: "password",
|
|
162
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
163
|
-
label: "Initial password",
|
|
164
|
-
id: "new-password",
|
|
165
|
-
name: field.name,
|
|
166
|
-
type: "password",
|
|
167
|
-
value: field.state.value,
|
|
168
|
-
onBlur: field.handleBlur,
|
|
169
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
170
|
-
error: field.state.meta.errors.length > 0,
|
|
171
|
-
errorText: firstError(field.state.meta.errors),
|
|
172
|
-
helpText: "The user can change it from their own account after signing in.",
|
|
173
|
-
autoComplete: "new-password",
|
|
174
|
-
required: true
|
|
175
|
-
})
|
|
176
|
-
}),
|
|
177
|
-
/*#__PURE__*/ jsxs("div", {
|
|
178
|
-
className: classnames('byline-user-create-flags', create_module.flags),
|
|
179
|
-
children: [
|
|
180
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
181
|
-
name: "is_enabled",
|
|
182
|
-
children: (field)=>/*#__PURE__*/ jsx(Checkbox, {
|
|
183
|
-
id: "new-is-enabled",
|
|
184
|
-
name: field.name,
|
|
185
|
-
label: "Enabled",
|
|
186
|
-
checked: field.state.value,
|
|
187
|
-
onCheckedChange: (checked)=>field.handleChange(true === checked),
|
|
188
|
-
helpText: "Disabled accounts cannot sign in."
|
|
189
|
-
})
|
|
190
|
-
}),
|
|
191
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
192
|
-
name: "is_email_verified",
|
|
193
|
-
children: (field)=>/*#__PURE__*/ jsx(Checkbox, {
|
|
194
|
-
id: "new-is-email-verified",
|
|
195
|
-
name: field.name,
|
|
196
|
-
label: "Email verified",
|
|
197
|
-
checked: field.state.value,
|
|
198
|
-
onCheckedChange: (checked)=>field.handleChange(true === checked),
|
|
199
|
-
helpText: "Skip the verification flow for this account."
|
|
200
|
-
})
|
|
201
|
-
}),
|
|
202
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
203
|
-
name: "is_super_admin",
|
|
204
|
-
children: (field)=>/*#__PURE__*/ jsx(Checkbox, {
|
|
205
|
-
id: "new-is-super-admin",
|
|
206
|
-
name: field.name,
|
|
207
|
-
label: "Super admin",
|
|
208
|
-
checked: field.state.value,
|
|
209
|
-
onCheckedChange: (checked)=>field.handleChange(true === checked),
|
|
210
|
-
helpText: "Super admins bypass every ability check — grant with care."
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
|
-
]
|
|
214
|
-
}),
|
|
215
|
-
/*#__PURE__*/ jsxs("div", {
|
|
216
|
-
className: classnames('byline-user-create-actions', create_module.actions),
|
|
217
|
-
children: [
|
|
218
|
-
/*#__PURE__*/ jsx(Button, {
|
|
219
|
-
type: "button",
|
|
220
|
-
intent: "secondary",
|
|
221
|
-
size: "sm",
|
|
222
|
-
onClick: onClose,
|
|
223
|
-
className: classnames('byline-user-create-action', create_module.action),
|
|
224
|
-
children: "Cancel"
|
|
225
|
-
}),
|
|
226
|
-
/*#__PURE__*/ jsx(form.Subscribe, {
|
|
227
|
-
selector: (state)=>({
|
|
228
|
-
canSubmit: state.canSubmit,
|
|
229
|
-
isSubmitting: state.isSubmitting
|
|
230
|
-
}),
|
|
231
|
-
children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
|
|
232
|
-
size: "sm",
|
|
233
|
-
intent: "primary",
|
|
234
|
-
type: "submit",
|
|
235
|
-
disabled: !canSubmit || isSubmitting,
|
|
236
|
-
className: classnames('byline-user-create-action', create_module.action),
|
|
237
|
-
children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
|
|
238
|
-
size: 42
|
|
239
|
-
}) : 'Save'
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
]
|
|
243
|
-
})
|
|
244
|
-
]
|
|
245
|
-
})
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
function firstError(errors) {
|
|
249
|
-
for (const err of errors){
|
|
250
|
-
if ('string' == typeof err) return err;
|
|
251
|
-
if (err && 'object' == typeof err && 'message' in err) {
|
|
252
|
-
const msg = err.message;
|
|
253
|
-
if ('string' == typeof msg) return msg;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function getErrorCode(err) {
|
|
258
|
-
if (err && 'object' == typeof err) {
|
|
259
|
-
const e = err;
|
|
260
|
-
if ('string' == typeof e.code) return e.code;
|
|
261
|
-
if (e.cause && 'object' == typeof e.cause && 'code' in e.cause) {
|
|
262
|
-
const cause = e.cause;
|
|
263
|
-
if ('string' == typeof cause.code) return cause.code;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
export { CreateAdminUser };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
:is(.wrap-VYxHeO, .byline-user-create-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-YMDaAb, .byline-user-create-form) {
|
|
10
|
-
gap: var(--spacing-16);
|
|
11
|
-
padding-top: var(--spacing-8);
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
display: flex;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
:is(.grid-xDObjA, .byline-user-create-grid) {
|
|
17
|
-
gap: var(--spacing-16);
|
|
18
|
-
grid-template-columns: 1fr;
|
|
19
|
-
display: grid;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@media (min-width: 40rem) {
|
|
23
|
-
:is(.grid-xDObjA, .byline-user-create-grid) {
|
|
24
|
-
grid-template-columns: 1fr 1fr;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
:is(.flags-JoKEl3, .byline-user-create-flags) {
|
|
29
|
-
gap: var(--spacing-8);
|
|
30
|
-
flex-direction: column;
|
|
31
|
-
display: flex;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:is(.actions-TcG9RX, .byline-user-create-actions) {
|
|
35
|
-
justify-content: flex-end;
|
|
36
|
-
align-items: center;
|
|
37
|
-
gap: var(--spacing-8);
|
|
38
|
-
margin-top: var(--spacing-16);
|
|
39
|
-
display: flex;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
:is(.action-CLDYKz, .byline-user-create-action) {
|
|
43
|
-
min-width: 4rem;
|
|
44
|
-
}
|
|
45
|
-
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AdminRoleResponse, UserRolesResponse } from '@byline/admin/admin-roles';
|
|
2
|
-
import type { AdminUserResponse } from '@byline/admin/admin-users';
|
|
3
|
-
interface UserRolesProps {
|
|
4
|
-
user: AdminUserResponse;
|
|
5
|
-
allRoles: AdminRoleResponse[];
|
|
6
|
-
initialRoleIds: string[];
|
|
7
|
-
onClose?: () => void;
|
|
8
|
-
onSaved?: (response: UserRolesResponse) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function UserRoles({ user, allRoles, initialRoleIds, onClose, onSaved }: UserRolesProps): import("react").JSX.Element;
|
|
11
|
-
export {};
|