@byline/admin 2.5.2 → 2.6.0
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/fields/array/array-field.d.ts +14 -0
- package/dist/fields/array/array-field.js +177 -0
- package/dist/fields/array/array-field.module.js +11 -0
- package/dist/fields/array/array-field_module.css +32 -0
- package/dist/fields/blocks/blocks-field.d.ts +13 -0
- package/dist/fields/blocks/blocks-field.js +245 -0
- package/dist/fields/blocks/blocks-field.module.js +26 -0
- package/dist/fields/blocks/blocks-field_module.css +107 -0
- package/dist/fields/checkbox/checkbox-field.d.ts +16 -0
- package/dist/fields/checkbox/checkbox-field.js +28 -0
- package/dist/fields/checkbox/checkbox-field.module.js +6 -0
- package/dist/fields/checkbox/checkbox-field_module.css +4 -0
- package/dist/fields/column-formatter.d.ts +20 -0
- package/dist/fields/column-formatter.js +15 -0
- package/dist/fields/date-time-formatter.d.ts +16 -0
- package/dist/fields/date-time-formatter.js +8 -0
- package/dist/fields/datetime/datetime-field.d.ts +16 -0
- package/dist/fields/datetime/datetime-field.js +37 -0
- package/dist/fields/datetime/datetime-field.module.js +5 -0
- package/dist/fields/datetime/datetime-field_module.css +4 -0
- package/dist/fields/draggable-context-menu.d.ts +6 -0
- package/dist/fields/draggable-context-menu.js +85 -0
- package/dist/fields/draggable-context-menu.module.js +15 -0
- package/dist/fields/draggable-context-menu_module.css +91 -0
- package/dist/fields/field-helpers.d.ts +26 -0
- package/dist/fields/field-helpers.js +50 -0
- package/dist/fields/field-renderer.d.ts +37 -0
- package/dist/fields/field-renderer.js +206 -0
- package/dist/fields/field-renderer.module.js +8 -0
- package/dist/fields/field-renderer_module.css +11 -0
- package/dist/fields/field-services-context.d.ts +16 -0
- package/dist/fields/field-services-context.js +13 -0
- package/dist/fields/field-services-types.d.ts +63 -0
- package/dist/fields/field-services-types.js +1 -0
- package/dist/fields/file/file-field.d.ts +19 -0
- package/dist/fields/file/file-field.js +225 -0
- package/dist/fields/file/file-field.module.js +18 -0
- package/dist/fields/file/file-field_module.css +131 -0
- package/dist/fields/file/file-upload-field.d.ts +21 -0
- package/dist/fields/file/file-upload-field.js +130 -0
- package/dist/fields/file/file-upload-field.module.js +15 -0
- package/dist/fields/file/file-upload-field_module.css +74 -0
- package/dist/fields/group/group-field.d.ts +15 -0
- package/dist/fields/group/group-field.js +59 -0
- package/dist/fields/group/group-field.module.js +9 -0
- package/dist/fields/group/group-field_module.css +27 -0
- package/dist/fields/image/image-field.d.ts +19 -0
- package/dist/fields/image/image-field.js +241 -0
- package/dist/fields/image/image-field.module.js +22 -0
- package/dist/fields/image/image-field_module.css +121 -0
- package/dist/fields/image/image-upload-field.d.ts +21 -0
- package/dist/fields/image/image-upload-field.js +190 -0
- package/dist/fields/image/image-upload-field.module.js +19 -0
- package/dist/fields/image/image-upload-field_module.css +92 -0
- package/dist/fields/local-date-time.d.ts +27 -0
- package/dist/fields/local-date-time.js +49 -0
- package/dist/fields/locale-badge.d.ts +18 -0
- package/dist/fields/locale-badge.js +10 -0
- package/dist/fields/locale-badge.module.js +5 -0
- package/dist/fields/locale-badge_module.css +27 -0
- package/dist/fields/numerical/numerical-field.d.ts +18 -0
- package/dist/fields/numerical/numerical-field.js +74 -0
- package/dist/fields/relation/relation-display.d.ts +40 -0
- package/dist/fields/relation/relation-display.js +58 -0
- package/dist/fields/relation/relation-display.module.js +9 -0
- package/dist/fields/relation/relation-display_module.css +21 -0
- package/dist/fields/relation/relation-field.d.ts +18 -0
- package/dist/fields/relation/relation-field.js +138 -0
- package/dist/fields/relation/relation-field.module.js +13 -0
- package/dist/fields/relation/relation-field_module.css +62 -0
- package/dist/fields/relation/relation-picker.d.ts +49 -0
- package/dist/fields/relation/relation-picker.js +236 -0
- package/dist/fields/relation/relation-picker.module.js +26 -0
- package/dist/fields/relation/relation-picker_module.css +124 -0
- package/dist/fields/relation/relation-summary.d.ts +31 -0
- package/dist/fields/relation/relation-summary.js +50 -0
- package/dist/fields/relation/relation-summary.module.js +11 -0
- package/dist/fields/relation/relation-summary_module.css +37 -0
- package/dist/fields/select/select-field.d.ts +16 -0
- package/dist/fields/select/select-field.js +50 -0
- package/dist/fields/select/select-field.module.js +5 -0
- package/dist/fields/select/select-field_module.css +4 -0
- package/dist/fields/sortable-item.d.ts +15 -0
- package/dist/fields/sortable-item.js +81 -0
- package/dist/fields/sortable-item.module.js +22 -0
- package/dist/fields/sortable-item_module.css +124 -0
- package/dist/fields/text/text-field.d.ts +20 -0
- package/dist/fields/text/text-field.js +104 -0
- package/dist/fields/text/text-field.module.js +6 -0
- package/dist/fields/text/text-field_module.css +5 -0
- package/dist/fields/text-area/text-area-field.d.ts +20 -0
- package/dist/fields/text-area/text-area-field.js +105 -0
- package/dist/fields/text-area/text-area-field.module.js +6 -0
- package/dist/fields/text-area/text-area-field_module.css +5 -0
- package/dist/fields/use-field-change-handler.d.ts +23 -0
- package/dist/fields/use-field-change-handler.js +52 -0
- package/dist/forms/document-actions.d.ts +48 -0
- package/dist/forms/document-actions.js +475 -0
- package/dist/forms/document-actions.module.js +34 -0
- package/dist/forms/document-actions_module.css +118 -0
- package/dist/forms/form-context.d.ts +89 -0
- package/dist/forms/form-context.js +466 -0
- package/dist/forms/form-renderer.d.ts +98 -0
- package/dist/forms/form-renderer.js +597 -0
- package/dist/forms/form-renderer.module.js +46 -0
- package/dist/forms/form-renderer_module.css +245 -0
- package/dist/forms/navigation-guard.d.ts +54 -0
- package/dist/forms/navigation-guard.js +22 -0
- package/dist/forms/path-widget.d.ts +36 -0
- package/dist/forms/path-widget.js +116 -0
- package/dist/forms/path-widget.module.js +8 -0
- package/dist/forms/path-widget_module.css +29 -0
- package/dist/forms/upload-executor.d.ts +57 -0
- package/dist/forms/upload-executor.js +94 -0
- package/dist/lib/translate-validation-error.d.ts +36 -0
- package/dist/lib/translate-validation-error.js +11 -0
- package/dist/modules/admin-account/commands.d.ts +2 -1
- package/dist/modules/admin-account/commands.js +13 -2
- package/dist/modules/admin-account/components/change-password.js +45 -36
- package/dist/modules/admin-account/components/container.js +185 -134
- package/dist/modules/admin-account/components/preferences.d.ts +8 -0
- package/dist/modules/admin-account/components/preferences.js +152 -0
- package/dist/modules/admin-account/components/preferences.module.js +11 -0
- package/dist/modules/admin-account/components/preferences_module.css +41 -0
- package/dist/modules/admin-account/components/update.js +50 -31
- package/dist/modules/admin-account/index.d.ts +3 -3
- package/dist/modules/admin-account/index.js +2 -2
- package/dist/modules/admin-account/schemas.d.ts +4 -0
- package/dist/modules/admin-account/schemas.js +4 -1
- package/dist/modules/admin-account/service.d.ts +1 -0
- package/dist/modules/admin-account/service.js +8 -0
- package/dist/modules/admin-permissions/components/inspector.js +31 -41
- package/dist/modules/admin-roles/components/create.js +43 -26
- package/dist/modules/admin-roles/components/permissions.js +26 -35
- package/dist/modules/admin-roles/components/update.js +26 -16
- package/dist/modules/admin-users/components/create.js +60 -40
- package/dist/modules/admin-users/components/roles.js +9 -15
- package/dist/modules/admin-users/components/set-password.js +30 -31
- package/dist/modules/admin-users/components/update.js +58 -39
- package/dist/modules/admin-users/dto.js +1 -0
- package/dist/modules/admin-users/repository.d.ts +17 -0
- package/dist/modules/admin-users/schemas.d.ts +4 -0
- package/dist/modules/admin-users/schemas.js +6 -2
- package/dist/modules/auth/components/sign-in-form.js +10 -8
- package/dist/presentation/group.d.ts +27 -0
- package/dist/presentation/group.js +14 -0
- package/dist/presentation/group.module.js +6 -0
- package/dist/presentation/group_module.css +19 -0
- package/dist/presentation/row.d.ts +25 -0
- package/dist/presentation/row.js +8 -0
- package/dist/presentation/row.module.js +5 -0
- package/dist/presentation/row_module.css +18 -0
- package/dist/presentation/tabs.d.ts +25 -0
- package/dist/presentation/tabs.js +39 -0
- package/dist/presentation/tabs.module.js +10 -0
- package/dist/presentation/tabs_module.css +68 -0
- package/dist/react.d.ts +66 -0
- package/dist/react.js +36 -0
- package/dist/services/admin-services-types.d.ts +16 -0
- package/dist/widgets/diff-viewer/diff-modal.d.ts +22 -0
- package/dist/widgets/diff-viewer/diff-modal.js +149 -0
- package/dist/widgets/diff-viewer/diff-modal.module.js +14 -0
- package/dist/widgets/diff-viewer/diff-modal_module.css +56 -0
- package/dist/widgets/status-badge/status-badge.d.ts +25 -0
- package/dist/widgets/status-badge/status-badge.js +37 -0
- package/dist/widgets/status-badge/status-badge.module.js +7 -0
- package/dist/widgets/status-badge/status-badge_module.css +20 -0
- package/package.json +14 -4
- package/src/fields/array/array-field.module.css +48 -0
- package/src/fields/array/array-field.tsx +267 -0
- package/src/fields/blocks/blocks-field.module.css +148 -0
- package/src/fields/blocks/blocks-field.tsx +323 -0
- package/src/fields/checkbox/checkbox-field.module.css +4 -0
- package/src/fields/checkbox/checkbox-field.tsx +54 -0
- package/src/fields/column-formatter.tsx +31 -0
- package/src/fields/date-time-formatter.tsx +22 -0
- package/src/fields/datetime/datetime-field.module.css +13 -0
- package/src/fields/datetime/datetime-field.tsx +54 -0
- package/src/fields/draggable-context-menu.module.css +127 -0
- package/src/fields/draggable-context-menu.tsx +87 -0
- package/src/fields/field-helpers.ts +69 -0
- package/src/fields/field-renderer.module.css +22 -0
- package/src/fields/field-renderer.tsx +288 -0
- package/src/fields/field-services-context.tsx +35 -0
- package/src/fields/field-services-types.ts +68 -0
- package/src/fields/file/file-field.module.css +153 -0
- package/src/fields/file/file-field.tsx +286 -0
- package/src/fields/file/file-upload-field.module.css +101 -0
- package/src/fields/file/file-upload-field.tsx +187 -0
- package/src/fields/group/group-field.module.css +43 -0
- package/src/fields/group/group-field.tsx +84 -0
- package/src/fields/image/image-field.module.css +155 -0
- package/src/fields/image/image-field.tsx +306 -0
- package/src/fields/image/image-upload-field.module.css +123 -0
- package/src/fields/image/image-upload-field.tsx +276 -0
- package/src/fields/local-date-time.tsx +88 -0
- package/src/fields/locale-badge.module.css +37 -0
- package/src/fields/locale-badge.tsx +32 -0
- package/src/fields/numerical/numerical-field.tsx +114 -0
- package/src/fields/relation/relation-display.module.css +36 -0
- package/src/fields/relation/relation-display.tsx +130 -0
- package/src/fields/relation/relation-field.module.css +83 -0
- package/src/fields/relation/relation-field.tsx +211 -0
- package/src/fields/relation/relation-picker.module.css +168 -0
- package/src/fields/relation/relation-picker.tsx +326 -0
- package/src/fields/relation/relation-summary.module.css +55 -0
- package/src/fields/relation/relation-summary.tsx +123 -0
- package/src/fields/select/select-field.module.css +13 -0
- package/src/fields/select/select-field.tsx +61 -0
- package/src/fields/sortable-item.module.css +167 -0
- package/src/fields/sortable-item.tsx +106 -0
- package/src/fields/text/text-field.module.css +13 -0
- package/src/fields/text/text-field.tsx +146 -0
- package/src/fields/text-area/text-area-field.module.css +13 -0
- package/src/fields/text-area/text-area-field.tsx +147 -0
- package/src/fields/use-field-change-handler.ts +112 -0
- package/src/forms/document-actions.module.css +160 -0
- package/src/forms/document-actions.tsx +482 -0
- package/src/forms/form-context.tsx +704 -0
- package/src/forms/form-renderer.module.css +321 -0
- package/src/forms/form-renderer.tsx +891 -0
- package/src/forms/navigation-guard.tsx +98 -0
- package/src/forms/path-widget.module.css +41 -0
- package/src/forms/path-widget.test.tsx +217 -0
- package/src/forms/path-widget.tsx +183 -0
- package/src/forms/upload-executor.ts +192 -0
- package/src/lib/translate-validation-error.ts +56 -0
- package/src/modules/admin-account/commands.ts +13 -0
- package/src/modules/admin-account/components/change-password.tsx +46 -31
- package/src/modules/admin-account/components/container.tsx +83 -38
- package/src/modules/admin-account/components/preferences.module.css +60 -0
- package/src/modules/admin-account/components/preferences.tsx +203 -0
- package/src/modules/admin-account/components/update.tsx +53 -27
- package/src/modules/admin-account/index.ts +3 -0
- package/src/modules/admin-account/schemas.ts +13 -0
- package/src/modules/admin-account/service.ts +12 -0
- package/src/modules/admin-permissions/components/inspector.tsx +22 -14
- package/src/modules/admin-roles/components/create.tsx +51 -23
- package/src/modules/admin-roles/components/permissions.tsx +25 -21
- package/src/modules/admin-roles/components/update.tsx +37 -19
- package/src/modules/admin-users/components/create.tsx +63 -34
- package/src/modules/admin-users/components/roles.tsx +9 -8
- package/src/modules/admin-users/components/set-password.tsx +34 -28
- package/src/modules/admin-users/components/update.tsx +58 -36
- package/src/modules/admin-users/dto.ts +1 -0
- package/src/modules/admin-users/repository.ts +17 -0
- package/src/modules/admin-users/schemas.ts +12 -0
- package/src/modules/auth/components/sign-in-form.tsx +14 -8
- package/src/presentation/group.module.css +41 -0
- package/src/presentation/group.tsx +40 -0
- package/src/presentation/row.module.css +32 -0
- package/src/presentation/row.tsx +33 -0
- package/src/presentation/tabs.module.css +107 -0
- package/src/presentation/tabs.tsx +84 -0
- package/src/react.ts +84 -0
- package/src/services/admin-services-types.ts +18 -0
- package/src/widgets/diff-viewer/diff-modal.module.css +79 -0
- package/src/widgets/diff-viewer/diff-modal.tsx +186 -0
- package/src/widgets/status-badge/status-badge.module.css +31 -0
- package/src/widgets/status-badge/status-badge.tsx +71 -0
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { LocalDateTime } from "@byline/admin/react";
|
|
5
|
+
import { useTranslation } from "@byline/i18n/react";
|
|
6
|
+
import { Button, CloseIcon, Drawer, EditIcon, IconButton } from "@byline/ui/react";
|
|
5
7
|
import classnames from "classnames";
|
|
6
8
|
import { ChangeAccountPassword } from "./change-password.js";
|
|
7
9
|
import container_module from "./container.module.js";
|
|
10
|
+
import { Preferences } from "./preferences.js";
|
|
8
11
|
import { UpdateAccount } from "./update.js";
|
|
9
|
-
const
|
|
10
|
-
update:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
change_password: {
|
|
15
|
-
title: 'Change Password',
|
|
16
|
-
component: ChangeAccountPassword
|
|
17
|
-
},
|
|
18
|
-
empty: {
|
|
19
|
-
title: '',
|
|
20
|
-
component: ()=>null
|
|
21
|
-
}
|
|
12
|
+
const panelComponents = {
|
|
13
|
+
update: UpdateAccount,
|
|
14
|
+
change_password: ChangeAccountPassword,
|
|
15
|
+
preferences: Preferences,
|
|
16
|
+
empty: ()=>null
|
|
22
17
|
};
|
|
23
|
-
function ContainerSection({ title, onEdit, children }) {
|
|
18
|
+
function ContainerSection({ title, onEdit, editAriaLabel, children }) {
|
|
24
19
|
return /*#__PURE__*/ jsxs("div", {
|
|
25
20
|
className: classnames('byline-account-section', container_module.section),
|
|
26
21
|
children: [
|
|
@@ -33,7 +28,7 @@ function ContainerSection({ title, onEdit, children }) {
|
|
|
33
28
|
onEdit ? /*#__PURE__*/ jsx(IconButton, {
|
|
34
29
|
variant: "text",
|
|
35
30
|
onClick: onEdit,
|
|
36
|
-
"aria-label":
|
|
31
|
+
"aria-label": editAriaLabel ?? title,
|
|
37
32
|
children: /*#__PURE__*/ jsx(EditIcon, {
|
|
38
33
|
width: "20px",
|
|
39
34
|
height: "20px"
|
|
@@ -48,6 +43,7 @@ function ContainerSection({ title, onEdit, children }) {
|
|
|
48
43
|
});
|
|
49
44
|
}
|
|
50
45
|
function AccountSelfContainer({ account }) {
|
|
46
|
+
const { t } = useTranslation('byline-admin');
|
|
51
47
|
const [currentAccount, setCurrentAccount] = useState(account);
|
|
52
48
|
const [current, setCurrent] = useState('empty');
|
|
53
49
|
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
|
@@ -62,149 +58,204 @@ function AccountSelfContainer({ account }) {
|
|
|
62
58
|
const handleSuccess = (updated)=>{
|
|
63
59
|
setCurrentAccount(updated);
|
|
64
60
|
};
|
|
65
|
-
const Panel =
|
|
61
|
+
const Panel = panelComponents[current];
|
|
62
|
+
const panelTitles = {
|
|
63
|
+
update: t('account.sections.profile'),
|
|
64
|
+
change_password: t('account.sections.password'),
|
|
65
|
+
preferences: t('account.sections.preferences'),
|
|
66
|
+
empty: ''
|
|
67
|
+
};
|
|
68
|
+
const editAriaFor = (section)=>t('account.editAriaLabel', {
|
|
69
|
+
section
|
|
70
|
+
});
|
|
66
71
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
67
72
|
children: [
|
|
68
73
|
/*#__PURE__*/ jsxs("div", {
|
|
69
74
|
className: classnames('byline-account-grid', container_module.grid),
|
|
70
75
|
children: [
|
|
71
|
-
/*#__PURE__*/
|
|
76
|
+
/*#__PURE__*/ jsxs("div", {
|
|
72
77
|
className: classnames('byline-account-column', container_module.column),
|
|
73
|
-
children:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ jsxs(ContainerSection, {
|
|
80
|
+
title: t('account.sections.profile'),
|
|
81
|
+
onEdit: openDrawer('update'),
|
|
82
|
+
editAriaLabel: editAriaFor(t('account.sections.profile')),
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ jsxs("p", {
|
|
85
|
+
className: classnames('byline-account-line', container_module.line),
|
|
86
|
+
children: [
|
|
87
|
+
/*#__PURE__*/ jsx("span", {
|
|
88
|
+
className: "muted",
|
|
89
|
+
children: t('account.profile.emailColon')
|
|
90
|
+
}),
|
|
91
|
+
' ',
|
|
92
|
+
currentAccount.email
|
|
93
|
+
]
|
|
94
|
+
}),
|
|
95
|
+
/*#__PURE__*/ jsxs("p", {
|
|
96
|
+
className: classnames('byline-account-line', container_module.line),
|
|
97
|
+
children: [
|
|
98
|
+
/*#__PURE__*/ jsx("span", {
|
|
99
|
+
className: "muted",
|
|
100
|
+
children: t('account.profile.givenName')
|
|
101
|
+
}),
|
|
102
|
+
' ',
|
|
103
|
+
currentAccount.given_name ?? /*#__PURE__*/ jsx("span", {
|
|
104
|
+
className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
|
|
105
|
+
children: t('common.notSet')
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
/*#__PURE__*/ jsxs("p", {
|
|
110
|
+
className: classnames('byline-account-line', container_module.line),
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ jsx("span", {
|
|
113
|
+
className: "muted",
|
|
114
|
+
children: t('account.profile.familyName')
|
|
115
|
+
}),
|
|
116
|
+
' ',
|
|
117
|
+
currentAccount.family_name ?? /*#__PURE__*/ jsx("span", {
|
|
118
|
+
className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
|
|
119
|
+
children: t('common.notSet')
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
}),
|
|
123
|
+
/*#__PURE__*/ jsxs("p", {
|
|
124
|
+
className: classnames('byline-account-cta-line', container_module["cta-line"]),
|
|
125
|
+
children: [
|
|
126
|
+
/*#__PURE__*/ jsx("span", {
|
|
127
|
+
className: "muted",
|
|
128
|
+
children: t('account.profile.username')
|
|
129
|
+
}),
|
|
130
|
+
' ',
|
|
131
|
+
currentAccount.username ?? /*#__PURE__*/ jsx("span", {
|
|
132
|
+
className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
|
|
133
|
+
children: t('common.notSet')
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ jsx(Button, {
|
|
138
|
+
size: "sm",
|
|
139
|
+
onClick: openDrawer('update'),
|
|
140
|
+
children: t('account.profile.editButton')
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ jsxs("div", {
|
|
143
|
+
className: classnames('muted', 'byline-account-meta', container_module.meta),
|
|
144
|
+
children: [
|
|
145
|
+
/*#__PURE__*/ jsxs("p", {
|
|
146
|
+
children: [
|
|
147
|
+
/*#__PURE__*/ jsxs("span", {
|
|
148
|
+
className: "font-bold",
|
|
149
|
+
children: [
|
|
150
|
+
t('account.profile.created'),
|
|
151
|
+
"\xa0"
|
|
152
|
+
]
|
|
153
|
+
}),
|
|
154
|
+
/*#__PURE__*/ jsx(LocalDateTime, {
|
|
155
|
+
value: currentAccount.created_at
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ jsxs("p", {
|
|
160
|
+
children: [
|
|
161
|
+
/*#__PURE__*/ jsxs("span", {
|
|
162
|
+
className: "font-bold",
|
|
163
|
+
children: [
|
|
164
|
+
t('account.profile.updated'),
|
|
165
|
+
"\xa0"
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ jsx(LocalDateTime, {
|
|
169
|
+
value: currentAccount.updated_at
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
}),
|
|
173
|
+
/*#__PURE__*/ jsxs("p", {
|
|
174
|
+
className: classnames('byline-account-line', container_module.line),
|
|
175
|
+
children: [
|
|
176
|
+
/*#__PURE__*/ jsxs("span", {
|
|
177
|
+
className: "font-bold",
|
|
178
|
+
children: [
|
|
179
|
+
t('account.profile.lastLogin'),
|
|
180
|
+
"\xa0"
|
|
181
|
+
]
|
|
182
|
+
}),
|
|
183
|
+
/*#__PURE__*/ jsx(LocalDateTime, {
|
|
184
|
+
value: currentAccount.last_login,
|
|
185
|
+
fallback: t('common.never')
|
|
186
|
+
})
|
|
187
|
+
]
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}),
|
|
193
|
+
/*#__PURE__*/ jsxs(ContainerSection, {
|
|
194
|
+
title: t('account.sections.preferences'),
|
|
195
|
+
onEdit: openDrawer('preferences'),
|
|
196
|
+
editAriaLabel: editAriaFor(t('account.sections.preferences')),
|
|
197
|
+
children: [
|
|
198
|
+
/*#__PURE__*/ jsxs("p", {
|
|
199
|
+
className: classnames('byline-account-line', container_module.line),
|
|
200
|
+
children: [
|
|
201
|
+
/*#__PURE__*/ jsx("span", {
|
|
202
|
+
className: "muted",
|
|
203
|
+
children: t('account.preferences.interfaceLanguage')
|
|
204
|
+
}),
|
|
205
|
+
' ',
|
|
206
|
+
currentAccount.preferred_locale ?? /*#__PURE__*/ jsx("span", {
|
|
207
|
+
className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
|
|
208
|
+
children: t('language.useBrowserDefault')
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
}),
|
|
212
|
+
/*#__PURE__*/ jsx("p", {
|
|
213
|
+
className: classnames('byline-account-cta-line', container_module["cta-line"]),
|
|
214
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
215
|
+
size: "sm",
|
|
216
|
+
onClick: openDrawer('preferences'),
|
|
217
|
+
children: t('account.preferences.editButton')
|
|
172
218
|
})
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
219
|
+
}),
|
|
220
|
+
/*#__PURE__*/ jsx("p", {
|
|
221
|
+
className: classnames('muted', 'byline-account-status-help', container_module["status-help"]),
|
|
222
|
+
children: t('account.preferences.help')
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
})
|
|
226
|
+
]
|
|
177
227
|
}),
|
|
178
228
|
/*#__PURE__*/ jsxs("div", {
|
|
179
229
|
className: classnames('byline-account-column', container_module.column),
|
|
180
230
|
children: [
|
|
181
231
|
/*#__PURE__*/ jsxs(ContainerSection, {
|
|
182
|
-
title:
|
|
232
|
+
title: t('account.sections.password'),
|
|
183
233
|
onEdit: openDrawer('change_password'),
|
|
234
|
+
editAriaLabel: editAriaFor(t('account.sections.password')),
|
|
184
235
|
children: [
|
|
185
236
|
/*#__PURE__*/ jsx("p", {
|
|
186
237
|
className: classnames('byline-account-cta-line', container_module["cta-line"]),
|
|
187
|
-
children:
|
|
238
|
+
children: t('account.password.intro')
|
|
188
239
|
}),
|
|
189
240
|
/*#__PURE__*/ jsx(Button, {
|
|
190
241
|
size: "sm",
|
|
191
242
|
onClick: openDrawer('change_password'),
|
|
192
|
-
children:
|
|
243
|
+
children: t('account.password.editButton')
|
|
193
244
|
})
|
|
194
245
|
]
|
|
195
246
|
}),
|
|
196
247
|
/*#__PURE__*/ jsxs(ContainerSection, {
|
|
197
|
-
title:
|
|
248
|
+
title: t('account.sections.status'),
|
|
198
249
|
children: [
|
|
199
250
|
/*#__PURE__*/ jsxs("p", {
|
|
200
251
|
className: classnames('byline-account-line', container_module.line),
|
|
201
252
|
children: [
|
|
202
253
|
/*#__PURE__*/ jsx("span", {
|
|
203
254
|
className: "muted",
|
|
204
|
-
children:
|
|
255
|
+
children: t('account.status.superAdmin')
|
|
205
256
|
}),
|
|
206
257
|
' ',
|
|
207
|
-
currentAccount.is_super_admin ? '
|
|
258
|
+
currentAccount.is_super_admin ? t('common.boolean.yes') : t('common.boolean.no')
|
|
208
259
|
]
|
|
209
260
|
}),
|
|
210
261
|
/*#__PURE__*/ jsxs("p", {
|
|
@@ -212,10 +263,10 @@ function AccountSelfContainer({ account }) {
|
|
|
212
263
|
children: [
|
|
213
264
|
/*#__PURE__*/ jsx("span", {
|
|
214
265
|
className: "muted",
|
|
215
|
-
children:
|
|
266
|
+
children: t('account.status.emailVerified')
|
|
216
267
|
}),
|
|
217
268
|
' ',
|
|
218
|
-
currentAccount.is_email_verified ? '
|
|
269
|
+
currentAccount.is_email_verified ? t('common.boolean.yes') : t('common.boolean.no')
|
|
219
270
|
]
|
|
220
271
|
}),
|
|
221
272
|
/*#__PURE__*/ jsxs("p", {
|
|
@@ -223,18 +274,18 @@ function AccountSelfContainer({ account }) {
|
|
|
223
274
|
children: [
|
|
224
275
|
/*#__PURE__*/ jsx("span", {
|
|
225
276
|
className: "muted",
|
|
226
|
-
children:
|
|
277
|
+
children: t('account.status.status')
|
|
227
278
|
}),
|
|
228
279
|
' ',
|
|
229
280
|
/*#__PURE__*/ jsx("span", {
|
|
230
281
|
className: currentAccount.is_enabled ? classnames('byline-account-status-on', container_module["status-on"]) : classnames('byline-account-status-off', container_module["status-off"]),
|
|
231
|
-
children: currentAccount.is_enabled ? '
|
|
282
|
+
children: currentAccount.is_enabled ? t('account.status.enabled') : t('account.status.disabled')
|
|
232
283
|
})
|
|
233
284
|
]
|
|
234
285
|
}),
|
|
235
286
|
/*#__PURE__*/ jsx("p", {
|
|
236
287
|
className: classnames('muted', 'byline-account-status-help', container_module["status-help"]),
|
|
237
|
-
children:
|
|
288
|
+
children: t('account.status.help')
|
|
238
289
|
})
|
|
239
290
|
]
|
|
240
291
|
})
|
|
@@ -263,7 +314,7 @@ function AccountSelfContainer({ account }) {
|
|
|
263
314
|
children: "no action"
|
|
264
315
|
}),
|
|
265
316
|
/*#__PURE__*/ jsx(IconButton, {
|
|
266
|
-
"aria-label":
|
|
317
|
+
"aria-label": t('common.actions.close'),
|
|
267
318
|
size: "sm",
|
|
268
319
|
onClick: closeDrawer,
|
|
269
320
|
children: /*#__PURE__*/ jsx(CloseIcon, {
|
|
@@ -276,7 +327,7 @@ function AccountSelfContainer({ account }) {
|
|
|
276
327
|
}),
|
|
277
328
|
/*#__PURE__*/ jsx(Drawer.Header, {
|
|
278
329
|
children: /*#__PURE__*/ jsx("h2", {
|
|
279
|
-
children:
|
|
330
|
+
children: panelTitles[current]
|
|
280
331
|
})
|
|
281
332
|
}),
|
|
282
333
|
/*#__PURE__*/ jsx(Drawer.Content, {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AccountResponse } from '../index.js';
|
|
2
|
+
interface PreferencesProps {
|
|
3
|
+
account: AccountResponse;
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
onSuccess?: (account: AccountResponse) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function Preferences({ account, onClose, onSuccess }: PreferencesProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import { revalidateLogic, useForm } from "@tanstack/react-form-start";
|
|
5
|
+
import { getClientConfig } from "@byline/core";
|
|
6
|
+
import { Alert, Button, LoaderEllipsis, Select } from "@byline/ui/react";
|
|
7
|
+
import classnames from "classnames";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { useBylineAdminServices } from "../../../services/admin-services-context.js";
|
|
10
|
+
import preferences_module from "./preferences.module.js";
|
|
11
|
+
const AUTO_VALUE = '__auto__';
|
|
12
|
+
const preferencesSchema = z.object({
|
|
13
|
+
locale: z.string().min(1, {
|
|
14
|
+
message: 'Select a language'
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
function defaultsFrom(account) {
|
|
18
|
+
return {
|
|
19
|
+
locale: account.preferred_locale ?? AUTO_VALUE
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function Preferences({ account, onClose, onSuccess }) {
|
|
23
|
+
const { setInterfaceLocale } = useBylineAdminServices();
|
|
24
|
+
const [formError, setFormError] = useState(null);
|
|
25
|
+
const [successMessage, setSuccessMessage] = useState(null);
|
|
26
|
+
const localeItems = useMemo(()=>{
|
|
27
|
+
const { i18n } = getClientConfig();
|
|
28
|
+
const definitionByCode = new Map((i18n.interface.localeDefinitions ?? []).map((d)=>[
|
|
29
|
+
d.code,
|
|
30
|
+
d.nativeName
|
|
31
|
+
]));
|
|
32
|
+
const items = i18n.interface.locales.map((code)=>({
|
|
33
|
+
value: code,
|
|
34
|
+
label: definitionByCode.get(code) ?? code
|
|
35
|
+
}));
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
value: AUTO_VALUE,
|
|
39
|
+
label: 'Use browser default'
|
|
40
|
+
},
|
|
41
|
+
...items
|
|
42
|
+
];
|
|
43
|
+
}, []);
|
|
44
|
+
const form = useForm({
|
|
45
|
+
defaultValues: defaultsFrom(account),
|
|
46
|
+
validationLogic: revalidateLogic({
|
|
47
|
+
mode: 'blur',
|
|
48
|
+
modeAfterSubmission: 'change'
|
|
49
|
+
}),
|
|
50
|
+
validators: {
|
|
51
|
+
onDynamic: preferencesSchema
|
|
52
|
+
},
|
|
53
|
+
onSubmit: async ({ value })=>{
|
|
54
|
+
setFormError(null);
|
|
55
|
+
setSuccessMessage(null);
|
|
56
|
+
const nextLocale = value.locale === AUTO_VALUE ? null : value.locale;
|
|
57
|
+
if (nextLocale === (account.preferred_locale ?? null)) return void setSuccessMessage('No changes to save.');
|
|
58
|
+
try {
|
|
59
|
+
const result = await setInterfaceLocale({
|
|
60
|
+
data: {
|
|
61
|
+
locale: nextLocale
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (null != result.account) {
|
|
65
|
+
setSuccessMessage('Saved.');
|
|
66
|
+
onSuccess?.(result.account);
|
|
67
|
+
} else setSuccessMessage('Saved.');
|
|
68
|
+
} catch {
|
|
69
|
+
setFormError('Could not save changes. Please try again.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return /*#__PURE__*/ jsx("div", {
|
|
74
|
+
className: classnames('byline-account-preferences-wrap', preferences_module.wrap),
|
|
75
|
+
children: /*#__PURE__*/ jsxs("form", {
|
|
76
|
+
noValidate: true,
|
|
77
|
+
onSubmit: (event)=>{
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
form.handleSubmit();
|
|
81
|
+
},
|
|
82
|
+
className: classnames('byline-account-preferences-form', preferences_module.form),
|
|
83
|
+
children: [
|
|
84
|
+
formError ? /*#__PURE__*/ jsx(Alert, {
|
|
85
|
+
intent: "danger",
|
|
86
|
+
children: formError
|
|
87
|
+
}) : null,
|
|
88
|
+
successMessage ? /*#__PURE__*/ jsx(Alert, {
|
|
89
|
+
intent: "success",
|
|
90
|
+
children: successMessage
|
|
91
|
+
}) : null,
|
|
92
|
+
/*#__PURE__*/ jsx(form.Field, {
|
|
93
|
+
name: "locale",
|
|
94
|
+
children: (field)=>/*#__PURE__*/ jsxs("div", {
|
|
95
|
+
className: classnames('byline-account-preferences-row', preferences_module.row),
|
|
96
|
+
children: [
|
|
97
|
+
/*#__PURE__*/ jsx("label", {
|
|
98
|
+
htmlFor: "preferences-locale-select",
|
|
99
|
+
className: classnames('byline-account-preferences-label', preferences_module.label),
|
|
100
|
+
children: "Interface language"
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ jsx(Select, {
|
|
103
|
+
id: "preferences-locale-select",
|
|
104
|
+
size: "sm",
|
|
105
|
+
ariaLabel: "Interface language",
|
|
106
|
+
value: field.state.value,
|
|
107
|
+
items: localeItems,
|
|
108
|
+
onValueChange: (value)=>{
|
|
109
|
+
if (null != value) field.handleChange(value);
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ jsx("p", {
|
|
113
|
+
className: classnames('muted', 'byline-account-preferences-help', preferences_module.help),
|
|
114
|
+
children: 'Choose "Use browser default" to let your browser\'s language settings decide.'
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
})
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ jsxs("div", {
|
|
120
|
+
className: classnames('byline-account-preferences-actions', preferences_module.actions),
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ jsx(Button, {
|
|
123
|
+
type: "button",
|
|
124
|
+
intent: "secondary",
|
|
125
|
+
size: "sm",
|
|
126
|
+
onClick: onClose,
|
|
127
|
+
className: classnames('byline-account-preferences-action', preferences_module.action),
|
|
128
|
+
children: successMessage ? 'Close' : 'Cancel'
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ jsx(form.Subscribe, {
|
|
131
|
+
selector: (state)=>({
|
|
132
|
+
canSubmit: state.canSubmit,
|
|
133
|
+
isSubmitting: state.isSubmitting
|
|
134
|
+
}),
|
|
135
|
+
children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
|
|
136
|
+
size: "sm",
|
|
137
|
+
intent: "primary",
|
|
138
|
+
type: "submit",
|
|
139
|
+
disabled: !canSubmit || isSubmitting,
|
|
140
|
+
className: classnames('byline-account-preferences-action', preferences_module.action),
|
|
141
|
+
children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
|
|
142
|
+
size: 42
|
|
143
|
+
}) : 'Save'
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export { Preferences };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./preferences_module.css";
|
|
2
|
+
const preferences_module = {
|
|
3
|
+
wrap: "wrap-Z0_u4U",
|
|
4
|
+
form: "form-vgAqtC",
|
|
5
|
+
row: "row-v7Li8f",
|
|
6
|
+
label: "label-Y07C1f",
|
|
7
|
+
help: "help-pf3pyB",
|
|
8
|
+
actions: "actions-cxaMe0",
|
|
9
|
+
action: "action-k1vCLN"
|
|
10
|
+
};
|
|
11
|
+
export default preferences_module;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
:is(.wrap-Z0_u4U, .byline-account-preferences-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-vgAqtC, .byline-account-preferences-form) {
|
|
10
|
+
gap: var(--spacing-16);
|
|
11
|
+
padding-top: var(--spacing-8);
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
display: flex;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:is(.row-v7Li8f, .byline-account-preferences-row) {
|
|
17
|
+
gap: var(--spacing-4);
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
display: flex;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:is(.label-Y07C1f, .byline-account-preferences-label) {
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:is(.help-pf3pyB, .byline-account-preferences-help) {
|
|
27
|
+
font-size: .875rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:is(.actions-cxaMe0, .byline-account-preferences-actions) {
|
|
31
|
+
justify-content: flex-end;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: var(--spacing-8);
|
|
34
|
+
margin-top: var(--spacing-16);
|
|
35
|
+
display: flex;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:is(.action-k1vCLN, .byline-account-preferences-action) {
|
|
39
|
+
min-width: 4rem;
|
|
40
|
+
}
|
|
41
|
+
|