@byline/ui 2.4.0 → 2.4.1
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,254 +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, Checkbox, Input, LoaderEllipsis } from "../../../uikit.js";
|
|
9
|
-
import update_module from "./update.module.js";
|
|
10
|
-
const updateUserSchema = 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
|
-
is_super_admin: z.boolean(),
|
|
18
|
-
is_enabled: z.boolean(),
|
|
19
|
-
is_email_verified: z.boolean()
|
|
20
|
-
});
|
|
21
|
-
function defaultsFrom(user) {
|
|
22
|
-
return {
|
|
23
|
-
given_name: user.given_name ?? '',
|
|
24
|
-
family_name: user.family_name ?? '',
|
|
25
|
-
username: user.username ?? '',
|
|
26
|
-
email: user.email,
|
|
27
|
-
is_super_admin: user.is_super_admin,
|
|
28
|
-
is_enabled: user.is_enabled,
|
|
29
|
-
is_email_verified: user.is_email_verified
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function buildPatch(values, user) {
|
|
33
|
-
const patch = {};
|
|
34
|
-
const normaliseText = (value)=>value.trim().length > 0 ? value : null;
|
|
35
|
-
const nextGiven = normaliseText(values.given_name);
|
|
36
|
-
const nextFamily = normaliseText(values.family_name);
|
|
37
|
-
const nextUsername = normaliseText(values.username);
|
|
38
|
-
if (nextGiven !== user.given_name) patch.given_name = nextGiven;
|
|
39
|
-
if (nextFamily !== user.family_name) patch.family_name = nextFamily;
|
|
40
|
-
if (nextUsername !== user.username) patch.username = nextUsername;
|
|
41
|
-
if (values.email !== user.email) patch.email = values.email;
|
|
42
|
-
if (values.is_super_admin !== user.is_super_admin) patch.is_super_admin = values.is_super_admin;
|
|
43
|
-
if (values.is_enabled !== user.is_enabled) patch.is_enabled = values.is_enabled;
|
|
44
|
-
if (values.is_email_verified !== user.is_email_verified) patch.is_email_verified = values.is_email_verified;
|
|
45
|
-
return patch;
|
|
46
|
-
}
|
|
47
|
-
function UpdateUser({ user, onClose, onSuccess }) {
|
|
48
|
-
const { updateAdminUser } = useBylineAdminServices();
|
|
49
|
-
const [formError, setFormError] = useState(null);
|
|
50
|
-
const [successMessage, setSuccessMessage] = useState(null);
|
|
51
|
-
const form = useForm({
|
|
52
|
-
defaultValues: defaultsFrom(user),
|
|
53
|
-
validationLogic: revalidateLogic({
|
|
54
|
-
mode: 'blur',
|
|
55
|
-
modeAfterSubmission: 'change'
|
|
56
|
-
}),
|
|
57
|
-
validators: {
|
|
58
|
-
onDynamic: updateUserSchema
|
|
59
|
-
},
|
|
60
|
-
onSubmit: async ({ value })=>{
|
|
61
|
-
setFormError(null);
|
|
62
|
-
setSuccessMessage(null);
|
|
63
|
-
const patch = buildPatch(value, user);
|
|
64
|
-
if (0 === Object.keys(patch).length) return void setSuccessMessage('No changes to save.');
|
|
65
|
-
try {
|
|
66
|
-
const updated = await updateAdminUser({
|
|
67
|
-
data: {
|
|
68
|
-
id: user.id,
|
|
69
|
-
vid: user.vid,
|
|
70
|
-
patch
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
setSuccessMessage('Saved.');
|
|
74
|
-
onSuccess?.(updated);
|
|
75
|
-
} catch (err) {
|
|
76
|
-
const code = getErrorCode(err);
|
|
77
|
-
if ('admin.users.emailInUse' === code) return void form.setFieldMeta('email', (meta)=>({
|
|
78
|
-
...meta,
|
|
79
|
-
errorMap: {
|
|
80
|
-
...meta.errorMap,
|
|
81
|
-
onServer: 'This email is already in use.'
|
|
82
|
-
},
|
|
83
|
-
errors: [
|
|
84
|
-
'This email is already in use.'
|
|
85
|
-
]
|
|
86
|
-
}));
|
|
87
|
-
if ('admin.users.versionConflict' === code) return void setFormError('This user has been modified elsewhere since you opened this form. Reload to get the latest values and try again.');
|
|
88
|
-
if ('admin.users.notFound' === code) return void setFormError('This user no longer exists.');
|
|
89
|
-
setFormError('Could not save changes. Please try again.');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return /*#__PURE__*/ jsx("div", {
|
|
94
|
-
className: classnames('byline-user-update-wrap', update_module.wrap),
|
|
95
|
-
children: /*#__PURE__*/ jsxs("form", {
|
|
96
|
-
noValidate: true,
|
|
97
|
-
onSubmit: (event)=>{
|
|
98
|
-
event.preventDefault();
|
|
99
|
-
event.stopPropagation();
|
|
100
|
-
form.handleSubmit();
|
|
101
|
-
},
|
|
102
|
-
className: classnames('byline-user-update-form', update_module.form),
|
|
103
|
-
children: [
|
|
104
|
-
formError ? /*#__PURE__*/ jsx(Alert, {
|
|
105
|
-
intent: "danger",
|
|
106
|
-
children: formError
|
|
107
|
-
}) : null,
|
|
108
|
-
successMessage ? /*#__PURE__*/ jsx(Alert, {
|
|
109
|
-
intent: "success",
|
|
110
|
-
children: successMessage
|
|
111
|
-
}) : null,
|
|
112
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
113
|
-
name: "given_name",
|
|
114
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
115
|
-
label: "Given name",
|
|
116
|
-
id: "given_name",
|
|
117
|
-
name: field.name,
|
|
118
|
-
value: field.state.value,
|
|
119
|
-
onBlur: field.handleBlur,
|
|
120
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
121
|
-
error: field.state.meta.errors.length > 0,
|
|
122
|
-
errorText: firstError(field.state.meta.errors),
|
|
123
|
-
autoComplete: "given-name"
|
|
124
|
-
})
|
|
125
|
-
}),
|
|
126
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
127
|
-
name: "family_name",
|
|
128
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
129
|
-
label: "Family name",
|
|
130
|
-
id: "family_name",
|
|
131
|
-
name: field.name,
|
|
132
|
-
value: field.state.value,
|
|
133
|
-
onBlur: field.handleBlur,
|
|
134
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
135
|
-
error: field.state.meta.errors.length > 0,
|
|
136
|
-
errorText: firstError(field.state.meta.errors),
|
|
137
|
-
autoComplete: "family-name"
|
|
138
|
-
})
|
|
139
|
-
}),
|
|
140
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
141
|
-
name: "username",
|
|
142
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
143
|
-
label: "Username",
|
|
144
|
-
id: "username",
|
|
145
|
-
name: field.name,
|
|
146
|
-
value: field.state.value,
|
|
147
|
-
onBlur: field.handleBlur,
|
|
148
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
149
|
-
error: field.state.meta.errors.length > 0,
|
|
150
|
-
errorText: firstError(field.state.meta.errors),
|
|
151
|
-
helpText: "Optional. Leave blank to clear.",
|
|
152
|
-
autoComplete: "username"
|
|
153
|
-
})
|
|
154
|
-
}),
|
|
155
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
156
|
-
name: "email",
|
|
157
|
-
children: (field)=>/*#__PURE__*/ jsx(Input, {
|
|
158
|
-
label: "Email",
|
|
159
|
-
id: "email",
|
|
160
|
-
name: field.name,
|
|
161
|
-
type: "email",
|
|
162
|
-
value: field.state.value,
|
|
163
|
-
onBlur: field.handleBlur,
|
|
164
|
-
onChange: (e)=>field.handleChange(e.currentTarget.value),
|
|
165
|
-
error: field.state.meta.errors.length > 0,
|
|
166
|
-
errorText: firstError(field.state.meta.errors),
|
|
167
|
-
autoComplete: "email",
|
|
168
|
-
required: true
|
|
169
|
-
})
|
|
170
|
-
}),
|
|
171
|
-
/*#__PURE__*/ jsxs("div", {
|
|
172
|
-
className: classnames('byline-user-update-flags', update_module.flags),
|
|
173
|
-
children: [
|
|
174
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
175
|
-
name: "is_enabled",
|
|
176
|
-
children: (field)=>/*#__PURE__*/ jsx(Checkbox, {
|
|
177
|
-
id: "is_enabled",
|
|
178
|
-
name: field.name,
|
|
179
|
-
label: "Enabled",
|
|
180
|
-
checked: field.state.value,
|
|
181
|
-
onCheckedChange: (checked)=>field.handleChange(true === checked),
|
|
182
|
-
helpText: "Disabled accounts cannot sign in."
|
|
183
|
-
})
|
|
184
|
-
}),
|
|
185
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
186
|
-
name: "is_email_verified",
|
|
187
|
-
children: (field)=>/*#__PURE__*/ jsx(Checkbox, {
|
|
188
|
-
id: "is_email_verified",
|
|
189
|
-
name: field.name,
|
|
190
|
-
label: "Email verified",
|
|
191
|
-
checked: field.state.value,
|
|
192
|
-
onCheckedChange: (checked)=>field.handleChange(true === checked)
|
|
193
|
-
})
|
|
194
|
-
}),
|
|
195
|
-
/*#__PURE__*/ jsx(form.Field, {
|
|
196
|
-
name: "is_super_admin",
|
|
197
|
-
children: (field)=>/*#__PURE__*/ jsx(Checkbox, {
|
|
198
|
-
id: "is_super_admin",
|
|
199
|
-
name: field.name,
|
|
200
|
-
label: "Super admin",
|
|
201
|
-
checked: field.state.value,
|
|
202
|
-
onCheckedChange: (checked)=>field.handleChange(true === checked),
|
|
203
|
-
helpText: "Super admins bypass every ability check — grant with care."
|
|
204
|
-
})
|
|
205
|
-
})
|
|
206
|
-
]
|
|
207
|
-
}),
|
|
208
|
-
/*#__PURE__*/ jsxs("div", {
|
|
209
|
-
className: classnames('byline-user-update-actions', update_module.actions),
|
|
210
|
-
children: [
|
|
211
|
-
/*#__PURE__*/ jsx(Button, {
|
|
212
|
-
type: "button",
|
|
213
|
-
intent: "secondary",
|
|
214
|
-
size: "sm",
|
|
215
|
-
onClick: onClose,
|
|
216
|
-
className: classnames('byline-user-update-action', update_module.action),
|
|
217
|
-
children: successMessage ? 'Close' : 'Cancel'
|
|
218
|
-
}),
|
|
219
|
-
/*#__PURE__*/ jsx(form.Subscribe, {
|
|
220
|
-
selector: (state)=>({
|
|
221
|
-
canSubmit: state.canSubmit,
|
|
222
|
-
isSubmitting: state.isSubmitting,
|
|
223
|
-
isDirty: state.isDirty
|
|
224
|
-
}),
|
|
225
|
-
children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
|
|
226
|
-
size: "sm",
|
|
227
|
-
intent: "primary",
|
|
228
|
-
type: "submit",
|
|
229
|
-
disabled: !canSubmit || isSubmitting,
|
|
230
|
-
className: classnames('byline-user-update-action', update_module.action),
|
|
231
|
-
children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
|
|
232
|
-
size: 42
|
|
233
|
-
}) : 'Save'
|
|
234
|
-
})
|
|
235
|
-
})
|
|
236
|
-
]
|
|
237
|
-
})
|
|
238
|
-
]
|
|
239
|
-
})
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
function firstError(errors) {
|
|
243
|
-
for (const err of errors){
|
|
244
|
-
if ('string' == typeof err) return err;
|
|
245
|
-
if (err && 'object' == typeof err && 'message' in err) {
|
|
246
|
-
const msg = err.message;
|
|
247
|
-
if ('string' == typeof msg) return msg;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function getErrorCode(err) {
|
|
252
|
-
return 'string' == typeof err?.code ? err.code : null;
|
|
253
|
-
}
|
|
254
|
-
export { UpdateUser };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
:is(.wrap-HGvVzG, .byline-user-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-Rdv5zH, .byline-user-update-form) {
|
|
10
|
-
gap: var(--spacing-16);
|
|
11
|
-
padding-top: var(--spacing-8);
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
display: flex;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
:is(.flags-hcYFLd, .byline-user-update-flags) {
|
|
17
|
-
gap: var(--spacing-8);
|
|
18
|
-
padding: var(--spacing-4);
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
display: flex;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
:is(.actions-bgPJcB, .byline-user-update-actions) {
|
|
24
|
-
justify-content: flex-end;
|
|
25
|
-
align-items: center;
|
|
26
|
-
gap: var(--spacing-8);
|
|
27
|
-
margin-top: var(--spacing-16);
|
|
28
|
-
display: flex;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
:is(.action-DNNfxh, .byline-user-update-action) {
|
|
32
|
-
min-width: 4rem;
|
|
33
|
-
}
|
|
34
|
-
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface SignInFormProps {
|
|
2
|
-
/** Destination after successful sign-in. Defaults to `/admin`. */
|
|
3
|
-
callbackUrl?: string;
|
|
4
|
-
/**
|
|
5
|
-
* Optional plain "Home" link rendered on the left of the action row.
|
|
6
|
-
* Typically the host's configured `serverURL` so signed-out admins can
|
|
7
|
-
* navigate back to the public site without typing the URL.
|
|
8
|
-
*/
|
|
9
|
-
homeUrl?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare function SignInForm({ callbackUrl, homeUrl }: SignInFormProps): import("react").JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1,115 +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 { Alert, Button, Card, Input, LoaderEllipsis } from "../../../uikit.js";
|
|
7
|
-
import sign_in_form_module from "./sign-in-form.module.js";
|
|
8
|
-
function SignInForm({ callbackUrl, homeUrl }) {
|
|
9
|
-
const { adminSignIn } = useBylineAdminServices();
|
|
10
|
-
const [email, setEmail] = useState('');
|
|
11
|
-
const [password, setPassword] = useState('');
|
|
12
|
-
const [pending, setPending] = useState(false);
|
|
13
|
-
const [error, setError] = useState(null);
|
|
14
|
-
async function handleSubmit(event) {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
if (pending) return;
|
|
17
|
-
if (0 === email.trim().length || 0 === password.length) return void setError('Enter your email and password.');
|
|
18
|
-
setPending(true);
|
|
19
|
-
setError(null);
|
|
20
|
-
try {
|
|
21
|
-
await adminSignIn({
|
|
22
|
-
data: {
|
|
23
|
-
email: email.trim(),
|
|
24
|
-
password
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const target = callbackUrl && callbackUrl.length > 0 ? callbackUrl : '/admin';
|
|
28
|
-
window.location.assign(target);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.warn('sign-in failed', err);
|
|
31
|
-
setError('Invalid credentials.');
|
|
32
|
-
setPending(false);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return /*#__PURE__*/ jsxs(Card, {
|
|
36
|
-
className: classnames('byline-sign-in-card', sign_in_form_module.card),
|
|
37
|
-
children: [
|
|
38
|
-
/*#__PURE__*/ jsxs(Card.Header, {
|
|
39
|
-
children: [
|
|
40
|
-
/*#__PURE__*/ jsx(Card.Title, {
|
|
41
|
-
children: /*#__PURE__*/ jsx("h2", {
|
|
42
|
-
children: "Sign in"
|
|
43
|
-
})
|
|
44
|
-
}),
|
|
45
|
-
/*#__PURE__*/ jsx(Card.Description, {
|
|
46
|
-
children: "Sign in to the Byline admin."
|
|
47
|
-
}),
|
|
48
|
-
error && /*#__PURE__*/ jsx(Alert, {
|
|
49
|
-
intent: "danger",
|
|
50
|
-
className: classnames('byline-sign-in-alert', sign_in_form_module.alert),
|
|
51
|
-
children: error
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
}),
|
|
55
|
-
/*#__PURE__*/ jsx(Card.Content, {
|
|
56
|
-
children: /*#__PURE__*/ jsxs("form", {
|
|
57
|
-
onSubmit: handleSubmit,
|
|
58
|
-
noValidate: true,
|
|
59
|
-
className: classnames('byline-sign-in-form', sign_in_form_module.form),
|
|
60
|
-
children: [
|
|
61
|
-
/*#__PURE__*/ jsxs("div", {
|
|
62
|
-
className: classnames('byline-sign-in-fields', sign_in_form_module.fields),
|
|
63
|
-
children: [
|
|
64
|
-
/*#__PURE__*/ jsx(Input, {
|
|
65
|
-
label: "Email",
|
|
66
|
-
id: "email",
|
|
67
|
-
name: "email",
|
|
68
|
-
type: "email",
|
|
69
|
-
autoComplete: "email",
|
|
70
|
-
required: true,
|
|
71
|
-
value: email,
|
|
72
|
-
onChange: (event)=>setEmail(event.currentTarget.value),
|
|
73
|
-
disabled: pending
|
|
74
|
-
}),
|
|
75
|
-
/*#__PURE__*/ jsx(Input, {
|
|
76
|
-
label: "Password",
|
|
77
|
-
id: "password",
|
|
78
|
-
name: "password",
|
|
79
|
-
type: "password",
|
|
80
|
-
autoComplete: "current-password",
|
|
81
|
-
required: true,
|
|
82
|
-
value: password,
|
|
83
|
-
onChange: (event)=>setPassword(event.currentTarget.value),
|
|
84
|
-
disabled: pending
|
|
85
|
-
})
|
|
86
|
-
]
|
|
87
|
-
}),
|
|
88
|
-
/*#__PURE__*/ jsxs("div", {
|
|
89
|
-
className: classnames('byline-sign-in-actions', sign_in_form_module.actions),
|
|
90
|
-
children: [
|
|
91
|
-
homeUrl && /*#__PURE__*/ jsx("a", {
|
|
92
|
-
href: homeUrl,
|
|
93
|
-
className: classnames('byline-sign-in-home-link', sign_in_form_module["home-link"]),
|
|
94
|
-
children: "Home"
|
|
95
|
-
}),
|
|
96
|
-
/*#__PURE__*/ jsx(Button, {
|
|
97
|
-
type: "submit",
|
|
98
|
-
disabled: pending,
|
|
99
|
-
className: classnames('byline-sign-in-button', sign_in_form_module.button),
|
|
100
|
-
children: pending ? /*#__PURE__*/ jsx(LoaderEllipsis, {
|
|
101
|
-
size: 30,
|
|
102
|
-
color: "#aaaaaa"
|
|
103
|
-
}) : /*#__PURE__*/ jsx("span", {
|
|
104
|
-
children: "Sign In"
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
]
|
|
108
|
-
})
|
|
109
|
-
]
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
]
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
export { SignInForm };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "./sign-in-form_module.css";
|
|
2
|
-
const sign_in_form_module = {
|
|
3
|
-
card: "card-QfnGXf",
|
|
4
|
-
alert: "alert-UP_Dsq",
|
|
5
|
-
form: "form-fWmy7i",
|
|
6
|
-
fields: "fields-PdCiqd",
|
|
7
|
-
actions: "actions-PqFgXw",
|
|
8
|
-
"home-link": "home-link-HFDZqL",
|
|
9
|
-
homeLink: "home-link-HFDZqL",
|
|
10
|
-
button: "button-t5aU4f"
|
|
11
|
-
};
|
|
12
|
-
export default sign_in_form_module;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
:is(.card-QfnGXf, .byline-sign-in-card) {
|
|
2
|
-
width: 100%;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
@media (min-width: 40rem) {
|
|
6
|
-
:is(.card-QfnGXf, .byline-sign-in-card) {
|
|
7
|
-
max-width: 380px;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
:is(.alert-UP_Dsq, .byline-sign-in-alert) {
|
|
12
|
-
margin-top: var(--spacing-12);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
:is(.form-fWmy7i, .byline-sign-in-form) {
|
|
16
|
-
padding-top: var(--spacing-8);
|
|
17
|
-
margin-bottom: var(--spacing-8);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
:is(.fields-PdCiqd, .byline-sign-in-fields) {
|
|
21
|
-
gap: var(--spacing-16);
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
display: flex;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
:is(.actions-PqFgXw, .byline-sign-in-actions) {
|
|
27
|
-
margin-top: var(--spacing-24);
|
|
28
|
-
align-items: center;
|
|
29
|
-
display: flex;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
:is(.home-link-HFDZqL, .byline-sign-in-home-link) {
|
|
33
|
-
font-size: .9rem;
|
|
34
|
-
text-decoration: underline;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
:is(.button-t5aU4f, .byline-sign-in-button) {
|
|
38
|
-
min-width: 5rem;
|
|
39
|
-
margin-left: auto;
|
|
40
|
-
}
|
|
41
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "./diff-modal_module.css";
|
|
2
|
-
const diff_modal_module = {
|
|
3
|
-
header: "header-u6gvtB",
|
|
4
|
-
"title-stack": "title-stack-rJ2qgD",
|
|
5
|
-
titleStack: "title-stack-rJ2qgD",
|
|
6
|
-
title: "title-TdarBi",
|
|
7
|
-
subtitle: "subtitle-QCnXHJ",
|
|
8
|
-
version: "version-bEVRZQ",
|
|
9
|
-
content: "content-aOYGDW",
|
|
10
|
-
state: "state-mE6b8u",
|
|
11
|
-
error: "error-Fn4D5K",
|
|
12
|
-
viewer: "viewer-g0QwS4"
|
|
13
|
-
};
|
|
14
|
-
export default diff_modal_module;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
|
-
import { type ReactNode } from 'react';
|
|
9
|
-
import type { BylineAdminServices } from './admin-services-types.js';
|
|
10
|
-
interface BylineAdminServicesProviderProps {
|
|
11
|
-
services: BylineAdminServices;
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
export declare const BylineAdminServicesProvider: ({ services, children, }: BylineAdminServicesProviderProps) => import("react").JSX.Element;
|
|
15
|
-
export declare const useBylineAdminServices: () => BylineAdminServices;
|
|
16
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
const AdminServicesContext = /*#__PURE__*/ createContext(null);
|
|
4
|
-
const BylineAdminServicesProvider = ({ services, children })=>/*#__PURE__*/ jsx(AdminServicesContext.Provider, {
|
|
5
|
-
value: services,
|
|
6
|
-
children: children
|
|
7
|
-
});
|
|
8
|
-
const useBylineAdminServices = ()=>{
|
|
9
|
-
const ctx = useContext(AdminServicesContext);
|
|
10
|
-
if (!ctx) throw new Error('@byline/ui: BylineAdminServicesProvider missing. Wrap your admin tree with <BylineAdminServicesProvider services={…} />.');
|
|
11
|
-
return ctx;
|
|
12
|
-
};
|
|
13
|
-
export { BylineAdminServicesProvider, useBylineAdminServices };
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Framework-neutral function contracts that admin UI components in
|
|
10
|
-
* `@byline/ui` need from the host application. The host wires concrete
|
|
11
|
-
* implementations via `BylineAdminServicesProvider` — typically thin
|
|
12
|
-
* adapters around TanStack Start server functions, Next.js server
|
|
13
|
-
* actions, or any other RPC-style transport.
|
|
14
|
-
*
|
|
15
|
-
* The call shape `(args: { data: TInput }) => Promise<TOutput>` mirrors
|
|
16
|
-
* TanStack Start's `createServerFn().handler()` calling convention so a
|
|
17
|
-
* webapp host can pass its server fns through as-is. Other transports
|
|
18
|
-
* just need a tiny adapter.
|
|
19
|
-
*
|
|
20
|
-
* Scope: Phase 2.1 covers the framework-neutral admin UI components
|
|
21
|
-
* only — the 15 forms, modals, and inner widgets that don't touch
|
|
22
|
-
* TanStack Router. Page containers (list/edit/delete pages) keep using
|
|
23
|
-
* server fns directly today and move into `@byline/host-tanstack-start`
|
|
24
|
-
* in Phase 3 along with the route factories.
|
|
25
|
-
*/
|
|
26
|
-
import type { AccountResponse, ChangeAccountPasswordRequest, UpdateAccountRequest } from '@byline/admin/admin-account';
|
|
27
|
-
import type { SetRoleAbilitiesResponse, WhoHasAbilityResponse } from '@byline/admin/admin-permissions';
|
|
28
|
-
import type { AdminRoleResponse, UserRolesResponse } from '@byline/admin/admin-roles';
|
|
29
|
-
import type { AdminUserResponse } from '@byline/admin/admin-users';
|
|
30
|
-
/**
|
|
31
|
-
* The TanStack Start `createServerFn(...).handler(...)` calling shape:
|
|
32
|
-
* `fn({ data: input }) → Promise<output>`. Hosts using a different
|
|
33
|
-
* transport supply small adapters that match this shape.
|
|
34
|
-
*/
|
|
35
|
-
export type AdminServiceCall<TInput, TOutput> = (args: {
|
|
36
|
-
data: TInput;
|
|
37
|
-
}) => Promise<TOutput>;
|
|
38
|
-
export interface SignInInput {
|
|
39
|
-
email: string;
|
|
40
|
-
password: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The admin UI's sign-in form does not consume the `SignInResult`
|
|
44
|
-
* payload directly — on success it navigates via `window.location`. The
|
|
45
|
-
* shape is left as `unknown` here so each host's session provider can
|
|
46
|
-
* supply whatever envelope it produces without forcing a public type.
|
|
47
|
-
*/
|
|
48
|
-
export type SignInResult = unknown;
|
|
49
|
-
/** Same shape as `UpdateAccountRequest` from `@byline/admin/admin-account`. */
|
|
50
|
-
export type UpdateAccountInput = UpdateAccountRequest;
|
|
51
|
-
/** Same shape as `ChangeAccountPasswordRequest` from `@byline/admin/admin-account`. */
|
|
52
|
-
export type ChangeAccountPasswordInput = ChangeAccountPasswordRequest;
|
|
53
|
-
export interface CreateAdminUserInput {
|
|
54
|
-
email: string;
|
|
55
|
-
password: string;
|
|
56
|
-
given_name?: string | null;
|
|
57
|
-
family_name?: string | null;
|
|
58
|
-
username?: string | null;
|
|
59
|
-
is_super_admin: boolean;
|
|
60
|
-
is_enabled: boolean;
|
|
61
|
-
is_email_verified: boolean;
|
|
62
|
-
}
|
|
63
|
-
export interface UpdateAdminUserInput {
|
|
64
|
-
id: string;
|
|
65
|
-
vid: number;
|
|
66
|
-
patch: {
|
|
67
|
-
email?: string;
|
|
68
|
-
given_name?: string | null;
|
|
69
|
-
family_name?: string | null;
|
|
70
|
-
username?: string | null;
|
|
71
|
-
is_super_admin?: boolean;
|
|
72
|
-
is_enabled?: boolean;
|
|
73
|
-
is_email_verified?: boolean;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export interface SetAdminUserPasswordInput {
|
|
77
|
-
id: string;
|
|
78
|
-
vid: number;
|
|
79
|
-
password: string;
|
|
80
|
-
}
|
|
81
|
-
export interface SetUserRolesInput {
|
|
82
|
-
userId: string;
|
|
83
|
-
roleIds: string[];
|
|
84
|
-
}
|
|
85
|
-
export interface CreateAdminRoleInput {
|
|
86
|
-
name: string;
|
|
87
|
-
machine_name: string;
|
|
88
|
-
description: string | null;
|
|
89
|
-
}
|
|
90
|
-
export interface UpdateAdminRoleInput {
|
|
91
|
-
id: string;
|
|
92
|
-
vid: number;
|
|
93
|
-
patch: {
|
|
94
|
-
name?: string;
|
|
95
|
-
description?: string | null;
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
export interface SetRoleAbilitiesInput {
|
|
99
|
-
id: string;
|
|
100
|
-
abilities: string[];
|
|
101
|
-
}
|
|
102
|
-
export interface WhoHasAbilityInput {
|
|
103
|
-
ability: string;
|
|
104
|
-
}
|
|
105
|
-
export interface BylineAdminServices {
|
|
106
|
-
adminSignIn: AdminServiceCall<SignInInput, SignInResult>;
|
|
107
|
-
updateAccount: AdminServiceCall<UpdateAccountInput, AccountResponse>;
|
|
108
|
-
changeAccountPassword: AdminServiceCall<ChangeAccountPasswordInput, AccountResponse>;
|
|
109
|
-
createAdminUser: AdminServiceCall<CreateAdminUserInput, AdminUserResponse>;
|
|
110
|
-
updateAdminUser: AdminServiceCall<UpdateAdminUserInput, AdminUserResponse>;
|
|
111
|
-
setAdminUserPassword: AdminServiceCall<SetAdminUserPasswordInput, AdminUserResponse>;
|
|
112
|
-
setUserRoles: AdminServiceCall<SetUserRolesInput, UserRolesResponse>;
|
|
113
|
-
createAdminRole: AdminServiceCall<CreateAdminRoleInput, AdminRoleResponse>;
|
|
114
|
-
updateAdminRole: AdminServiceCall<UpdateAdminRoleInput, AdminRoleResponse>;
|
|
115
|
-
setRoleAbilities: AdminServiceCall<SetRoleAbilitiesInput, SetRoleAbilitiesResponse>;
|
|
116
|
-
whoHasAbility: AdminServiceCall<WhoHasAbilityInput, WhoHasAbilityResponse>;
|
|
117
|
-
/**
|
|
118
|
-
* Diff helper. Loads a specific historical version of a document so
|
|
119
|
-
* the diff modal can compare it against the current version. Returns
|
|
120
|
-
* the same shape as the regular document loader — the diff modal
|
|
121
|
-
* consumes only `doc.fields` (or strips known meta keys when an
|
|
122
|
-
* older flat-shape doc is encountered).
|
|
123
|
-
*
|
|
124
|
-
* Positional-args shape rather than `{ data }` because this helper
|
|
125
|
-
* predates the contract and is consumed only by `DiffModal`. Hosts
|
|
126
|
-
* adapt their server fn into this call signature.
|
|
127
|
-
*/
|
|
128
|
-
getCollectionDocumentVersion: (collection: string, documentId: string, versionId: string, locale: string | undefined) => Promise<Record<string, unknown>>;
|
|
129
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|