@focus-reactive/payload-plugin-translator 0.7.1 → 0.8.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 (141) hide show
  1. package/README.md +18 -3
  2. package/dist/client/entities/translation/api/mutations/useDismissStaleness.d.ts +12 -0
  3. package/dist/client/entities/translation/api/mutations/useDismissStaleness.js +40 -0
  4. package/dist/client/entities/translation/api/mutations/useQueueDocumentTranslation.js +6 -0
  5. package/dist/client/entities/translation/api/mutations/useRunDocumentTranslation.js +6 -0
  6. package/dist/client/entities/translation/api/queries/useDocumentStaleness.d.ts +17 -0
  7. package/dist/client/entities/translation/api/queries/useDocumentStaleness.js +35 -0
  8. package/dist/client/entities/translation/api/queries/useDocumentTranslation.js +23 -1
  9. package/dist/client/entities/translation/index.d.ts +12 -5
  10. package/dist/client/entities/translation/index.js +10 -5
  11. package/dist/client/entities/translation/model/panelStatus.d.ts +60 -0
  12. package/dist/client/entities/translation/model/panelStatus.js +101 -0
  13. package/dist/client/entities/translation/model/statusRows.d.ts +42 -0
  14. package/dist/client/entities/translation/model/statusRows.js +79 -0
  15. package/dist/client/entities/translation/model/types.d.ts +11 -0
  16. package/dist/client/entities/translation/model/types.js +1 -1
  17. package/dist/client/entities/translation/ui/ActionButton/ActionButton.d.ts +14 -0
  18. package/dist/client/entities/translation/ui/ActionButton/ActionButton.js +28 -0
  19. package/dist/client/entities/translation/ui/ActionButton/index.d.ts +1 -0
  20. package/dist/client/entities/translation/ui/ActionButton/index.js +3 -0
  21. package/dist/client/entities/translation/ui/ActionButton/styles.module.scss +11 -0
  22. package/dist/client/entities/translation/ui/PanelStatusMarker/PanelStatusMarker.d.ts +12 -0
  23. package/dist/client/entities/translation/ui/PanelStatusMarker/PanelStatusMarker.js +26 -0
  24. package/dist/client/entities/translation/ui/PanelStatusMarker/index.d.ts +1 -0
  25. package/dist/client/entities/translation/ui/PanelStatusMarker/index.js +3 -0
  26. package/dist/client/entities/translation/ui/PanelStatusMarker/styles.module.scss +12 -0
  27. package/dist/client/entities/translation/ui/TranslationDirection/styles.module.scss +2 -2
  28. package/dist/client/entities/translation/ui/TranslationStatusList/StatusBadge.d.ts +10 -0
  29. package/dist/client/entities/translation/ui/TranslationStatusList/StatusBadge.js +27 -0
  30. package/dist/client/entities/translation/ui/TranslationStatusList/TranslationStatusList.d.ts +14 -0
  31. package/dist/client/entities/translation/ui/TranslationStatusList/TranslationStatusList.js +194 -0
  32. package/dist/client/entities/translation/ui/TranslationStatusList/index.d.ts +1 -0
  33. package/dist/client/entities/translation/ui/TranslationStatusList/index.js +3 -0
  34. package/dist/client/entities/translation/ui/TranslationStatusList/styles.module.scss +72 -0
  35. package/dist/client/features/collection-translation-form/ui/CollectionTranslationForm.js +17 -21
  36. package/dist/client/features/collection-translation-form/ui/styles.module.scss +14 -14
  37. package/dist/client/features/collection-translation-popup/ui/CollectionTranslationPopup.d.ts +4 -2
  38. package/dist/client/features/collection-translation-popup/ui/CollectionTranslationPopup.js +9 -9
  39. package/dist/client/features/collection-translation-popup/ui/styles.module.scss +5 -3
  40. package/dist/client/features/collection-translation-progress/ui/CollectionTranslationProgress.d.ts +5 -1
  41. package/dist/client/features/collection-translation-progress/ui/CollectionTranslationProgress.js +100 -93
  42. package/dist/client/features/collection-translation-progress/ui/styles.module.scss +52 -3
  43. package/dist/client/features/open-document-translation-popup/ui/OpenDocumentTranslationPopup.d.ts +4 -1
  44. package/dist/client/features/open-document-translation-popup/ui/OpenDocumentTranslationPopup.js +16 -5
  45. package/dist/client/features/open-document-translation-popup/ui/styles.module.scss +5 -3
  46. package/dist/client/features/translate-document-form/ui/DocumentTranslationForm.js +5 -2
  47. package/dist/client/features/translate-document-form/ui/styles.module.scss +8 -2
  48. package/dist/client/shared/lib/assets/icons/AlertTriangleIcon.d.ts +1 -0
  49. package/dist/client/shared/lib/assets/icons/AlertTriangleIcon.js +14 -0
  50. package/dist/client/shared/lib/assets/icons/CheckIcon.d.ts +1 -0
  51. package/dist/client/shared/lib/assets/icons/CheckIcon.js +17 -0
  52. package/dist/client/shared/lib/assets/icons/CloseIcon.d.ts +1 -0
  53. package/dist/client/shared/lib/assets/icons/CloseIcon.js +16 -0
  54. package/dist/client/shared/ui/Button/Button.js +2 -1
  55. package/dist/client/shared/ui/ColorIndicator/ColorIndicator.d.ts +1 -1
  56. package/dist/client/shared/ui/ColorIndicator/styles.module.scss +4 -0
  57. package/dist/client/shared/ui/Label/Label.d.ts +2 -0
  58. package/dist/client/shared/ui/Label/Label.js +3 -2
  59. package/dist/client/shared/ui/Label/styles.module.scss +11 -0
  60. package/dist/client/shared/ui/Loading/Loading.d.ts +6 -2
  61. package/dist/client/shared/ui/Loading/Loading.js +4 -2
  62. package/dist/client/shared/ui/Loading/barCount.d.ts +3 -0
  63. package/dist/client/shared/ui/Loading/barCount.js +11 -0
  64. package/dist/client/shared/ui/Loading/styles.module.scss +20 -27
  65. package/dist/client/shared/ui/Popup/Popup.js +3 -0
  66. package/dist/client/shared/ui/Select/Select.js +1 -1
  67. package/dist/client/shared/ui/form/FormSelect/FormSelect.js +1 -0
  68. package/dist/client/widgets/bulk-translation-dashboard/ui/BulkTranslationDashboard.js +37 -17
  69. package/dist/client/widgets/bulk-translation-dashboard/ui/styles.module.scss +27 -0
  70. package/dist/client/widgets/translate-document/ui/TranslateDocument.js +53 -27
  71. package/dist/client/widgets/translate-document/ui/styles.module.scss +27 -0
  72. package/dist/composition/levels/useDocTranslationApi.d.ts +3 -2
  73. package/dist/composition/levels/useDocTranslationApi.js +6 -3
  74. package/dist/core/field-traversal/types.d.ts +4 -2
  75. package/dist/core/provenance/ProvenanceStore.interface.d.ts +18 -0
  76. package/dist/core/provenance/index.d.ts +1 -0
  77. package/dist/core/provenance/index.js +1 -1
  78. package/dist/core/provenance/staleness.d.ts +19 -0
  79. package/dist/core/provenance/staleness.js +21 -0
  80. package/dist/core/translation-pipeline/stages/data-reconciler/DataReconciler.js +33 -10
  81. package/dist/plugin.js +2 -1
  82. package/dist/server/features/_lib/sourceDocument.d.ts +9 -0
  83. package/dist/server/features/_lib/sourceDocument.js +16 -0
  84. package/dist/server/features/createTranslationRoutes.d.ts +12 -4
  85. package/dist/server/features/createTranslationRoutes.js +15 -5
  86. package/dist/server/features/get-document-status/model.js +7 -2
  87. package/dist/server/features/staleness/dismissStaleness.handler.d.ts +8 -0
  88. package/dist/server/features/staleness/dismissStaleness.handler.js +27 -0
  89. package/dist/server/features/staleness/getDocumentStaleness.handler.d.ts +12 -0
  90. package/dist/server/features/staleness/getDocumentStaleness.handler.js +43 -0
  91. package/dist/server/features/staleness/index.d.ts +2 -0
  92. package/dist/server/features/staleness/index.js +3 -0
  93. package/dist/server/features/staleness/model.d.ts +52 -0
  94. package/dist/server/features/staleness/model.js +17 -0
  95. package/dist/server/features/staleness/route.d.ts +7 -0
  96. package/dist/server/features/staleness/route.js +21 -0
  97. package/dist/server/features/staleness/service.d.ts +15 -0
  98. package/dist/server/features/staleness/service.js +78 -0
  99. package/dist/server/features/translate-document/handler.js +22 -8
  100. package/dist/server/modules/provenance/PayloadProvenanceStore.d.ts +2 -0
  101. package/dist/server/modules/provenance/PayloadProvenanceStore.js +37 -14
  102. package/dist/server/modules/translation-levels/PluginConfigBuilder.d.ts +3 -0
  103. package/dist/server/modules/translation-levels/PluginConfigBuilder.js +2 -0
  104. package/dist/server/modules/translation-levels/types.d.ts +3 -0
  105. package/dist/server/shared/http/index.d.ts +1 -0
  106. package/dist/server/shared/http/index.js +1 -0
  107. package/dist/server/shared/http/toClientErrorMessage.d.ts +15 -0
  108. package/dist/server/shared/http/toClientErrorMessage.js +26 -0
  109. package/dist/server/shared/index.d.ts +1 -1
  110. package/dist/server/shared/index.js +1 -1
  111. package/package.json +1 -1
  112. package/dist/client/entities/translation/ui/CompletedTranslationStatus/CompletedTranslationStatus.d.ts +0 -7
  113. package/dist/client/entities/translation/ui/CompletedTranslationStatus/CompletedTranslationStatus.js +0 -45
  114. package/dist/client/entities/translation/ui/CompletedTranslationStatus/index.d.ts +0 -1
  115. package/dist/client/entities/translation/ui/CompletedTranslationStatus/index.js +0 -3
  116. package/dist/client/entities/translation/ui/CompletedTranslationStatus/styles.module.scss +0 -3
  117. package/dist/client/entities/translation/ui/FailedTranslationStatus/FailedTranslationStatus.d.ts +0 -9
  118. package/dist/client/entities/translation/ui/FailedTranslationStatus/FailedTranslationStatus.js +0 -54
  119. package/dist/client/entities/translation/ui/FailedTranslationStatus/index.d.ts +0 -1
  120. package/dist/client/entities/translation/ui/FailedTranslationStatus/index.js +0 -3
  121. package/dist/client/entities/translation/ui/FailedTranslationStatus/styles.module.scss +0 -3
  122. package/dist/client/entities/translation/ui/PendingTranslationStatus/PendingTranslationStatus.d.ts +0 -11
  123. package/dist/client/entities/translation/ui/PendingTranslationStatus/PendingTranslationStatus.js +0 -83
  124. package/dist/client/entities/translation/ui/PendingTranslationStatus/index.d.ts +0 -1
  125. package/dist/client/entities/translation/ui/PendingTranslationStatus/index.js +0 -3
  126. package/dist/client/entities/translation/ui/RunningTranslationStatus/RunningTranslationStatus.d.ts +0 -10
  127. package/dist/client/entities/translation/ui/RunningTranslationStatus/RunningTranslationStatus.js +0 -66
  128. package/dist/client/entities/translation/ui/RunningTranslationStatus/index.d.ts +0 -1
  129. package/dist/client/entities/translation/ui/RunningTranslationStatus/index.js +0 -3
  130. package/dist/client/features/document-translation-progress-failed/index.d.ts +0 -1
  131. package/dist/client/features/document-translation-progress-failed/index.js +0 -3
  132. package/dist/client/features/document-translation-progress-failed/ui/DocumentTranslationProgressFailed.d.ts +0 -6
  133. package/dist/client/features/document-translation-progress-failed/ui/DocumentTranslationProgressFailed.js +0 -28
  134. package/dist/client/features/document-translation-progress-pending/index.d.ts +0 -1
  135. package/dist/client/features/document-translation-progress-pending/index.js +0 -3
  136. package/dist/client/features/document-translation-progress-pending/ui/DocumentTranslationProgressPending.d.ts +0 -6
  137. package/dist/client/features/document-translation-progress-pending/ui/DocumentTranslationProgressPending.js +0 -44
  138. package/dist/client/features/document-translation-progress-running/index.d.ts +0 -1
  139. package/dist/client/features/document-translation-progress-running/index.js +0 -3
  140. package/dist/client/features/document-translation-progress-running/ui/DocumentTranslationProgressRunning.d.ts +0 -6
  141. package/dist/client/features/document-translation-progress-running/ui/DocumentTranslationProgressRunning.js +0 -28
@@ -0,0 +1,26 @@
1
+ /** Shown to the browser instead of a raw provider/runtime error outside development. */ export const GENERIC_TRANSLATION_ERROR = "Translation failed. See the server logs for details.";
2
+ // Only these environments get the raw message as a debug aid. Anything else — production, an unset
3
+ // or misconfigured NODE_ENV — is treated as "not debug", so the default is the safe, generic text.
4
+ const DEBUG_ENVS = new Set([
5
+ "development",
6
+ "test"
7
+ ]);
8
+ /**
9
+ * Collapse a server-side error message to something safe to send to the browser.
10
+ *
11
+ * Provider/runtime errors (e.g. `401 Incorrect API key provided: sk-proj-…`) leak implementation
12
+ * detail — and sometimes secrets — so the client must not see them in production. The full error
13
+ * still lives in the job record and server logs for debugging; only the client-facing copy is
14
+ * collapsed. Fail-safe: the raw message passes through solely in `development`/`test`; every other
15
+ * environment (including an unset `NODE_ENV`) returns {@link GENERIC_TRANSLATION_ERROR}.
16
+ *
17
+ * @param message - The raw server-side error message, if any.
18
+ * @returns The raw message in a debug environment, otherwise the generic text.
19
+ */ export function toClientErrorMessage(message) {
20
+ if (DEBUG_ENVS.has(process.env.NODE_ENV ?? "")) {
21
+ return message?.trim() || GENERIC_TRANSLATION_ERROR;
22
+ }
23
+ return GENERIC_TRANSLATION_ERROR;
24
+ }
25
+
26
+ //# sourceMappingURL=toClientErrorMessage.js.map
@@ -1,4 +1,4 @@
1
- export { ServerResponse, withErrorHandler, withAccessCheck } from "./http";
1
+ export { ServerResponse, withErrorHandler, withAccessCheck, toClientErrorMessage, GENERIC_TRANSLATION_ERROR, } from "./http";
2
2
  export { AnyAccessGuard } from "./access";
3
3
  export type { AccessGuard, AccessGuardRequest, Handler } from "./access";
4
4
  export { isEmpty, isObject, normalizePath, pipe, getByPath, setByPath, filterLocalizedFields, } from "./utils";
@@ -1,5 +1,5 @@
1
1
  // HTTP utilities
2
- export { ServerResponse, withErrorHandler, withAccessCheck } from "./http";
2
+ export { ServerResponse, withErrorHandler, withAccessCheck, toClientErrorMessage, GENERIC_TRANSLATION_ERROR } from "./http";
3
3
  // Access control
4
4
  export { AnyAccessGuard } from "./access";
5
5
  // General utilities
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@focus-reactive/payload-plugin-translator",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Translation plugin for Payload CMS 3.x. Automatically translate your localized content using any translation provider.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,7 +0,0 @@
1
- type CompletedTranslationStatusProps = {
2
- completed_at: string;
3
- sourceLocale: string;
4
- targetLocale: string;
5
- };
6
- export declare function CompletedTranslationStatus({ completed_at, sourceLocale, targetLocale, }: CompletedTranslationStatusProps): import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,45 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { LanguageTranslateIcon } from "../../../../shared/lib/assets/icons/LanguageTranslateIcon";
3
- import Button from "../../../../shared/ui/Button";
4
- import StatusIndicator from "../../../../shared/ui/StatusIndicator";
5
- import Tooltip from "../../../../shared/ui/Tooltip";
6
- import { TranslationDirection } from "../TranslationDirection";
7
- import styles from "./styles.module.scss";
8
- export function CompletedTranslationStatus({ completed_at, sourceLocale, targetLocale }) {
9
- return /*#__PURE__*/ _jsxs(StatusIndicator, {
10
- className: styles.indicator,
11
- $color: "green",
12
- title: "Completed",
13
- children: [
14
- /*#__PURE__*/ _jsx(Tooltip, {
15
- sideOffset: 12,
16
- side: "bottom",
17
- content: /*#__PURE__*/ _jsxs("time", {
18
- dateTime: completed_at,
19
- children: [
20
- "Completed at:",
21
- " ",
22
- new Date(completed_at).toLocaleString(undefined, {
23
- year: "numeric",
24
- month: "short",
25
- day: "numeric",
26
- hour: "2-digit",
27
- minute: "2-digit"
28
- })
29
- ]
30
- }),
31
- children: /*#__PURE__*/ _jsx(Button, {
32
- type: "button",
33
- $variant: "unstyled",
34
- children: /*#__PURE__*/ _jsx(LanguageTranslateIcon, {})
35
- })
36
- }),
37
- /*#__PURE__*/ _jsx(TranslationDirection, {
38
- sourceLocale: sourceLocale,
39
- targetLocale: targetLocale
40
- })
41
- ]
42
- });
43
- }
44
-
45
- //# sourceMappingURL=CompletedTranslationStatus.js.map
@@ -1 +0,0 @@
1
- export { CompletedTranslationStatus } from "./CompletedTranslationStatus";
@@ -1,3 +0,0 @@
1
- export { CompletedTranslationStatus } from "./CompletedTranslationStatus";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- .indicator {
2
- font-size: 1.3rem;
3
- }
@@ -1,9 +0,0 @@
1
- type FailedTranslationStatusProps = {
2
- message: string;
3
- sourceLocale: string;
4
- targetLocale: string;
5
- isLoading?: boolean;
6
- onRetry: () => void;
7
- };
8
- export declare function FailedTranslationStatus({ onRetry, message, isLoading, sourceLocale, targetLocale, }: FailedTranslationStatusProps): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,54 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { LanguageTranslateIcon } from "../../../../shared/lib/assets/icons/LanguageTranslateIcon";
3
- import { ReloadIcon } from "../../../../shared/lib/assets/icons/ReloadIcon";
4
- import Button from "../../../../shared/ui/Button";
5
- import Divider from "../../../../shared/ui/Divider";
6
- import StatusIndicator from "../../../../shared/ui/StatusIndicator";
7
- import Tooltip from "../../../../shared/ui/Tooltip";
8
- import { TranslationDirection } from "../TranslationDirection";
9
- import styles from "./styles.module.scss";
10
- export function FailedTranslationStatus({ onRetry, message, isLoading, sourceLocale, targetLocale }) {
11
- return /*#__PURE__*/ _jsxs(StatusIndicator, {
12
- $color: "red",
13
- title: "Failed",
14
- children: [
15
- /*#__PURE__*/ _jsx(Tooltip, {
16
- sideOffset: 12,
17
- side: "bottom",
18
- content: message,
19
- children: /*#__PURE__*/ _jsx(Button, {
20
- type: "button",
21
- $variant: "unstyled",
22
- children: /*#__PURE__*/ _jsx(LanguageTranslateIcon, {})
23
- })
24
- }),
25
- /*#__PURE__*/ _jsx(TranslationDirection, {
26
- sourceLocale: sourceLocale,
27
- targetLocale: targetLocale
28
- }),
29
- /*#__PURE__*/ _jsx(Divider, {
30
- className: styles.divider,
31
- $orientation: "vertical",
32
- $size: "sm"
33
- }),
34
- /*#__PURE__*/ _jsx(Tooltip, {
35
- side: "bottom",
36
- sideOffset: 12,
37
- content: "Retry",
38
- children: /*#__PURE__*/ _jsx(Button, {
39
- $variant: "light",
40
- $size: "sm",
41
- $isIconButton: true,
42
- "aria-label": "Retry failed translation",
43
- type: "button",
44
- onClick: onRetry,
45
- disabled: isLoading,
46
- $isLoading: isLoading,
47
- children: /*#__PURE__*/ _jsx(ReloadIcon, {})
48
- })
49
- })
50
- ]
51
- });
52
- }
53
-
54
- //# sourceMappingURL=FailedTranslationStatus.js.map
@@ -1 +0,0 @@
1
- export { FailedTranslationStatus } from "./FailedTranslationStatus";
@@ -1,3 +0,0 @@
1
- export { FailedTranslationStatus } from "./FailedTranslationStatus";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- .indicator {
2
- font-size: 1.3rem;
3
- }
@@ -1,11 +0,0 @@
1
- type TranslationStatusProps = {
2
- onCancel: () => void;
3
- onRun: () => void;
4
- isLoading?: boolean;
5
- disabled?: boolean;
6
- sourceLocale: string;
7
- targetLocale: string;
8
- createdAt: string;
9
- };
10
- export declare function PendingTranslationStatus({ onCancel, onRun, isLoading, disabled, sourceLocale, targetLocale, createdAt, }: TranslationStatusProps): import("react/jsx-runtime").JSX.Element;
11
- export {};
@@ -1,83 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { TrashIcon } from "@payloadcms/ui/icons/Trash";
3
- import { LanguageTranslateIcon } from "../../../../shared/lib/assets/icons/LanguageTranslateIcon";
4
- import { ReloadIcon } from "../../../../shared/lib/assets/icons/ReloadIcon";
5
- import Button from "../../../../shared/ui/Button";
6
- import Divider from "../../../../shared/ui/Divider";
7
- import StatusIndicator from "../../../../shared/ui/StatusIndicator";
8
- import Tooltip from "../../../../shared/ui/Tooltip";
9
- import { TranslationDirection } from "../TranslationDirection";
10
- export function PendingTranslationStatus({ onCancel, onRun, isLoading, disabled, sourceLocale, targetLocale, createdAt }) {
11
- return /*#__PURE__*/ _jsxs(StatusIndicator, {
12
- $color: "gray",
13
- $animated: true,
14
- title: "Pending",
15
- children: [
16
- /*#__PURE__*/ _jsx(Tooltip, {
17
- side: "bottom",
18
- sideOffset: 12,
19
- content: /*#__PURE__*/ _jsxs("time", {
20
- dateTime: createdAt,
21
- children: [
22
- "Created at:",
23
- " ",
24
- new Date(createdAt).toLocaleString(undefined, {
25
- year: "numeric",
26
- month: "short",
27
- day: "numeric",
28
- hour: "2-digit",
29
- minute: "2-digit"
30
- })
31
- ]
32
- }),
33
- children: /*#__PURE__*/ _jsx(Button, {
34
- type: "button",
35
- $variant: "unstyled",
36
- children: /*#__PURE__*/ _jsx(LanguageTranslateIcon, {})
37
- })
38
- }),
39
- /*#__PURE__*/ _jsx(TranslationDirection, {
40
- sourceLocale: sourceLocale,
41
- targetLocale: targetLocale
42
- }),
43
- /*#__PURE__*/ _jsx(Divider, {
44
- $size: "sm",
45
- $orientation: "vertical"
46
- }),
47
- /*#__PURE__*/ _jsx(Tooltip, {
48
- sideOffset: 12,
49
- side: "bottom",
50
- content: "Cancel",
51
- children: /*#__PURE__*/ _jsx(Button, {
52
- $variant: "light",
53
- $size: "sm",
54
- $isIconButton: true,
55
- "aria-label": "Cancel",
56
- type: "button",
57
- onClick: onCancel,
58
- disabled: isLoading || disabled,
59
- $isLoading: isLoading,
60
- children: /*#__PURE__*/ _jsx(TrashIcon, {})
61
- })
62
- }),
63
- /*#__PURE__*/ _jsx(Tooltip, {
64
- sideOffset: 12,
65
- side: "bottom",
66
- content: "Run queued translation",
67
- children: /*#__PURE__*/ _jsx(Button, {
68
- $variant: "light",
69
- $size: "sm",
70
- $isIconButton: true,
71
- "aria-label": "Run queued translation",
72
- type: "button",
73
- onClick: onRun,
74
- disabled: isLoading || disabled,
75
- $isLoading: isLoading,
76
- children: /*#__PURE__*/ _jsx(ReloadIcon, {})
77
- })
78
- })
79
- ]
80
- });
81
- }
82
-
83
- //# sourceMappingURL=PendingTranslationStatus.js.map
@@ -1 +0,0 @@
1
- export { PendingTranslationStatus } from "./PendingTranslationStatus";
@@ -1,3 +0,0 @@
1
- export { PendingTranslationStatus } from "./PendingTranslationStatus";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,10 +0,0 @@
1
- type TranslationStatusProps = {
2
- onCancel: () => void;
3
- isLoading?: boolean;
4
- disabled?: boolean;
5
- sourceLocale: string;
6
- targetLocale: string;
7
- createdAt: string;
8
- };
9
- export declare function RunningTranslationStatus({ onCancel, isLoading, disabled, sourceLocale, targetLocale, createdAt, }: TranslationStatusProps): import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,66 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { TrashIcon } from "@payloadcms/ui/icons/Trash";
3
- import { LanguageTranslateIcon } from "../../../../shared/lib/assets/icons/LanguageTranslateIcon";
4
- import Button from "../../../../shared/ui/Button";
5
- import Divider from "../../../../shared/ui/Divider";
6
- import StatusIndicator from "../../../../shared/ui/StatusIndicator";
7
- import Tooltip from "../../../../shared/ui/Tooltip";
8
- import { TranslationDirection } from "../TranslationDirection";
9
- export function RunningTranslationStatus({ onCancel, isLoading, disabled, sourceLocale, targetLocale, createdAt }) {
10
- return /*#__PURE__*/ _jsxs(StatusIndicator, {
11
- $animated: true,
12
- $color: "blue",
13
- title: "In Progress",
14
- children: [
15
- /*#__PURE__*/ _jsx(Tooltip, {
16
- side: "bottom",
17
- sideOffset: 12,
18
- content: /*#__PURE__*/ _jsxs("time", {
19
- dateTime: createdAt,
20
- children: [
21
- "Created at:",
22
- " ",
23
- new Date(createdAt).toLocaleString(undefined, {
24
- year: "numeric",
25
- month: "short",
26
- day: "numeric",
27
- hour: "2-digit",
28
- minute: "2-digit"
29
- })
30
- ]
31
- }),
32
- children: /*#__PURE__*/ _jsx(Button, {
33
- type: "button",
34
- $variant: "unstyled",
35
- children: /*#__PURE__*/ _jsx(LanguageTranslateIcon, {})
36
- })
37
- }),
38
- /*#__PURE__*/ _jsx(TranslationDirection, {
39
- sourceLocale: sourceLocale,
40
- targetLocale: targetLocale
41
- }),
42
- /*#__PURE__*/ _jsx(Divider, {
43
- $size: "sm",
44
- $orientation: "vertical"
45
- }),
46
- /*#__PURE__*/ _jsx(Tooltip, {
47
- sideOffset: 12,
48
- side: "bottom",
49
- content: "Cancel",
50
- children: /*#__PURE__*/ _jsx(Button, {
51
- $variant: "light",
52
- $size: "sm",
53
- $isIconButton: true,
54
- "aria-label": "Cancel",
55
- type: "button",
56
- onClick: onCancel,
57
- disabled: isLoading || disabled,
58
- $isLoading: isLoading,
59
- children: /*#__PURE__*/ _jsx(TrashIcon, {})
60
- })
61
- })
62
- ]
63
- });
64
- }
65
-
66
- //# sourceMappingURL=RunningTranslationStatus.js.map
@@ -1 +0,0 @@
1
- export { RunningTranslationStatus } from "./RunningTranslationStatus";
@@ -1,3 +0,0 @@
1
- export { RunningTranslationStatus } from "./RunningTranslationStatus";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- export { DocumentTranslationProgressFailed } from "./ui/DocumentTranslationProgressFailed";
@@ -1,3 +0,0 @@
1
- export { DocumentTranslationProgressFailed } from "./ui/DocumentTranslationProgressFailed";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- import type { DocumentTranslationFailed } from "../../../entities/translation";
2
- type DocumentTranslationProgressFailedProps = {
3
- data: DocumentTranslationFailed;
4
- };
5
- export declare function DocumentTranslationProgressFailed({ data, }: DocumentTranslationProgressFailedProps): import("react/jsx-runtime").JSX.Element;
6
- export {};
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { toast } from "@payloadcms/ui";
3
- import { FailedTranslationStatus, TranslationsApi } from "../../../entities/translation";
4
- export function DocumentTranslationProgressFailed({ data }) {
5
- const runQueuedTranslationApi = TranslationsApi.useRunDocumentTranslation();
6
- const handleRunDocumentTranslation = async ()=>{
7
- try {
8
- await runQueuedTranslationApi.mutateAsync({
9
- id: data.id
10
- });
11
- } catch (e) {
12
- if (e instanceof Error) {
13
- toast.error(e.message);
14
- } else {
15
- toast.error("Error running document translation");
16
- }
17
- }
18
- };
19
- return /*#__PURE__*/ _jsx(FailedTranslationStatus, {
20
- onRetry: handleRunDocumentTranslation,
21
- isLoading: runQueuedTranslationApi.isPending,
22
- sourceLocale: data.input.source_lng,
23
- targetLocale: data.input.target_lng,
24
- message: data.error.message
25
- });
26
- }
27
-
28
- //# sourceMappingURL=DocumentTranslationProgressFailed.js.map
@@ -1 +0,0 @@
1
- export { DocumentTranslationProgressPending } from "./ui/DocumentTranslationProgressPending";
@@ -1,3 +0,0 @@
1
- export { DocumentTranslationProgressPending } from "./ui/DocumentTranslationProgressPending";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- import type { DocumentTranslationPending } from "../../../entities/translation";
2
- type DocumentTranslationProgressPendingProps = {
3
- data: DocumentTranslationPending;
4
- };
5
- export declare function DocumentTranslationProgressPending({ data, }: DocumentTranslationProgressPendingProps): import("react/jsx-runtime").JSX.Element;
6
- export {};
@@ -1,44 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { toast } from "@payloadcms/ui";
3
- import { TranslationsApi } from "../../../entities/translation";
4
- import { PendingTranslationStatus } from "../../../entities/translation";
5
- export function DocumentTranslationProgressPending({ data }) {
6
- const cancelDocumentTranslationApi = TranslationsApi.useCancelDocumentTranslation();
7
- const runQueuedTranslationApi = TranslationsApi.useRunDocumentTranslation();
8
- const handleCancelDocumentTranslation = async ()=>{
9
- try {
10
- await cancelDocumentTranslationApi.mutateAsync({
11
- id: data.id
12
- });
13
- } catch (e) {
14
- if (e instanceof Error) {
15
- toast.error(e.message);
16
- } else {
17
- toast.error("Error canceling document translation");
18
- }
19
- }
20
- };
21
- const handleRunDocumentTranslation = async ()=>{
22
- try {
23
- await runQueuedTranslationApi.mutateAsync({
24
- id: data.id
25
- });
26
- } catch (e) {
27
- if (e instanceof Error) {
28
- toast.error(e.message);
29
- } else {
30
- toast.error("Error running document translation");
31
- }
32
- }
33
- };
34
- return /*#__PURE__*/ _jsx(PendingTranslationStatus, {
35
- onRun: handleRunDocumentTranslation,
36
- createdAt: data.created_at,
37
- sourceLocale: data.input.source_lng,
38
- targetLocale: data.input.target_lng,
39
- isLoading: cancelDocumentTranslationApi.isPending || runQueuedTranslationApi.isPending,
40
- onCancel: handleCancelDocumentTranslation
41
- });
42
- }
43
-
44
- //# sourceMappingURL=DocumentTranslationProgressPending.js.map
@@ -1 +0,0 @@
1
- export { DocumentTranslationProgressRunning } from "./ui/DocumentTranslationProgressRunning";
@@ -1,3 +0,0 @@
1
- export { DocumentTranslationProgressRunning } from "./ui/DocumentTranslationProgressRunning";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- import type { DocumentTranslationRunning } from "../../../entities/translation";
2
- type DocumentTranslationProgressRunningProps = {
3
- data: DocumentTranslationRunning;
4
- };
5
- export declare function DocumentTranslationProgressRunning({ data, }: DocumentTranslationProgressRunningProps): import("react/jsx-runtime").JSX.Element;
6
- export {};
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { toast } from "@payloadcms/ui";
3
- import { RunningTranslationStatus, TranslationsApi } from "../../../entities/translation";
4
- export function DocumentTranslationProgressRunning({ data }) {
5
- const cancelDocumentTranslationApi = TranslationsApi.useCancelDocumentTranslation();
6
- const handleCancelDocumentTranslation = async ()=>{
7
- try {
8
- await cancelDocumentTranslationApi.mutateAsync({
9
- id: data.id
10
- });
11
- } catch (e) {
12
- if (e instanceof Error) {
13
- toast.error(e.message);
14
- } else {
15
- toast.error("Error canceling document translation");
16
- }
17
- }
18
- };
19
- return /*#__PURE__*/ _jsx(RunningTranslationStatus, {
20
- createdAt: data.created_at,
21
- sourceLocale: data.input.source_lng,
22
- targetLocale: data.input.target_lng,
23
- isLoading: cancelDocumentTranslationApi.isPending,
24
- onCancel: handleCancelDocumentTranslation
25
- });
26
- }
27
-
28
- //# sourceMappingURL=DocumentTranslationProgressRunning.js.map