@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
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
5
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) Infonomic Company Limited
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useState } from 'react'
|
|
12
|
+
|
|
13
|
+
import { useTranslation } from '@byline/i18n/react'
|
|
14
|
+
import {
|
|
15
|
+
Button,
|
|
16
|
+
Checkbox,
|
|
17
|
+
CloseIcon,
|
|
18
|
+
DeleteIcon,
|
|
19
|
+
Dropdown as DropdownComponent,
|
|
20
|
+
EllipsisIcon,
|
|
21
|
+
IconButton,
|
|
22
|
+
Modal,
|
|
23
|
+
Select,
|
|
24
|
+
} from '@byline/ui/react'
|
|
25
|
+
import cx from 'classnames'
|
|
26
|
+
|
|
27
|
+
import styles from './document-actions.module.css'
|
|
28
|
+
import type { PublishedVersionInfo } from './form-renderer'
|
|
29
|
+
|
|
30
|
+
const DUPLICATE_TITLE_SUFFIX = ' (copy)'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Shape of a content-locale option as consumed by the Copy-to-Locale
|
|
34
|
+
* modal. Matches the host adapter's `ContentLocaleOption`; declared
|
|
35
|
+
* locally so this package does not take a dependency on host code.
|
|
36
|
+
*/
|
|
37
|
+
export interface DocumentActionsLocaleOption {
|
|
38
|
+
code: string
|
|
39
|
+
label: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function DocumentActions({
|
|
43
|
+
publishedVersion,
|
|
44
|
+
onUnpublish,
|
|
45
|
+
onDelete,
|
|
46
|
+
onDuplicate,
|
|
47
|
+
sourceTitle,
|
|
48
|
+
onCopyToLocale,
|
|
49
|
+
sourceLocale,
|
|
50
|
+
contentLocales,
|
|
51
|
+
}: {
|
|
52
|
+
publishedVersion?: PublishedVersionInfo | null
|
|
53
|
+
onUnpublish?: () => Promise<void>
|
|
54
|
+
onDelete?: () => Promise<void>
|
|
55
|
+
/**
|
|
56
|
+
* Called when the editor confirms the duplicate modal. The parent runs
|
|
57
|
+
* the server fn, surfaces a toast, and navigates to the new document.
|
|
58
|
+
*/
|
|
59
|
+
onDuplicate?: () => Promise<void>
|
|
60
|
+
/**
|
|
61
|
+
* The current (saved) value of the source document's `useAsTitle`
|
|
62
|
+
* field, used to render the suffix preview inside the duplicate modal.
|
|
63
|
+
* Sourced from the form's `initialData`, not live form state, so the
|
|
64
|
+
* preview reflects what will actually be duplicated.
|
|
65
|
+
*/
|
|
66
|
+
sourceTitle?: string | null
|
|
67
|
+
/**
|
|
68
|
+
* Called when the editor confirms the Copy-to-Locale modal. The
|
|
69
|
+
* parent runs the server fn, surfaces a toast, and navigates to the
|
|
70
|
+
* target locale view. Menu item is hidden when omitted, or when fewer
|
|
71
|
+
* than two content locales are configured.
|
|
72
|
+
*/
|
|
73
|
+
onCopyToLocale?: (args: { targetLocale: string; overwrite: boolean }) => Promise<void>
|
|
74
|
+
/**
|
|
75
|
+
* The locale the form is currently displaying. Used as the read-only
|
|
76
|
+
* "From" label in the Copy-to-Locale modal and excluded from the
|
|
77
|
+
* target Select.
|
|
78
|
+
*/
|
|
79
|
+
sourceLocale?: string
|
|
80
|
+
/**
|
|
81
|
+
* All configured content locales (code + display label). The
|
|
82
|
+
* Copy-to-Locale Select lists every locale except `sourceLocale`.
|
|
83
|
+
*/
|
|
84
|
+
contentLocales?: ReadonlyArray<DocumentActionsLocaleOption>
|
|
85
|
+
}) {
|
|
86
|
+
const { t } = useTranslation('byline-admin')
|
|
87
|
+
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
|
|
88
|
+
const [showDuplicateConfirm, setShowDuplicateConfirm] = useState(false)
|
|
89
|
+
const [duplicateBusy, setDuplicateBusy] = useState(false)
|
|
90
|
+
|
|
91
|
+
// Copy-to-Locale modal state. The menu item is hidden entirely unless
|
|
92
|
+
// the host has supplied a handler AND there is at least one *other*
|
|
93
|
+
// locale to copy into.
|
|
94
|
+
const availableTargetLocales = (contentLocales ?? []).filter((loc) => loc.code !== sourceLocale)
|
|
95
|
+
const copyToLocaleAvailable = onCopyToLocale != null && availableTargetLocales.length > 0
|
|
96
|
+
const [showCopyToLocaleConfirm, setShowCopyToLocaleConfirm] = useState(false)
|
|
97
|
+
const [copyToLocaleBusy, setCopyToLocaleBusy] = useState(false)
|
|
98
|
+
const [copyTargetLocale, setCopyTargetLocale] = useState<string>(
|
|
99
|
+
availableTargetLocales[0]?.code ?? ''
|
|
100
|
+
)
|
|
101
|
+
const [copyOverwrite, setCopyOverwrite] = useState(false)
|
|
102
|
+
|
|
103
|
+
const handleOnDelete = () => {
|
|
104
|
+
setShowDeleteConfirm(false)
|
|
105
|
+
if (onDelete) {
|
|
106
|
+
onDelete()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const handleOnDuplicate = async () => {
|
|
111
|
+
if (!onDuplicate) return
|
|
112
|
+
setDuplicateBusy(true)
|
|
113
|
+
try {
|
|
114
|
+
await onDuplicate()
|
|
115
|
+
setShowDuplicateConfirm(false)
|
|
116
|
+
} finally {
|
|
117
|
+
setDuplicateBusy(false)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const handleOpenCopyToLocale = () => {
|
|
122
|
+
// Reset on open: pick the first available target and clear the
|
|
123
|
+
// overwrite checkbox so a previous-session "overwrite=true" choice
|
|
124
|
+
// is not silently sticky.
|
|
125
|
+
setCopyTargetLocale(availableTargetLocales[0]?.code ?? '')
|
|
126
|
+
setCopyOverwrite(false)
|
|
127
|
+
setShowCopyToLocaleConfirm(true)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const handleOnCopyToLocale = async () => {
|
|
131
|
+
if (!onCopyToLocale || !copyTargetLocale) return
|
|
132
|
+
setCopyToLocaleBusy(true)
|
|
133
|
+
try {
|
|
134
|
+
await onCopyToLocale({ targetLocale: copyTargetLocale, overwrite: copyOverwrite })
|
|
135
|
+
setShowCopyToLocaleConfirm(false)
|
|
136
|
+
} finally {
|
|
137
|
+
setCopyToLocaleBusy(false)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Preview text shown inside the modal. Falls back to the literal suffix
|
|
142
|
+
// when no source title is supplied (collections without `useAsTitle`).
|
|
143
|
+
const duplicatePreviewBefore = sourceTitle ?? ''
|
|
144
|
+
const duplicatePreviewAfter = (sourceTitle ?? '') + DUPLICATE_TITLE_SUFFIX
|
|
145
|
+
|
|
146
|
+
const sourceLocaleLabel =
|
|
147
|
+
contentLocales?.find((loc) => loc.code === sourceLocale)?.label ?? sourceLocale ?? ''
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
<DropdownComponent.Root>
|
|
152
|
+
<DropdownComponent.Trigger
|
|
153
|
+
render={<IconButton variant="text" intent="noeffect" size="sm" />}
|
|
154
|
+
>
|
|
155
|
+
<EllipsisIcon
|
|
156
|
+
className={cx('byline-form-actions-icon', styles.icon)}
|
|
157
|
+
width="15px"
|
|
158
|
+
height="15px"
|
|
159
|
+
/>
|
|
160
|
+
</DropdownComponent.Trigger>
|
|
161
|
+
|
|
162
|
+
<DropdownComponent.Portal>
|
|
163
|
+
<DropdownComponent.Content
|
|
164
|
+
className={cx('byline-form-actions-menu', styles.menu)}
|
|
165
|
+
align="end"
|
|
166
|
+
data-side="top"
|
|
167
|
+
sideOffset={10}
|
|
168
|
+
>
|
|
169
|
+
{/*{publishedVersion && (
|
|
170
|
+
<>
|
|
171
|
+
<DropdownComponent.Item onClick={onUnpublish}>
|
|
172
|
+
<div className={cx('byline-form-actions-item', styles.item)}>
|
|
173
|
+
<span className={cx('byline-form-actions-item-icon', styles['item-icon'])} />
|
|
174
|
+
<span className={cx('byline-form-actions-item-text', styles['item-text'])}>
|
|
175
|
+
Unpublish
|
|
176
|
+
</span>
|
|
177
|
+
</div>
|
|
178
|
+
</DropdownComponent.Item>
|
|
179
|
+
<DropdownComponent.Separator />
|
|
180
|
+
</>
|
|
181
|
+
)}*/}
|
|
182
|
+
{copyToLocaleAvailable && (
|
|
183
|
+
<DropdownComponent.Item onClick={handleOpenCopyToLocale}>
|
|
184
|
+
<div className={cx('byline-form-actions-item', styles.item)}>
|
|
185
|
+
<span className={cx('byline-form-actions-item-text', styles['item-text'])}>
|
|
186
|
+
<button type="button">{t('documentActions.copyToLocaleMenuItem')}</button>
|
|
187
|
+
</span>
|
|
188
|
+
</div>
|
|
189
|
+
</DropdownComponent.Item>
|
|
190
|
+
)}
|
|
191
|
+
{onDuplicate && (
|
|
192
|
+
<DropdownComponent.Item
|
|
193
|
+
onClick={() => {
|
|
194
|
+
setShowDuplicateConfirm(true)
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
<div className={cx('byline-form-actions-item', styles.item)}>
|
|
198
|
+
<span className={cx('byline-form-actions-item-text', styles['item-text'])}>
|
|
199
|
+
<button type="button">{t('common.actions.duplicate')}</button>
|
|
200
|
+
</span>
|
|
201
|
+
</div>
|
|
202
|
+
</DropdownComponent.Item>
|
|
203
|
+
)}
|
|
204
|
+
<DropdownComponent.Separator />
|
|
205
|
+
<DropdownComponent.Item
|
|
206
|
+
onClick={() => {
|
|
207
|
+
setShowDeleteConfirm(true)
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
<div className={cx('byline-form-actions-item', styles.item)}>
|
|
211
|
+
<span className={cx('byline-form-actions-item-icon', styles['item-icon'])}>
|
|
212
|
+
<DeleteIcon width="16px" height="16px" />
|
|
213
|
+
</span>
|
|
214
|
+
<span className={cx('byline-form-actions-item-text', styles['item-text'])}>
|
|
215
|
+
<button type="button" className={cx('byline-form-actions-delete', styles.delete)}>
|
|
216
|
+
{t('common.actions.delete')}
|
|
217
|
+
</button>
|
|
218
|
+
</span>
|
|
219
|
+
</div>
|
|
220
|
+
</DropdownComponent.Item>
|
|
221
|
+
</DropdownComponent.Content>
|
|
222
|
+
</DropdownComponent.Portal>
|
|
223
|
+
</DropdownComponent.Root>
|
|
224
|
+
|
|
225
|
+
<Modal
|
|
226
|
+
isOpen={showDeleteConfirm}
|
|
227
|
+
closeOnOverlayClick={true}
|
|
228
|
+
onDismiss={() => {
|
|
229
|
+
setShowDeleteConfirm(false)
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
232
|
+
<Modal.Container style={{ maxWidth: '500px' }}>
|
|
233
|
+
<Modal.Header className={cx('byline-form-actions-modal-head', styles['modal-head'])}>
|
|
234
|
+
<h3 className={cx('byline-form-actions-modal-title', styles['modal-title'])}>
|
|
235
|
+
{t('documentActions.delete.title')}
|
|
236
|
+
</h3>
|
|
237
|
+
<IconButton
|
|
238
|
+
arial-label={t('common.actions.close')}
|
|
239
|
+
size="xs"
|
|
240
|
+
onClick={() => {
|
|
241
|
+
setShowDeleteConfirm(false)
|
|
242
|
+
}}
|
|
243
|
+
>
|
|
244
|
+
<CloseIcon width="16px" height="16px" svgClassName="white-icon" />
|
|
245
|
+
</IconButton>
|
|
246
|
+
</Modal.Header>
|
|
247
|
+
<Modal.Content>
|
|
248
|
+
<p>{t('documentActions.delete.warning')}</p>
|
|
249
|
+
</Modal.Content>
|
|
250
|
+
<Modal.Actions>
|
|
251
|
+
<button
|
|
252
|
+
data-autofocus
|
|
253
|
+
type="button"
|
|
254
|
+
tabIndex={0}
|
|
255
|
+
className={cx('byline-form-actions-sr-only', styles['sr-only'])}
|
|
256
|
+
>
|
|
257
|
+
no action
|
|
258
|
+
</button>
|
|
259
|
+
<Button
|
|
260
|
+
size="sm"
|
|
261
|
+
style={{ minWidth: '80px' }}
|
|
262
|
+
intent="noeffect"
|
|
263
|
+
onClick={() => {
|
|
264
|
+
setShowDeleteConfirm(false)
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
{t('common.actions.cancel')}
|
|
268
|
+
</Button>
|
|
269
|
+
<Button size="sm" style={{ minWidth: '80px' }} intent="danger" onClick={handleOnDelete}>
|
|
270
|
+
{t('common.actions.delete')}
|
|
271
|
+
</Button>
|
|
272
|
+
</Modal.Actions>
|
|
273
|
+
</Modal.Container>
|
|
274
|
+
</Modal>
|
|
275
|
+
|
|
276
|
+
<Modal
|
|
277
|
+
isOpen={showDuplicateConfirm}
|
|
278
|
+
closeOnOverlayClick={!duplicateBusy}
|
|
279
|
+
onDismiss={() => {
|
|
280
|
+
if (!duplicateBusy) setShowDuplicateConfirm(false)
|
|
281
|
+
}}
|
|
282
|
+
>
|
|
283
|
+
<Modal.Container style={{ maxWidth: '560px' }}>
|
|
284
|
+
<Modal.Header className={cx('byline-form-actions-modal-head', styles['modal-head'])}>
|
|
285
|
+
<h3 className={cx('byline-form-actions-modal-title', styles['modal-title'])}>
|
|
286
|
+
{t('documentActions.duplicate.title')}
|
|
287
|
+
</h3>
|
|
288
|
+
<IconButton
|
|
289
|
+
arial-label={t('common.actions.close')}
|
|
290
|
+
size="xs"
|
|
291
|
+
onClick={() => {
|
|
292
|
+
if (!duplicateBusy) setShowDuplicateConfirm(false)
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
<CloseIcon width="16px" height="16px" svgClassName="white-icon" />
|
|
296
|
+
</IconButton>
|
|
297
|
+
</Modal.Header>
|
|
298
|
+
<Modal.Content className="prose">
|
|
299
|
+
<p className="m-0">{t('documentActions.duplicate.intro')}</p>
|
|
300
|
+
<ul className={cx('byline-form-actions-list', styles.list)}>
|
|
301
|
+
<li>
|
|
302
|
+
{t('documentActions.duplicate.bulletTitle')}{' '}
|
|
303
|
+
<code>{DUPLICATE_TITLE_SUFFIX.trim()}</code>.
|
|
304
|
+
</li>
|
|
305
|
+
<li>{t('documentActions.duplicate.bulletPath')}</li>
|
|
306
|
+
</ul>
|
|
307
|
+
{sourceTitle != null && sourceTitle.length > 0 && (
|
|
308
|
+
<div className={cx('byline-form-actions-preview', styles.preview)}>
|
|
309
|
+
<div className={cx('byline-form-actions-preview-label', styles['preview-label'])}>
|
|
310
|
+
{t('documentActions.duplicate.previewLabel')}
|
|
311
|
+
</div>
|
|
312
|
+
<div className={cx('byline-form-actions-preview-row', styles['preview-row'])}>
|
|
313
|
+
<span
|
|
314
|
+
className={cx('byline-form-actions-preview-before', styles['preview-before'])}
|
|
315
|
+
>
|
|
316
|
+
{duplicatePreviewBefore}
|
|
317
|
+
</span>
|
|
318
|
+
<span
|
|
319
|
+
className={cx('byline-form-actions-preview-arrow', styles['preview-arrow'])}
|
|
320
|
+
>
|
|
321
|
+
→
|
|
322
|
+
</span>
|
|
323
|
+
<span
|
|
324
|
+
className={cx('byline-form-actions-preview-after', styles['preview-after'])}
|
|
325
|
+
>
|
|
326
|
+
{duplicatePreviewAfter}
|
|
327
|
+
</span>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
)}
|
|
331
|
+
</Modal.Content>
|
|
332
|
+
<Modal.Actions>
|
|
333
|
+
<button
|
|
334
|
+
data-autofocus
|
|
335
|
+
type="button"
|
|
336
|
+
tabIndex={0}
|
|
337
|
+
className={cx('byline-form-actions-sr-only', styles['sr-only'])}
|
|
338
|
+
>
|
|
339
|
+
no action
|
|
340
|
+
</button>
|
|
341
|
+
<Button
|
|
342
|
+
size="sm"
|
|
343
|
+
style={{ minWidth: '80px' }}
|
|
344
|
+
intent="noeffect"
|
|
345
|
+
onClick={() => {
|
|
346
|
+
if (!duplicateBusy) setShowDuplicateConfirm(false)
|
|
347
|
+
}}
|
|
348
|
+
disabled={duplicateBusy}
|
|
349
|
+
>
|
|
350
|
+
{t('common.actions.cancel')}
|
|
351
|
+
</Button>
|
|
352
|
+
<Button
|
|
353
|
+
size="sm"
|
|
354
|
+
style={{ minWidth: '80px' }}
|
|
355
|
+
intent="primary"
|
|
356
|
+
onClick={handleOnDuplicate}
|
|
357
|
+
disabled={duplicateBusy}
|
|
358
|
+
>
|
|
359
|
+
{duplicateBusy
|
|
360
|
+
? t('documentActions.duplicate.busyButton')
|
|
361
|
+
: t('common.actions.duplicate')}
|
|
362
|
+
</Button>
|
|
363
|
+
</Modal.Actions>
|
|
364
|
+
</Modal.Container>
|
|
365
|
+
</Modal>
|
|
366
|
+
|
|
367
|
+
<Modal
|
|
368
|
+
isOpen={showCopyToLocaleConfirm}
|
|
369
|
+
closeOnOverlayClick={!copyToLocaleBusy}
|
|
370
|
+
onDismiss={() => {
|
|
371
|
+
if (!copyToLocaleBusy) setShowCopyToLocaleConfirm(false)
|
|
372
|
+
}}
|
|
373
|
+
>
|
|
374
|
+
<Modal.Container style={{ maxWidth: '560px' }}>
|
|
375
|
+
<Modal.Header className={cx('byline-form-actions-modal-head', styles['modal-head'])}>
|
|
376
|
+
<h3 className={cx('byline-form-actions-modal-title', styles['modal-title'])}>
|
|
377
|
+
{t('documentActions.copyToLocale.title')}
|
|
378
|
+
</h3>
|
|
379
|
+
<IconButton
|
|
380
|
+
arial-label={t('common.actions.close')}
|
|
381
|
+
size="xs"
|
|
382
|
+
onClick={() => {
|
|
383
|
+
if (!copyToLocaleBusy) setShowCopyToLocaleConfirm(false)
|
|
384
|
+
}}
|
|
385
|
+
>
|
|
386
|
+
<CloseIcon width="16px" height="16px" svgClassName="white-icon" />
|
|
387
|
+
</IconButton>
|
|
388
|
+
</Modal.Header>
|
|
389
|
+
<Modal.Content>
|
|
390
|
+
<p>{t('documentActions.copyToLocale.intro')}</p>
|
|
391
|
+
<div
|
|
392
|
+
className={cx('byline-form-actions-copy-row', styles['copy-row'])}
|
|
393
|
+
style={{ marginTop: 'var(--spacing-12)' }}
|
|
394
|
+
>
|
|
395
|
+
<span
|
|
396
|
+
className={cx('byline-form-actions-copy-label', styles['copy-label'])}
|
|
397
|
+
style={{ fontWeight: 500 }}
|
|
398
|
+
>
|
|
399
|
+
{t('documentActions.copyToLocale.fromLabel')}
|
|
400
|
+
</span>
|
|
401
|
+
<span className={cx('byline-form-actions-copy-source', styles['copy-source'])}>
|
|
402
|
+
{sourceLocaleLabel}
|
|
403
|
+
</span>
|
|
404
|
+
</div>
|
|
405
|
+
<div
|
|
406
|
+
className={cx('byline-form-actions-copy-row', styles['copy-row'])}
|
|
407
|
+
style={{ marginTop: 'var(--spacing-12)' }}
|
|
408
|
+
>
|
|
409
|
+
<span
|
|
410
|
+
className={cx('byline-form-actions-copy-label', styles['copy-label'])}
|
|
411
|
+
style={{ fontWeight: 500, marginRight: 'var(--spacing-8)' }}
|
|
412
|
+
>
|
|
413
|
+
{t('documentActions.copyToLocale.toLabel')}
|
|
414
|
+
</span>
|
|
415
|
+
<Select<string>
|
|
416
|
+
size="sm"
|
|
417
|
+
ariaLabel={t('documentActions.copyToLocale.targetAriaLabel')}
|
|
418
|
+
value={copyTargetLocale}
|
|
419
|
+
items={availableTargetLocales.map((loc) => ({
|
|
420
|
+
value: loc.code,
|
|
421
|
+
label: loc.label,
|
|
422
|
+
}))}
|
|
423
|
+
onValueChange={(value) => {
|
|
424
|
+
if (value != null) setCopyTargetLocale(value)
|
|
425
|
+
}}
|
|
426
|
+
disabled={copyToLocaleBusy}
|
|
427
|
+
/>
|
|
428
|
+
</div>
|
|
429
|
+
<div
|
|
430
|
+
className={cx('byline-form-actions-copy-row', styles['copy-row'])}
|
|
431
|
+
style={{ marginTop: 'var(--spacing-16)' }}
|
|
432
|
+
>
|
|
433
|
+
<Checkbox
|
|
434
|
+
id="copy-to-locale-overwrite"
|
|
435
|
+
name="overwrite"
|
|
436
|
+
label={t('documentActions.copyToLocale.overwriteLabel')}
|
|
437
|
+
checked={copyOverwrite}
|
|
438
|
+
disabled={copyToLocaleBusy}
|
|
439
|
+
helpText={t('documentActions.copyToLocale.overwriteHelp')}
|
|
440
|
+
onCheckedChange={(value) => {
|
|
441
|
+
setCopyOverwrite(value === true)
|
|
442
|
+
}}
|
|
443
|
+
/>
|
|
444
|
+
</div>
|
|
445
|
+
</Modal.Content>
|
|
446
|
+
<Modal.Actions>
|
|
447
|
+
<button
|
|
448
|
+
data-autofocus
|
|
449
|
+
type="button"
|
|
450
|
+
tabIndex={0}
|
|
451
|
+
className={cx('byline-form-actions-sr-only', styles['sr-only'])}
|
|
452
|
+
>
|
|
453
|
+
no action
|
|
454
|
+
</button>
|
|
455
|
+
<Button
|
|
456
|
+
size="sm"
|
|
457
|
+
style={{ minWidth: '80px' }}
|
|
458
|
+
intent="noeffect"
|
|
459
|
+
onClick={() => {
|
|
460
|
+
if (!copyToLocaleBusy) setShowCopyToLocaleConfirm(false)
|
|
461
|
+
}}
|
|
462
|
+
disabled={copyToLocaleBusy}
|
|
463
|
+
>
|
|
464
|
+
{t('common.actions.cancel')}
|
|
465
|
+
</Button>
|
|
466
|
+
<Button
|
|
467
|
+
size="sm"
|
|
468
|
+
style={{ minWidth: '80px' }}
|
|
469
|
+
intent="primary"
|
|
470
|
+
onClick={handleOnCopyToLocale}
|
|
471
|
+
disabled={copyToLocaleBusy || !copyTargetLocale}
|
|
472
|
+
>
|
|
473
|
+
{copyToLocaleBusy
|
|
474
|
+
? t('documentActions.copyToLocale.busyButton')
|
|
475
|
+
: t('documentActions.copyToLocale.confirmButton')}
|
|
476
|
+
</Button>
|
|
477
|
+
</Modal.Actions>
|
|
478
|
+
</Modal.Container>
|
|
479
|
+
</Modal>
|
|
480
|
+
</>
|
|
481
|
+
)
|
|
482
|
+
}
|