Skip to content

Commit

Permalink
prefix events
Browse files Browse the repository at this point in the history
  • Loading branch information
Etienne Laurent committed Dec 5, 2023
1 parent 787dd05 commit f406de1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/methods/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ module.exports = self => {
icon: 'database-export-icon',
type: 'success',
event: {
name: 'export-download',
name: 'import-export-export-download',
data: {
url: downloadUrl
}
Expand Down
6 changes: 3 additions & 3 deletions lib/methods/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = self => {
await self.apos.notify(req, ' ', {
type: 'warning',
event: {
name: 'import-locale-differs',
name: 'import-export-import-locale-differs',
data: {
moduleName,
exportPath,
Expand Down Expand Up @@ -95,7 +95,7 @@ module.exports = self => {
icon: 'database-import-icon',
type: failedIds.length ? 'danger' : 'success',
event: {
name: 'import-ended'
name: 'import-export-import-ended'
}
});

Expand Down Expand Up @@ -134,7 +134,7 @@ module.exports = self => {
await self.apos.notify(req, ' ', {
type: 'warning',
event: {
name: 'import-duplicates',
name: 'import-export-import-duplicates',
data: results
},
classes: [ 'apos-notification--hidden' ]
Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/import-export-piece-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
progress: 'aposImportExport:exporting',
completed: 'aposImportExport:exported',
icon: 'database-export-icon',
resultsEventName: 'export-download'
resultsEventName: 'import-export-export-download'
},
modal: 'AposExportModal'
}
Expand Down
10 changes: 5 additions & 5 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ describe('@apostrophecms/import-export', function () {
};
};
apos.notify = async (req, message, options) => {
if (options?.event?.name === 'import-locale-differs') {
if (options?.event?.name === 'import-export-import-locale-differs') {
throw new Error('should not have been called with event "import-locale-differ"');
}
return {};
Expand Down Expand Up @@ -824,7 +824,7 @@ describe('@apostrophecms/import-export', function () {
};
};
apos.notify = async (req, message, options) => {
if (options?.event?.name === 'import-locale-differs') {
if (options?.event?.name === 'import-export-import-locale-differs') {
throw new Error('should not have been called with event "import-locale-differ"');
}
return {};
Expand Down Expand Up @@ -948,7 +948,7 @@ describe('@apostrophecms/import-export', function () {
};
};
apos.notify = async (req, message, options) => {
if (options?.event?.name === 'import-locale-differs') {
if (options?.event?.name === 'import-export-import-locale-differs') {
throw new Error('should not have been called with event "import-locale-differ"');
}
return {};
Expand Down Expand Up @@ -980,7 +980,7 @@ describe('@apostrophecms/import-export', function () {
throw new Error('should not have been called');
};
apos.notify = async (req, message, options) => {
assert.equal(options.event.name, 'import-locale-differs');
assert.equal(options.event.name, 'import-export-import-locale-differs');
};

await importExportManager.import(req);
Expand Down Expand Up @@ -1040,7 +1040,7 @@ describe('@apostrophecms/import-export', function () {
};
};
apos.notify = async (req, message, options) => {
if (options?.event?.name === 'import-locale-differs') {
if (options?.event?.name === 'import-export-import-locale-differs') {
throw new Error('should not have been called with event "import-locale-differ"');
}
return {};
Expand Down
10 changes: 5 additions & 5 deletions ui/apos/apps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export default () => {
apos.util.onReady(() => {
if (!ready) {
ready = true;
apos.bus.$on('export-download', openUrl);
apos.bus.$on('import-started', addBeforeUnloadListener);
apos.bus.$on('import-ended', removeBeforeUnloadListener);
apos.bus.$on('import-locale-differs', handleDifferentLocale);
apos.bus.$on('import-duplicates', handleDuplicates);
apos.bus.$on('import-export-export-download', openUrl);
apos.bus.$on('import-export-import-started', addBeforeUnloadListener);
apos.bus.$on('import-export-import-ended', removeBeforeUnloadListener);
apos.bus.$on('import-export-import-locale-differs', handleDifferentLocale);
apos.bus.$on('import-export-import-duplicates', handleDuplicates);
}
});

Expand Down
2 changes: 1 addition & 1 deletion ui/apos/components/AposDuplicateImportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default {
}
});
} finally {
apos.bus.$emit('import-ended');
apos.bus.$emit('import-export-import-ended');
}
},
ready() {
Expand Down
4 changes: 2 additions & 2 deletions ui/apos/components/AposImportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ export default {
const formData = new FormData();
formData.append('file', this.selectedFile);
apos.bus.$emit('import-started');
apos.bus.$emit('import-export-import-started');
apos.http.post(`${this.moduleAction}/${this.action}`, {
body: formData
}).catch(() => {
apos.notify('aposImportExport:importFailed', {
type: 'danger',
dismiss: true
});
apos.bus.$emit('import-ended');
apos.bus.$emit('import-export-import-ended');
});
this.modal.showModal = false;
Expand Down

0 comments on commit f406de1

Please sign in to comment.