Skip to content

Commit

Permalink
prefix routes to avoid conflicts with the old pieces import and expor…
Browse files Browse the repository at this point in the history
…t modules
  • Loading branch information
Etienne Laurent committed Dec 5, 2023
1 parent 529b066 commit 787dd05
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## UNRELEASED

### Changes

* Prefix routes to avoid conflicts with the old [`@apostrophecms/piece-type-importer`](https://github.com/apostrophecms/piece-type-importer) and [`@apostrophecms/piece-type-exporter`](https://github.com/apostrophecms/piece-type-exporter) modules.

## 1.2.0 (2023-11-29)

### Adds
Expand Down
4 changes: 2 additions & 2 deletions modules/@apostrophecms/import-export-doc-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = {

init(self) {
const operation = {
action: 'export',
action: 'import-export-export',
context: 'update',
label: 'aposImportExport:export',
modal: 'AposExportModal',
props: {
action: 'export'
action: 'import-export-export'
}
};

Expand Down
8 changes: 4 additions & 4 deletions modules/@apostrophecms/import-export-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {

return {
add: {
import: {
'import-export-import': {
label: 'aposImportExport:import',
modalOptions: {
modal: 'AposImportModal'
Expand All @@ -24,16 +24,16 @@ module.exports = {
return {
post: {
...self.options.importExport?.import !== false && {
import: [
importExportImport: [
multiparty(),
async (req) => {
return self.apos.modules['@apostrophecms/import-export'].import(req, self.__meta.name);
}
]
},
...self.options.importExport?.export !== false && {
export(req) {
// Add the page label to req.body for notifications.
importExportExport(req) {
// Add the page label to req.body for notifications.
req.body.type = req.t('apostrophe:page');

return self.apos.modules['@apostrophecms/import-export'].export(req, self);
Expand Down
12 changes: 6 additions & 6 deletions modules/@apostrophecms/import-export-piece-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {

return {
add: {
import: {
'import-export-import': {
label: 'aposImportExport:import',
modalOptions: {
modal: 'AposImportModal'
Expand All @@ -26,7 +26,7 @@ module.exports = {

return {
add: {
'export-batch': {
'import-export-export-batch': {
label: 'aposImportExport:export',
messages: {
progress: 'aposImportExport:exporting',
Expand All @@ -40,7 +40,7 @@ module.exports = {
group: {
more: {
icon: 'dots-vertical-icon',
operations: [ 'export-batch' ]
operations: [ 'import-export-export-batch' ]
}
}
};
Expand All @@ -49,7 +49,7 @@ module.exports = {
return {
post: {
...self.options.importExport?.import !== false && {
import: [
importExportImport: [
multiparty(),
async (req) => {
return self.apos.modules['@apostrophecms/import-export'].import(req, self.__meta.name);
Expand All @@ -58,7 +58,7 @@ module.exports = {
},

...self.options.importExport?.export !== false && {
export(req) {
importExportExport(req) {
// Add the piece type label to req.body for notifications.
req.body.type = req.t(self.options.label);

Expand All @@ -68,7 +68,7 @@ module.exports = {
// in order to make the job work with the progress notification.
// The other 'export' routes that are used by context operations on each doc
// are also POST for consistency.
exportBatch(req) {
importExportExportBatch(req) {
// Add the piece type label to req.body for notifications.
// Should be done before calling the job's `run` method.
req.body.type = req.body._ids.length === 1
Expand Down
2 changes: 1 addition & 1 deletion ui/apos/apps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default () => {
try {
const moduleAction = apos.modules[event.moduleName].action;

await apos.http.post(`${moduleAction}/import`, {
await apos.http.post(`${moduleAction}/import-export-import`, {
body: {
overrideLocale: true,
exportPath: event.exportPath
Expand Down

0 comments on commit 787dd05

Please sign in to comment.