Commit 13e6035
authored
feat(plugin-import-export)!: refactor plugin and add import functionality (#14782)
This PR works to refactor the entire plugin so it's easier for us to
work with it going forward and also implements import functionality.
It expands the int tests and adds some e2e tests as well.
## Previous config
Previously the config for the plugin looked like this. If you wanted to
disable jobs queue you'd have to do it for all collections, the
`collections` config was optional and the plugin applied both import and
export functionality to _all_ collections which isn't normally how our
plugins work.
If you want to customise certain behaviour you need to instantiate the
plugin multiple times, which causes additional problems by doubling up
providers, UI components and endpoints.
As such we're committing some breaking changes while the plugin is in
beta to standardise the config and allow more customisation.
```ts
importExportPlugin({
overrideExportCollection: (collection) => {
collection.admin.group = 'System'
collection.upload.staticDir = path.resolve(dirname, 'uploads')
return collection
},
overrideImportCollection: (collection) => {
collection.admin.group = 'System'
collection.upload.staticDir = path.resolve(dirname, 'uploads')
return collection
},
disableJobsQueue: true,
debug: true,
// collections: ['posts'] // optionally provided - defaults to all collections
}),
```
## New config
The new config pushes most customisation to a per collection level so
that you only ever need to instantiate the plugin once.
You can now provide export/import collections per collection config if
needed, do not instantiate the plugin multiple times.
`collections` is now required.
```ts
importExportPlugin({
overrideExportCollection: (collection) => {
collection.admin.group = 'System'
collection.upload.staticDir = path.resolve(dirname, 'uploads')
return collection
},
overrideImportCollection: (collection) => {
collection.admin.group = 'System'
collection.upload.staticDir = path.resolve(dirname, 'uploads')
return collection
},
collections: [
{
slug: 'posts',
import: false, // disables import functionality, export enabled by default
},
{
slug: 'pages',
// customise the export collection per collection if needed
export: ({ collection }) => {
collection.admin.group = 'System'
collection.upload.staticDir = path.resolve(dirname, 'uploads')
return collection
},
disableJobsQueue: true, // disable jobs queue for this collection only
},
],
debug: true, // debug remains top level
})
```
This PR also fixes the following:
- Drafts being exported even if 'no' is selected to include them
- Fetch endpoints from preview not respecting the API routes
- Downloads not respecting drafts
- Dependencies on `csv-parse` and `csv-stringify` are now pinned
Todo:
- [x] Regenerate all translations
- [x] Add docs for import
- [x] Review code structure/patterns
- [x] Polish the preview UI to allow for pagination, show loading states
and make it clear what data is being previewed1 parent 7d80d21 commit 13e6035
109 files changed
Lines changed: 13899 additions & 877 deletions
File tree
- docs/plugins
- packages
- plugin-ecommerce/src/collections/carts
- plugin-import-export
- src
- components
- CollectionField
- ExportListMenuItem
- ExportPreview
- ImportCollectionField
- ImportListMenuItem
- ImportPreview
- ImportSaveButton
- Page
- Preview
- exports
- export
- import
- translations
- languages
- utilities
- test
- plugin-import-export
- collections
- seed
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments