@byline/admin 4.19.0 → 5.0.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/field-services-types.d.ts +5 -2
- package/dist/forms/available-locales-widget.d.ts +2 -1
- package/dist/forms/available-locales-widget.js +4 -2
- package/dist/forms/document-actions.d.ts +2 -1
- package/dist/forms/document-actions.js +32 -14
- package/dist/forms/form-renderer.d.ts +9 -0
- package/dist/forms/form-renderer.js +98 -8
- package/dist/forms/form-renderer.module.js +1 -0
- package/dist/forms/form-renderer_module.css +12 -0
- package/dist/forms/form-status-display.d.ts +2 -1
- package/dist/forms/form-status-display.js +5 -2
- package/dist/forms/path-widget.d.ts +2 -1
- package/dist/forms/path-widget.js +7 -2
- package/dist/forms/scheduled-publication-control.d.ts +2 -1
- package/dist/forms/scheduled-publication-control.js +12 -8
- package/dist/forms/tree-placement-widget.d.ts +5 -1
- package/dist/forms/tree-placement-widget.js +14 -7
- package/package.json +7 -7
- package/src/fields/field-services-types.ts +10 -2
- package/src/forms/available-locales-widget.tsx +5 -2
- package/src/forms/document-actions.tsx +55 -20
- package/src/forms/form-renderer-submit.test.tsx +131 -2
- package/src/forms/form-renderer.module.css +20 -0
- package/src/forms/form-renderer.tsx +122 -7
- package/src/forms/form-status-display.tsx +6 -1
- package/src/forms/path-widget.tsx +8 -3
- package/src/forms/scheduled-publication-control.tsx +16 -7
- package/src/forms/tree-placement-widget.tsx +34 -7
|
@@ -20,6 +20,10 @@ import { RelationPicker } from '../fields/relation/relation-picker.js'
|
|
|
20
20
|
import styles from './tree-placement-widget.module.css'
|
|
21
21
|
|
|
22
22
|
export interface TreePlacementWidgetProps {
|
|
23
|
+
disabled?: boolean
|
|
24
|
+
onMutationError?: (error: unknown) => 'blocked' | 'committed' | null | void
|
|
25
|
+
onCommitted?: (receipt: import('@byline/core').StructuralMutationReceipt) => void
|
|
26
|
+
expectedRevision: number
|
|
23
27
|
/** The collection path (`tree: true`). */
|
|
24
28
|
collectionPath: string
|
|
25
29
|
/** The logical id of the document being edited. */
|
|
@@ -44,6 +48,10 @@ export interface TreePlacementWidgetProps {
|
|
|
44
48
|
*/
|
|
45
49
|
export const TreePlacementWidget = ({
|
|
46
50
|
collectionPath,
|
|
51
|
+
disabled = false,
|
|
52
|
+
onMutationError,
|
|
53
|
+
onCommitted,
|
|
54
|
+
expectedRevision,
|
|
47
55
|
documentId,
|
|
48
56
|
useAsTitle,
|
|
49
57
|
}: TreePlacementWidgetProps) => {
|
|
@@ -99,7 +107,7 @@ export const TreePlacementWidget = ({
|
|
|
99
107
|
// placement (including making the node a root) leaves it placed.
|
|
100
108
|
const place = useCallback(
|
|
101
109
|
async (parentDocumentId: string | null, optimistic: { id: string; title: string } | null) => {
|
|
102
|
-
if (placeTreeNode == null || busy) return
|
|
110
|
+
if (disabled || placeTreeNode == null || busy) return
|
|
103
111
|
const previousParent = parent
|
|
104
112
|
const previousPlaced = placed
|
|
105
113
|
setError(null)
|
|
@@ -107,8 +115,15 @@ export const TreePlacementWidget = ({
|
|
|
107
115
|
setParent(optimistic)
|
|
108
116
|
setPlaced(true)
|
|
109
117
|
try {
|
|
110
|
-
await placeTreeNode({
|
|
111
|
-
|
|
118
|
+
const result = await placeTreeNode({
|
|
119
|
+
expectedRevision,
|
|
120
|
+
collection: collectionPath,
|
|
121
|
+
documentId,
|
|
122
|
+
parentDocumentId,
|
|
123
|
+
})
|
|
124
|
+
onCommitted?.(result)
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (onMutationError?.(error) === 'committed') return
|
|
112
127
|
setParent(previousParent)
|
|
113
128
|
setPlaced(previousPlaced)
|
|
114
129
|
setError(t('treeWidget.error'))
|
|
@@ -116,7 +131,19 @@ export const TreePlacementWidget = ({
|
|
|
116
131
|
setBusy(false)
|
|
117
132
|
}
|
|
118
133
|
},
|
|
119
|
-
[
|
|
134
|
+
[
|
|
135
|
+
disabled,
|
|
136
|
+
onMutationError,
|
|
137
|
+
onCommitted,
|
|
138
|
+
expectedRevision,
|
|
139
|
+
placeTreeNode,
|
|
140
|
+
busy,
|
|
141
|
+
parent,
|
|
142
|
+
placed,
|
|
143
|
+
collectionPath,
|
|
144
|
+
documentId,
|
|
145
|
+
t,
|
|
146
|
+
]
|
|
120
147
|
)
|
|
121
148
|
|
|
122
149
|
const handlePick = useCallback(
|
|
@@ -156,7 +183,7 @@ export const TreePlacementWidget = ({
|
|
|
156
183
|
size="xs"
|
|
157
184
|
variant="outlined"
|
|
158
185
|
intent="noeffect"
|
|
159
|
-
disabled={loading || busy}
|
|
186
|
+
disabled={disabled || loading || busy}
|
|
160
187
|
onClick={() => setPickerOpen(true)}
|
|
161
188
|
>
|
|
162
189
|
{t('treeWidget.choose')}
|
|
@@ -165,7 +192,7 @@ export const TreePlacementWidget = ({
|
|
|
165
192
|
<button
|
|
166
193
|
type="button"
|
|
167
194
|
className={cx('byline-form-tree-link', styles.link)}
|
|
168
|
-
disabled={loading || busy}
|
|
195
|
+
disabled={disabled || loading || busy}
|
|
169
196
|
onClick={() => place(null, null)}
|
|
170
197
|
>
|
|
171
198
|
{t('treeWidget.addToTree')}
|
|
@@ -175,7 +202,7 @@ export const TreePlacementWidget = ({
|
|
|
175
202
|
<button
|
|
176
203
|
type="button"
|
|
177
204
|
className={cx('byline-form-tree-link', styles.link)}
|
|
178
|
-
disabled={busy}
|
|
205
|
+
disabled={disabled || busy}
|
|
179
206
|
onClick={() => place(null, null)}
|
|
180
207
|
>
|
|
181
208
|
{t('treeWidget.makeRoot')}
|