From f406de14172d4a8c3f9bb61fd0fd2820f27db258 Mon Sep 17 00:00:00 2001 From: Etienne Laurent Date: Tue, 5 Dec 2023 15:34:51 +0100 Subject: [PATCH] prefix events --- lib/methods/export.js | 2 +- lib/methods/import.js | 6 +++--- .../@apostrophecms/import-export-piece-type/index.js | 2 +- test/index.js | 10 +++++----- ui/apos/apps/index.js | 10 +++++----- ui/apos/components/AposDuplicateImportModal.vue | 2 +- ui/apos/components/AposImportModal.vue | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/methods/export.js b/lib/methods/export.js index 7c76bf49..92d70158 100644 --- a/lib/methods/export.js +++ b/lib/methods/export.js @@ -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 } diff --git a/lib/methods/import.js b/lib/methods/import.js index e0764da2..72ff5584 100644 --- a/lib/methods/import.js +++ b/lib/methods/import.js @@ -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, @@ -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' } }); @@ -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' ] diff --git a/modules/@apostrophecms/import-export-piece-type/index.js b/modules/@apostrophecms/import-export-piece-type/index.js index 0aaf240f..2838808b 100644 --- a/modules/@apostrophecms/import-export-piece-type/index.js +++ b/modules/@apostrophecms/import-export-piece-type/index.js @@ -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' } diff --git a/test/index.js b/test/index.js index b9966142..14b70899 100644 --- a/test/index.js +++ b/test/index.js @@ -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 {}; @@ -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 {}; @@ -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 {}; @@ -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); @@ -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 {}; diff --git a/ui/apos/apps/index.js b/ui/apos/apps/index.js index 50d3bca6..df4fe004 100644 --- a/ui/apos/apps/index.js +++ b/ui/apos/apps/index.js @@ -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); } }); diff --git a/ui/apos/components/AposDuplicateImportModal.vue b/ui/apos/components/AposDuplicateImportModal.vue index 2345a935..1acbb4b2 100644 --- a/ui/apos/components/AposDuplicateImportModal.vue +++ b/ui/apos/components/AposDuplicateImportModal.vue @@ -205,7 +205,7 @@ export default { } }); } finally { - apos.bus.$emit('import-ended'); + apos.bus.$emit('import-export-import-ended'); } }, ready() { diff --git a/ui/apos/components/AposImportModal.vue b/ui/apos/components/AposImportModal.vue index d25c6079..3f2a23c8 100644 --- a/ui/apos/components/AposImportModal.vue +++ b/ui/apos/components/AposImportModal.vue @@ -126,7 +126,7 @@ 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(() => { @@ -134,7 +134,7 @@ export default { type: 'danger', dismiss: true }); - apos.bus.$emit('import-ended'); + apos.bus.$emit('import-export-import-ended'); }); this.modal.showModal = false;