@sanity/cross-dataset-duplicator 1.1.0 → 1.2.1
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/README.md +56 -2
- package/{lib/src → dist}/index.d.ts +10 -7
- package/dist/index.esm.js +1063 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1079 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -52
- package/src/actions/DuplicateToAction.tsx +1 -1
- package/src/components/CrossDatasetDuplicator.tsx +11 -3
- package/src/components/CrossDatasetDuplicatorAction.tsx +2 -3
- package/src/components/CrossDatasetDuplicatorTool.tsx +0 -1
- package/src/components/Duplicator.tsx +11 -3
- package/src/components/DuplicatorQuery.tsx +1 -1
- package/src/components/DuplicatorWrapper.tsx +5 -3
- package/src/components/ResetSecret.tsx +2 -2
- package/src/components/SelectButtons.tsx +1 -1
- package/src/components/StatusBadge.tsx +0 -1
- package/src/context/ConfigProvider.tsx +1 -1
- package/src/types/index.ts +1 -0
- package/lib/index.esm.js +0 -1
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -71,13 +71,63 @@ The plugin has some configuration options. These can be set by adding a config f
|
|
|
71
71
|
})
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Options:
|
|
74
|
+
#### Options:
|
|
75
75
|
|
|
76
76
|
- `tool` (boolean, default: true) – Set whether the Migration **Tool** is enabled.
|
|
77
77
|
- `types` (Array[String], default: []) – Set which Schema Types the Migration Action should be enabled in.
|
|
78
78
|
- `filter` (String, default: undefined) - Set a predicate for documents when gathering dependencies.
|
|
79
79
|
- `follow` (("inbound" | "outbound")[], default: []) – Add buttons to allow the user to begin with just the existing document or first fetch all inbound references.
|
|
80
80
|
|
|
81
|
+
#### Action Options
|
|
82
|
+
|
|
83
|
+
The Document Action has additional config options:
|
|
84
|
+
|
|
85
|
+
- `onDuplicated` (`() => Promise<void>`, default: undefined) - fire a callback after documents have been duplicated.
|
|
86
|
+
|
|
87
|
+
The `onDuplicated` callback could be used to update update metadata after documents have been synced, or to perform arbitrary cleanup tasks like closing the dialog:
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
const DuplicatorAction = ({ published, onComplete }: DocumentActionProps) => {
|
|
91
|
+
const [dialogOpen, setDialogOpen] = useState(false)
|
|
92
|
+
const [submitting, setSubmitting] = useState(false)
|
|
93
|
+
const [duplicated, setDuplicated] = useState(false)
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
label: 'Duplicate',
|
|
97
|
+
title: 'Duplicate',
|
|
98
|
+
tone: 'positive',
|
|
99
|
+
disabled: submitting || duplicated,
|
|
100
|
+
loading: submitting,
|
|
101
|
+
icon: PublishIcon,
|
|
102
|
+
dialog: dialogOpen && published && {
|
|
103
|
+
type: 'popover',
|
|
104
|
+
title: 'Cross Dataset Duplicator',
|
|
105
|
+
content: (
|
|
106
|
+
<CrossDatasetDuplicatorAction
|
|
107
|
+
docs={[published]}
|
|
108
|
+
onDuplicated={async () => {
|
|
109
|
+
alert('data migrated')
|
|
110
|
+
await new Promise((resolve) => {
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
setDialogOpen(false);
|
|
113
|
+
setDuplicated(true)
|
|
114
|
+
resolve()
|
|
115
|
+
}, 1000)
|
|
116
|
+
})
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
),
|
|
120
|
+
onHandle: () => setDialogOpen(true),
|
|
121
|
+
onClose: () => {
|
|
122
|
+
onComplete()
|
|
123
|
+
setDialogOpen(false)
|
|
124
|
+
setSubmitting(false)
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
81
131
|
### 3. Authentication Key
|
|
82
132
|
|
|
83
133
|
To Duplicate the original files of Assets, an API Token with Viewer permissions is required. You will be prompted for this the first time you attempt to use either the Tool or Document Action on any Dataset.
|
|
@@ -113,4 +163,8 @@ on how to run this plugin with hotreload in the studio.
|
|
|
113
163
|
Run ["CI & Release" workflow](https://github.com/sanity-io/cross-dataset-duplicator/actions/workflows/main.yml).
|
|
114
164
|
Make sure to select the main branch and check "Release new version".
|
|
115
165
|
|
|
116
|
-
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
|
166
|
+
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
[MIT](LICENSE) © Sanity.io
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
|
|
3
3
|
import {DocumentActionProps} from 'sanity'
|
|
4
|
+
import {ForwardRefExoticComponent} from 'react'
|
|
4
5
|
import {Plugin as Plugin_2} from 'sanity'
|
|
5
|
-
import {
|
|
6
|
+
import {RefAttributes} from 'react'
|
|
6
7
|
import {SanityDocument} from 'sanity'
|
|
8
|
+
import {SVGProps} from 'react'
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Plugin: Cross Dataset Duplicator
|
|
@@ -25,6 +27,7 @@ export declare function CrossDatasetDuplicatorAction(
|
|
|
25
27
|
*/
|
|
26
28
|
export declare type CrossDatasetDuplicatorActionProps = {
|
|
27
29
|
docs: SanityDocument[]
|
|
30
|
+
onDuplicated?: () => Promise<void>
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
/**
|
|
@@ -46,10 +49,13 @@ export declare const DuplicateToAction: {
|
|
|
46
49
|
}
|
|
47
50
|
| null
|
|
48
51
|
onHandle: () => void
|
|
49
|
-
icon:
|
|
52
|
+
icon: ForwardRefExoticComponent<
|
|
50
53
|
Pick<
|
|
51
|
-
|
|
54
|
+
SVGProps<SVGSVGElement>,
|
|
52
55
|
| 'string'
|
|
56
|
+
| 'filter'
|
|
57
|
+
| 'fill'
|
|
58
|
+
| 'values'
|
|
53
59
|
| 'height'
|
|
54
60
|
| 'crossOrigin'
|
|
55
61
|
| 'href'
|
|
@@ -285,10 +291,8 @@ export declare const DuplicateToAction: {
|
|
|
285
291
|
| 'overflow'
|
|
286
292
|
| 'radius'
|
|
287
293
|
| 'clipPath'
|
|
288
|
-
| 'filter'
|
|
289
294
|
| 'mask'
|
|
290
295
|
| 'path'
|
|
291
|
-
| 'fill'
|
|
292
296
|
| 'direction'
|
|
293
297
|
| 'fontSize'
|
|
294
298
|
| 'mode'
|
|
@@ -483,7 +487,6 @@ export declare const DuplicateToAction: {
|
|
|
483
487
|
| 'unicodeRange'
|
|
484
488
|
| 'unitsPerEm'
|
|
485
489
|
| 'vAlphabetic'
|
|
486
|
-
| 'values'
|
|
487
490
|
| 'vectorEffect'
|
|
488
491
|
| 'version'
|
|
489
492
|
| 'vertAdvY'
|
|
@@ -522,7 +525,7 @@ export declare const DuplicateToAction: {
|
|
|
522
525
|
| 'z'
|
|
523
526
|
| 'zoomAndPan'
|
|
524
527
|
> &
|
|
525
|
-
|
|
528
|
+
RefAttributes<SVGSVGElement>
|
|
526
529
|
>
|
|
527
530
|
}
|
|
528
531
|
action: string
|