@byline/admin 2.5.1 → 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.
Files changed (260) hide show
  1. package/dist/fields/array/array-field.d.ts +14 -0
  2. package/dist/fields/array/array-field.js +177 -0
  3. package/dist/fields/array/array-field.module.js +11 -0
  4. package/dist/fields/array/array-field_module.css +32 -0
  5. package/dist/fields/blocks/blocks-field.d.ts +13 -0
  6. package/dist/fields/blocks/blocks-field.js +245 -0
  7. package/dist/fields/blocks/blocks-field.module.js +26 -0
  8. package/dist/fields/blocks/blocks-field_module.css +107 -0
  9. package/dist/fields/checkbox/checkbox-field.d.ts +16 -0
  10. package/dist/fields/checkbox/checkbox-field.js +28 -0
  11. package/dist/fields/checkbox/checkbox-field.module.js +6 -0
  12. package/dist/fields/checkbox/checkbox-field_module.css +4 -0
  13. package/dist/fields/column-formatter.d.ts +20 -0
  14. package/dist/fields/column-formatter.js +15 -0
  15. package/dist/fields/date-time-formatter.d.ts +16 -0
  16. package/dist/fields/date-time-formatter.js +8 -0
  17. package/dist/fields/datetime/datetime-field.d.ts +16 -0
  18. package/dist/fields/datetime/datetime-field.js +37 -0
  19. package/dist/fields/datetime/datetime-field.module.js +5 -0
  20. package/dist/fields/datetime/datetime-field_module.css +4 -0
  21. package/dist/fields/draggable-context-menu.d.ts +6 -0
  22. package/dist/fields/draggable-context-menu.js +85 -0
  23. package/dist/fields/draggable-context-menu.module.js +15 -0
  24. package/dist/fields/draggable-context-menu_module.css +91 -0
  25. package/dist/fields/field-helpers.d.ts +26 -0
  26. package/dist/fields/field-helpers.js +50 -0
  27. package/dist/fields/field-renderer.d.ts +37 -0
  28. package/dist/fields/field-renderer.js +206 -0
  29. package/dist/fields/field-renderer.module.js +8 -0
  30. package/dist/fields/field-renderer_module.css +11 -0
  31. package/dist/fields/field-services-context.d.ts +16 -0
  32. package/dist/fields/field-services-context.js +13 -0
  33. package/dist/fields/field-services-types.d.ts +63 -0
  34. package/dist/fields/field-services-types.js +1 -0
  35. package/dist/fields/file/file-field.d.ts +19 -0
  36. package/dist/fields/file/file-field.js +225 -0
  37. package/dist/fields/file/file-field.module.js +18 -0
  38. package/dist/fields/file/file-field_module.css +131 -0
  39. package/dist/fields/file/file-upload-field.d.ts +21 -0
  40. package/dist/fields/file/file-upload-field.js +130 -0
  41. package/dist/fields/file/file-upload-field.module.js +15 -0
  42. package/dist/fields/file/file-upload-field_module.css +74 -0
  43. package/dist/fields/group/group-field.d.ts +15 -0
  44. package/dist/fields/group/group-field.js +59 -0
  45. package/dist/fields/group/group-field.module.js +9 -0
  46. package/dist/fields/group/group-field_module.css +27 -0
  47. package/dist/fields/image/image-field.d.ts +19 -0
  48. package/dist/fields/image/image-field.js +241 -0
  49. package/dist/fields/image/image-field.module.js +22 -0
  50. package/dist/fields/image/image-field_module.css +121 -0
  51. package/dist/fields/image/image-upload-field.d.ts +21 -0
  52. package/dist/fields/image/image-upload-field.js +190 -0
  53. package/dist/fields/image/image-upload-field.module.js +19 -0
  54. package/dist/fields/image/image-upload-field_module.css +92 -0
  55. package/dist/fields/local-date-time.d.ts +27 -0
  56. package/dist/fields/local-date-time.js +49 -0
  57. package/dist/fields/locale-badge.d.ts +18 -0
  58. package/dist/fields/locale-badge.js +10 -0
  59. package/dist/fields/locale-badge.module.js +5 -0
  60. package/dist/fields/locale-badge_module.css +27 -0
  61. package/dist/fields/numerical/numerical-field.d.ts +18 -0
  62. package/dist/fields/numerical/numerical-field.js +74 -0
  63. package/dist/fields/relation/relation-display.d.ts +40 -0
  64. package/dist/fields/relation/relation-display.js +58 -0
  65. package/dist/fields/relation/relation-display.module.js +9 -0
  66. package/dist/fields/relation/relation-display_module.css +21 -0
  67. package/dist/fields/relation/relation-field.d.ts +18 -0
  68. package/dist/fields/relation/relation-field.js +138 -0
  69. package/dist/fields/relation/relation-field.module.js +13 -0
  70. package/dist/fields/relation/relation-field_module.css +62 -0
  71. package/dist/fields/relation/relation-picker.d.ts +49 -0
  72. package/dist/fields/relation/relation-picker.js +236 -0
  73. package/dist/fields/relation/relation-picker.module.js +26 -0
  74. package/dist/fields/relation/relation-picker_module.css +124 -0
  75. package/dist/fields/relation/relation-summary.d.ts +31 -0
  76. package/dist/fields/relation/relation-summary.js +50 -0
  77. package/dist/fields/relation/relation-summary.module.js +11 -0
  78. package/dist/fields/relation/relation-summary_module.css +37 -0
  79. package/dist/fields/select/select-field.d.ts +16 -0
  80. package/dist/fields/select/select-field.js +50 -0
  81. package/dist/fields/select/select-field.module.js +5 -0
  82. package/dist/fields/select/select-field_module.css +4 -0
  83. package/dist/fields/sortable-item.d.ts +15 -0
  84. package/dist/fields/sortable-item.js +81 -0
  85. package/dist/fields/sortable-item.module.js +22 -0
  86. package/dist/fields/sortable-item_module.css +124 -0
  87. package/dist/fields/text/text-field.d.ts +20 -0
  88. package/dist/fields/text/text-field.js +104 -0
  89. package/dist/fields/text/text-field.module.js +6 -0
  90. package/dist/fields/text/text-field_module.css +5 -0
  91. package/dist/fields/text-area/text-area-field.d.ts +20 -0
  92. package/dist/fields/text-area/text-area-field.js +105 -0
  93. package/dist/fields/text-area/text-area-field.module.js +6 -0
  94. package/dist/fields/text-area/text-area-field_module.css +5 -0
  95. package/dist/fields/use-field-change-handler.d.ts +23 -0
  96. package/dist/fields/use-field-change-handler.js +52 -0
  97. package/dist/forms/document-actions.d.ts +48 -0
  98. package/dist/forms/document-actions.js +475 -0
  99. package/dist/forms/document-actions.module.js +34 -0
  100. package/dist/forms/document-actions_module.css +118 -0
  101. package/dist/forms/form-context.d.ts +89 -0
  102. package/dist/forms/form-context.js +466 -0
  103. package/dist/forms/form-renderer.d.ts +98 -0
  104. package/dist/forms/form-renderer.js +597 -0
  105. package/dist/forms/form-renderer.module.js +46 -0
  106. package/dist/forms/form-renderer_module.css +245 -0
  107. package/dist/forms/navigation-guard.d.ts +54 -0
  108. package/dist/forms/navigation-guard.js +22 -0
  109. package/dist/forms/path-widget.d.ts +36 -0
  110. package/dist/forms/path-widget.js +116 -0
  111. package/dist/forms/path-widget.module.js +8 -0
  112. package/dist/forms/path-widget_module.css +29 -0
  113. package/dist/forms/upload-executor.d.ts +57 -0
  114. package/dist/forms/upload-executor.js +94 -0
  115. package/dist/lib/translate-validation-error.d.ts +36 -0
  116. package/dist/lib/translate-validation-error.js +11 -0
  117. package/dist/modules/admin-account/commands.d.ts +2 -1
  118. package/dist/modules/admin-account/commands.js +13 -2
  119. package/dist/modules/admin-account/components/change-password.js +45 -36
  120. package/dist/modules/admin-account/components/container.js +185 -134
  121. package/dist/modules/admin-account/components/preferences.d.ts +8 -0
  122. package/dist/modules/admin-account/components/preferences.js +152 -0
  123. package/dist/modules/admin-account/components/preferences.module.js +11 -0
  124. package/dist/modules/admin-account/components/preferences_module.css +41 -0
  125. package/dist/modules/admin-account/components/update.js +50 -31
  126. package/dist/modules/admin-account/index.d.ts +3 -3
  127. package/dist/modules/admin-account/index.js +2 -2
  128. package/dist/modules/admin-account/schemas.d.ts +4 -0
  129. package/dist/modules/admin-account/schemas.js +4 -1
  130. package/dist/modules/admin-account/service.d.ts +1 -0
  131. package/dist/modules/admin-account/service.js +8 -0
  132. package/dist/modules/admin-permissions/components/inspector.js +31 -41
  133. package/dist/modules/admin-roles/components/create.js +43 -26
  134. package/dist/modules/admin-roles/components/permissions.js +26 -35
  135. package/dist/modules/admin-roles/components/update.js +26 -16
  136. package/dist/modules/admin-users/components/create.js +60 -40
  137. package/dist/modules/admin-users/components/roles.js +9 -15
  138. package/dist/modules/admin-users/components/set-password.js +30 -31
  139. package/dist/modules/admin-users/components/update.js +58 -39
  140. package/dist/modules/admin-users/dto.js +1 -0
  141. package/dist/modules/admin-users/repository.d.ts +17 -0
  142. package/dist/modules/admin-users/schemas.d.ts +4 -0
  143. package/dist/modules/admin-users/schemas.js +6 -2
  144. package/dist/modules/auth/components/sign-in-form.js +10 -8
  145. package/dist/presentation/group.d.ts +27 -0
  146. package/dist/presentation/group.js +14 -0
  147. package/dist/presentation/group.module.js +6 -0
  148. package/dist/presentation/group_module.css +19 -0
  149. package/dist/presentation/row.d.ts +25 -0
  150. package/dist/presentation/row.js +8 -0
  151. package/dist/presentation/row.module.js +5 -0
  152. package/dist/presentation/row_module.css +18 -0
  153. package/dist/presentation/tabs.d.ts +25 -0
  154. package/dist/presentation/tabs.js +39 -0
  155. package/dist/presentation/tabs.module.js +10 -0
  156. package/dist/presentation/tabs_module.css +68 -0
  157. package/dist/react.d.ts +66 -0
  158. package/dist/react.js +36 -0
  159. package/dist/services/admin-services-types.d.ts +16 -0
  160. package/dist/widgets/diff-viewer/diff-modal.d.ts +22 -0
  161. package/dist/widgets/diff-viewer/diff-modal.js +149 -0
  162. package/dist/widgets/diff-viewer/diff-modal.module.js +14 -0
  163. package/dist/widgets/diff-viewer/diff-modal_module.css +56 -0
  164. package/dist/widgets/status-badge/status-badge.d.ts +25 -0
  165. package/dist/widgets/status-badge/status-badge.js +37 -0
  166. package/dist/widgets/status-badge/status-badge.module.js +7 -0
  167. package/dist/widgets/status-badge/status-badge_module.css +20 -0
  168. package/package.json +14 -4
  169. package/src/fields/array/array-field.module.css +48 -0
  170. package/src/fields/array/array-field.tsx +267 -0
  171. package/src/fields/blocks/blocks-field.module.css +148 -0
  172. package/src/fields/blocks/blocks-field.tsx +323 -0
  173. package/src/fields/checkbox/checkbox-field.module.css +4 -0
  174. package/src/fields/checkbox/checkbox-field.tsx +54 -0
  175. package/src/fields/column-formatter.tsx +31 -0
  176. package/src/fields/date-time-formatter.tsx +22 -0
  177. package/src/fields/datetime/datetime-field.module.css +13 -0
  178. package/src/fields/datetime/datetime-field.tsx +54 -0
  179. package/src/fields/draggable-context-menu.module.css +127 -0
  180. package/src/fields/draggable-context-menu.tsx +87 -0
  181. package/src/fields/field-helpers.ts +69 -0
  182. package/src/fields/field-renderer.module.css +22 -0
  183. package/src/fields/field-renderer.tsx +288 -0
  184. package/src/fields/field-services-context.tsx +35 -0
  185. package/src/fields/field-services-types.ts +68 -0
  186. package/src/fields/file/file-field.module.css +153 -0
  187. package/src/fields/file/file-field.tsx +286 -0
  188. package/src/fields/file/file-upload-field.module.css +101 -0
  189. package/src/fields/file/file-upload-field.tsx +187 -0
  190. package/src/fields/group/group-field.module.css +43 -0
  191. package/src/fields/group/group-field.tsx +84 -0
  192. package/src/fields/image/image-field.module.css +155 -0
  193. package/src/fields/image/image-field.tsx +306 -0
  194. package/src/fields/image/image-upload-field.module.css +123 -0
  195. package/src/fields/image/image-upload-field.tsx +276 -0
  196. package/src/fields/local-date-time.tsx +88 -0
  197. package/src/fields/locale-badge.module.css +37 -0
  198. package/src/fields/locale-badge.tsx +32 -0
  199. package/src/fields/numerical/numerical-field.tsx +114 -0
  200. package/src/fields/relation/relation-display.module.css +36 -0
  201. package/src/fields/relation/relation-display.tsx +130 -0
  202. package/src/fields/relation/relation-field.module.css +83 -0
  203. package/src/fields/relation/relation-field.tsx +211 -0
  204. package/src/fields/relation/relation-picker.module.css +168 -0
  205. package/src/fields/relation/relation-picker.tsx +326 -0
  206. package/src/fields/relation/relation-summary.module.css +55 -0
  207. package/src/fields/relation/relation-summary.tsx +123 -0
  208. package/src/fields/select/select-field.module.css +13 -0
  209. package/src/fields/select/select-field.tsx +61 -0
  210. package/src/fields/sortable-item.module.css +167 -0
  211. package/src/fields/sortable-item.tsx +106 -0
  212. package/src/fields/text/text-field.module.css +13 -0
  213. package/src/fields/text/text-field.tsx +146 -0
  214. package/src/fields/text-area/text-area-field.module.css +13 -0
  215. package/src/fields/text-area/text-area-field.tsx +147 -0
  216. package/src/fields/use-field-change-handler.ts +112 -0
  217. package/src/forms/document-actions.module.css +160 -0
  218. package/src/forms/document-actions.tsx +482 -0
  219. package/src/forms/form-context.tsx +704 -0
  220. package/src/forms/form-renderer.module.css +321 -0
  221. package/src/forms/form-renderer.tsx +891 -0
  222. package/src/forms/navigation-guard.tsx +98 -0
  223. package/src/forms/path-widget.module.css +41 -0
  224. package/src/forms/path-widget.test.tsx +217 -0
  225. package/src/forms/path-widget.tsx +183 -0
  226. package/src/forms/upload-executor.ts +192 -0
  227. package/src/lib/translate-validation-error.ts +56 -0
  228. package/src/modules/admin-account/commands.ts +13 -0
  229. package/src/modules/admin-account/components/change-password.tsx +46 -31
  230. package/src/modules/admin-account/components/container.tsx +83 -38
  231. package/src/modules/admin-account/components/preferences.module.css +60 -0
  232. package/src/modules/admin-account/components/preferences.tsx +203 -0
  233. package/src/modules/admin-account/components/update.tsx +53 -27
  234. package/src/modules/admin-account/index.ts +3 -0
  235. package/src/modules/admin-account/schemas.ts +13 -0
  236. package/src/modules/admin-account/service.ts +12 -0
  237. package/src/modules/admin-permissions/components/inspector.tsx +22 -14
  238. package/src/modules/admin-roles/components/create.tsx +51 -23
  239. package/src/modules/admin-roles/components/permissions.tsx +25 -21
  240. package/src/modules/admin-roles/components/update.tsx +37 -19
  241. package/src/modules/admin-users/components/create.tsx +63 -34
  242. package/src/modules/admin-users/components/roles.tsx +9 -8
  243. package/src/modules/admin-users/components/set-password.tsx +34 -28
  244. package/src/modules/admin-users/components/update.tsx +58 -36
  245. package/src/modules/admin-users/dto.ts +1 -0
  246. package/src/modules/admin-users/repository.ts +17 -0
  247. package/src/modules/admin-users/schemas.ts +12 -0
  248. package/src/modules/auth/components/sign-in-form.tsx +14 -8
  249. package/src/presentation/group.module.css +41 -0
  250. package/src/presentation/group.tsx +40 -0
  251. package/src/presentation/row.module.css +32 -0
  252. package/src/presentation/row.tsx +33 -0
  253. package/src/presentation/tabs.module.css +107 -0
  254. package/src/presentation/tabs.tsx +84 -0
  255. package/src/react.ts +84 -0
  256. package/src/services/admin-services-types.ts +18 -0
  257. package/src/widgets/diff-viewer/diff-modal.module.css +79 -0
  258. package/src/widgets/diff-viewer/diff-modal.tsx +186 -0
  259. package/src/widgets/status-badge/status-badge.module.css +31 -0
  260. package/src/widgets/status-badge/status-badge.tsx +71 -0
@@ -0,0 +1,36 @@
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
+ * Map a stable validation-error code (emitted by a `@byline/core/validation`
10
+ * schema) onto its translation. Returns the original input unchanged when
11
+ * the code is not in the map, so non-coded error messages (free-form
12
+ * Zod messages, server-supplied strings) pass through.
13
+ *
14
+ * Why a separate translator: `@byline/core` stays i18n-agnostic — schemas
15
+ * emit codes, not text — so it has no dependency on `@byline/i18n` or
16
+ * any locale data. This package owns the translation surface and keeps
17
+ * the mapping in one place, so callers across the admin shell don't
18
+ * each maintain their own code-to-key lookup.
19
+ *
20
+ * Adding a new code: extend the source schema in `@byline/core/validation`
21
+ * and add the matching key here.
22
+ */
23
+ import type { UseTranslationReturn } from '@byline/i18n/react';
24
+ type Translate = UseTranslationReturn['t'];
25
+ /**
26
+ * Translate a validation error code into the active locale's message.
27
+ *
28
+ * Pass the raw error string straight out of Zod (e.g. via
29
+ * `firstError(field.state.meta.errors)`). When the string matches a
30
+ * known code, the corresponding translation is returned; otherwise the
31
+ * input flows through unchanged.
32
+ *
33
+ * Designed for the `errorText={…}` slot on form inputs.
34
+ */
35
+ export declare function translateValidationError(t: Translate, message: string | undefined): string | undefined;
36
+ export {};
@@ -0,0 +1,11 @@
1
+ const VALIDATION_CODE_KEYS = {
2
+ 'password.tooShort': 'validation.password.tooShort',
3
+ 'password.tooLong': 'validation.password.tooLong',
4
+ 'password.complexity': 'validation.password.complexity'
5
+ };
6
+ function translateValidationError(t, message) {
7
+ if (null == message) return message;
8
+ const key = VALIDATION_CODE_KEYS[message];
9
+ return key ? t(key) : message;
10
+ }
11
+ export { translateValidationError };
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { type Command } from '../../lib/create-command.js';
9
9
  import type { AdminStore } from '../../store.js';
10
- import type { AccountResponse, ChangeAccountPasswordRequest, GetAccountRequest, UpdateAccountRequest } from './schemas.js';
10
+ import type { AccountResponse, ChangeAccountPasswordRequest, GetAccountRequest, SetPreferredLocaleRequest, UpdateAccountRequest } from './schemas.js';
11
11
  /**
12
12
  * Transport-agnostic commands for admin-account self-service.
13
13
  *
@@ -25,3 +25,4 @@ export interface AdminAccountCommandDeps {
25
25
  export declare const getAccountCommand: Command<GetAccountRequest, AccountResponse, AdminAccountCommandDeps>;
26
26
  export declare const updateAccountCommand: Command<UpdateAccountRequest, AccountResponse, AdminAccountCommandDeps>;
27
27
  export declare const changeAccountPasswordCommand: Command<ChangeAccountPasswordRequest, AccountResponse, AdminAccountCommandDeps>;
28
+ export declare const setPreferredLocaleCommand: Command<SetPreferredLocaleRequest, AccountResponse, AdminAccountCommandDeps>;
@@ -1,6 +1,6 @@
1
1
  import { createCommand } from "../../lib/create-command.js";
2
2
  import { adminUserResponseSchema } from "../admin-users/schemas.js";
3
- import { changeAccountPasswordRequestSchema, getAccountRequestSchema, updateAccountRequestSchema } from "./schemas.js";
3
+ import { changeAccountPasswordRequestSchema, getAccountRequestSchema, setPreferredLocaleRequestSchema, updateAccountRequestSchema } from "./schemas.js";
4
4
  import { AdminAccountService } from "./service.js";
5
5
  function serviceOf(deps) {
6
6
  return new AdminAccountService({
@@ -40,4 +40,15 @@ const changeAccountPasswordCommand = createCommand({
40
40
  },
41
41
  handler: ({ input, deps, actor })=>serviceOf(deps).changePassword(actor.id, input)
42
42
  });
43
- export { changeAccountPasswordCommand, getAccountCommand, updateAccountCommand };
43
+ const setPreferredLocaleCommand = createCommand({
44
+ method: 'setPreferredLocale',
45
+ auth: {
46
+ authenticated: true
47
+ },
48
+ schemas: {
49
+ input: setPreferredLocaleRequestSchema,
50
+ output: adminUserResponseSchema
51
+ },
52
+ handler: ({ input, deps, actor })=>serviceOf(deps).setPreferredLocale(actor.id, input.locale)
53
+ });
54
+ export { changeAccountPasswordCommand, getAccountCommand, setPreferredLocaleCommand, updateAccountCommand };
@@ -1,31 +1,36 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useState } from "react";
3
+ import { useMemo, useState } from "react";
4
4
  import { revalidateLogic, useForm } from "@tanstack/react-form-start";
5
5
  import { passwordSchema } from "@byline/core/validation";
6
+ import { useTranslation } from "@byline/i18n/react";
6
7
  import { Alert, Button, InputPassword, LoaderEllipsis } from "@byline/ui/react";
7
8
  import classnames from "classnames";
8
9
  import { z } from "zod";
10
+ import { translateValidationError } from "../../../lib/translate-validation-error.js";
9
11
  import { useBylineAdminServices } from "../../../services/admin-services-context.js";
10
12
  import change_password_module from "./change-password.module.js";
11
- const changePasswordFormSchema = z.object({
12
- currentPassword: z.string().min(1, {
13
- message: 'Please enter your current password'
14
- }),
15
- newPassword: passwordSchema,
16
- confirm: z.string({
17
- message: 'Please confirm the new password'
18
- })
19
- }).refine((v)=>v.newPassword === v.confirm, {
20
- message: 'New passwords do not match',
21
- path: [
22
- 'confirm'
23
- ]
24
- });
25
13
  function ChangeAccountPassword({ account, onClose, onSuccess }) {
26
14
  const { changeAccountPassword } = useBylineAdminServices();
15
+ const { t } = useTranslation('byline-admin');
27
16
  const [formError, setFormError] = useState(null);
28
17
  const [successMessage, setSuccessMessage] = useState(null);
18
+ const changePasswordFormSchema = useMemo(()=>z.object({
19
+ currentPassword: z.string().min(1, {
20
+ message: t('account.changePassword.errors.currentRequired')
21
+ }),
22
+ newPassword: passwordSchema,
23
+ confirm: z.string({
24
+ message: t('account.changePassword.errors.confirmRequired')
25
+ })
26
+ }).refine((v)=>v.newPassword === v.confirm, {
27
+ message: t('account.changePassword.errors.mismatch'),
28
+ path: [
29
+ 'confirm'
30
+ ]
31
+ }), [
32
+ t
33
+ ]);
29
34
  const form = useForm({
30
35
  defaultValues: {
31
36
  currentPassword: '',
@@ -50,7 +55,7 @@ function ChangeAccountPassword({ account, onClose, onSuccess }) {
50
55
  newPassword: value.newPassword
51
56
  }
52
57
  });
53
- setSuccessMessage('Password updated.');
58
+ setSuccessMessage(t('account.changePassword.feedback.updated'));
54
59
  form.reset({
55
60
  currentPassword: '',
56
61
  newPassword: '',
@@ -59,19 +64,23 @@ function ChangeAccountPassword({ account, onClose, onSuccess }) {
59
64
  onSuccess?.(updated);
60
65
  } catch (err) {
61
66
  const code = getErrorCode(err);
62
- if ('admin.account.invalidCurrentPassword' === code) return void form.setFieldMeta('currentPassword', (meta)=>({
63
- ...meta,
64
- errorMap: {
65
- ...meta.errorMap,
66
- onServer: 'Current password is incorrect.'
67
- },
68
- errors: [
69
- 'Current password is incorrect.'
70
- ]
71
- }));
72
- if ('admin.users.versionConflict' === code) return void setFormError('Your account has been modified elsewhere since you opened this form. Reload to refresh and try again.');
73
- if ('admin.account.notFound' === code) return void setFormError('Your admin account could not be found. Please sign in again.');
74
- setFormError('Could not change the password. Please try again.');
67
+ if ('admin.account.invalidCurrentPassword' === code) {
68
+ const message = t('account.changePassword.errors.currentIncorrect');
69
+ form.setFieldMeta('currentPassword', (meta)=>({
70
+ ...meta,
71
+ errorMap: {
72
+ ...meta.errorMap,
73
+ onServer: message
74
+ },
75
+ errors: [
76
+ message
77
+ ]
78
+ }));
79
+ return;
80
+ }
81
+ if ('admin.users.versionConflict' === code) return void setFormError(t('common.errors.versionConflict'));
82
+ if ('admin.account.notFound' === code) return void setFormError(t('common.errors.accountNotFound'));
83
+ setFormError(t('account.changePassword.errors.couldNotChange'));
75
84
  }
76
85
  }
77
86
  });
@@ -96,12 +105,12 @@ function ChangeAccountPassword({ account, onClose, onSuccess }) {
96
105
  }) : null,
97
106
  /*#__PURE__*/ jsx("p", {
98
107
  className: "muted",
99
- children: "Other active sessions will continue to work until their tokens expire. Sign out elsewhere if you suspect another device has been compromised."
108
+ children: t('account.changePassword.intro')
100
109
  }),
101
110
  /*#__PURE__*/ jsx(form.Field, {
102
111
  name: "currentPassword",
103
112
  children: (field)=>/*#__PURE__*/ jsx(InputPassword, {
104
- label: "Current password",
113
+ label: t('account.changePassword.fields.current'),
105
114
  id: "currentPassword",
106
115
  name: field.name,
107
116
  value: field.state.value,
@@ -116,14 +125,14 @@ function ChangeAccountPassword({ account, onClose, onSuccess }) {
116
125
  /*#__PURE__*/ jsx(form.Field, {
117
126
  name: "newPassword",
118
127
  children: (field)=>/*#__PURE__*/ jsx(InputPassword, {
119
- label: "New password",
128
+ label: t('account.changePassword.fields.new'),
120
129
  id: "newPassword",
121
130
  name: field.name,
122
131
  value: field.state.value,
123
132
  onBlur: field.handleBlur,
124
133
  onChange: (e)=>field.handleChange(e.currentTarget.value),
125
134
  error: field.state.meta.errors.length > 0,
126
- errorText: firstError(field.state.meta.errors),
135
+ errorText: translateValidationError(t, firstError(field.state.meta.errors)),
127
136
  autoComplete: "new-password",
128
137
  required: true
129
138
  })
@@ -131,7 +140,7 @@ function ChangeAccountPassword({ account, onClose, onSuccess }) {
131
140
  /*#__PURE__*/ jsx(form.Field, {
132
141
  name: "confirm",
133
142
  children: (field)=>/*#__PURE__*/ jsx(InputPassword, {
134
- label: "Confirm new password",
143
+ label: t('account.changePassword.fields.confirm'),
135
144
  id: "confirm",
136
145
  name: field.name,
137
146
  value: field.state.value,
@@ -152,7 +161,7 @@ function ChangeAccountPassword({ account, onClose, onSuccess }) {
152
161
  size: "sm",
153
162
  onClick: onClose,
154
163
  className: classnames('byline-account-change-password-action', change_password_module.action),
155
- children: successMessage ? 'Close' : 'Cancel'
164
+ children: successMessage ? t('common.actions.close') : t('common.actions.cancel')
156
165
  }),
157
166
  /*#__PURE__*/ jsx(form.Subscribe, {
158
167
  selector: (state)=>({
@@ -168,7 +177,7 @@ function ChangeAccountPassword({ account, onClose, onSuccess }) {
168
177
  className: classnames('byline-account-change-password-action', change_password_module.action),
169
178
  children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
170
179
  size: 42
171
- }) : 'Save'
180
+ }) : t('common.actions.save')
172
181
  })
173
182
  })
174
183
  ]