From 9f08dcdce3513493de1dc835ff9beddb18bb2eb6 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Tue, 10 Oct 2023 12:13:36 +0100 Subject: [PATCH] feat: Reuse centralized Toast Notifs component - MEED-2627 - Meeds-io/MIPs#99 (#276) Prior to this change, the used toast notifications wasn't relying on the centralized reusable component to display alerts. This change removes the specific alerts in order to reuse the centralized component. --- .../vue-app/components/PerkStoreApp.vue | 12 --- .../components/perk-store/PerkStoreAlert.vue | 42 ----------- .../components/perk-store/ProductDetail.vue | 4 +- .../perk-store/ProductNotification.vue | 73 ------------------- .../src/main/webapp/vue-app/initComponents.js | 4 - .../components/PerkStoreAdmin.vue | 25 +------ .../webapp/vue-app/perk-store-admin/main.js | 4 +- .../components/PerkStoreOverview.vue | 1 - .../perk-store-overview/initComponents.js | 2 - .../vue-app/perk-store-overview/main.js | 4 +- .../src/main/webapp/vue-app/perk-store.js | 4 +- 11 files changed, 11 insertions(+), 164 deletions(-) delete mode 100644 perk-store-webapps/src/main/webapp/vue-app/components/perk-store/PerkStoreAlert.vue delete mode 100644 perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductNotification.vue diff --git a/perk-store-webapps/src/main/webapp/vue-app/components/PerkStoreApp.vue b/perk-store-webapps/src/main/webapp/vue-app/components/PerkStoreApp.vue index a2a16fd4c..f0ef30d7f 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/components/PerkStoreApp.vue +++ b/perk-store-webapps/src/main/webapp/vue-app/components/PerkStoreApp.vue @@ -19,7 +19,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. id="PerkStoreApp" class="transparent singlePageApplication" flat> -
@@ -104,9 +103,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. :wallet-loading="walletLoading" :wallet-enabled="walletEnabled" @closeProductDetails="closeProduct()" /> - { - if (!product.lastModifiedDate && !this.products.find(existingProduct => existingProduct.id === product.id)) { - this.products.unshift(product); - } - }); - this.modifiedProducts.splice(0, this.modifiedProducts.length); - }, } }; \ No newline at end of file diff --git a/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/PerkStoreAlert.vue b/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/PerkStoreAlert.vue deleted file mode 100644 index de0fc2cd6..000000000 --- a/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/PerkStoreAlert.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - diff --git a/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductDetail.vue b/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductDetail.vue index 9491cf1d7..e1c948d17 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductDetail.vue +++ b/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductDetail.vue @@ -352,7 +352,7 @@ export default { removeProduct() { deleteProduct(this.product.id) .then(() => { - this.$root.$emit('show-alert', {type: 'success',message: this.$t('exoplatform.perkstore.label.deleteSuccess')}); + this.$root.$emit('alert-message', this.$t('exoplatform.perkstore.label.deleteSuccess'), 'success'); this.$emit('product-deleted'); }).catch(e => { let msg = ''; @@ -363,7 +363,7 @@ export default { } else { msg = this.$t('exoplatform.perkstore.label.deleteError'); } - this.$root.$emit('show-alert', {type: 'error',message: msg}); + this.$root.$emit('alert-message', msg, 'error'); }); }, } diff --git a/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductNotification.vue b/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductNotification.vue deleted file mode 100644 index 2ff7f85be..000000000 --- a/perk-store-webapps/src/main/webapp/vue-app/components/perk-store/ProductNotification.vue +++ /dev/null @@ -1,73 +0,0 @@ - - - diff --git a/perk-store-webapps/src/main/webapp/vue-app/initComponents.js b/perk-store-webapps/src/main/webapp/vue-app/initComponents.js index ab1fd2b33..43a5fafbf 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/initComponents.js +++ b/perk-store-webapps/src/main/webapp/vue-app/initComponents.js @@ -13,9 +13,7 @@ import OrderNotification from './components/perk-store/OrderNotification.vue'; import OrdersFilter from './components/perk-store/OrdersFilter.vue'; import OrdersList from './components/perk-store/OrdersList.vue'; import ProductDetailContent from './components/perk-store/ProductDetailContent.vue'; -import ProductNotification from './components/perk-store/ProductNotification.vue'; import PerkStoreProductSearchCard from './components/perk-store-search/PerkStoreProductSearchCard.vue'; -import PerkStoreAlert from './components/perk-store/PerkStoreAlert.vue'; import RefundDrawer from './components/perk-store/RefundDrawer.vue'; import PerkStoreToolbar from './components/perk-store/PerkStoreToolbar.vue'; @@ -35,9 +33,7 @@ const components = { 'perk-store-orders-filter': OrdersFilter, 'perk-store-orders-list': OrdersList, 'perk-store-product-detail-content': ProductDetailContent, - 'perk-store-product-notification': ProductNotification, 'perk-store-product-search-card': PerkStoreProductSearchCard, - 'perk-store-alert': PerkStoreAlert, 'perk-store-refund-drawer': RefundDrawer, 'perk-store-toolbar': PerkStoreToolbar, }; diff --git a/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/components/PerkStoreAdmin.vue b/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/components/PerkStoreAdmin.vue index f7fc1670d..0875669e8 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/components/PerkStoreAdmin.vue +++ b/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/components/PerkStoreAdmin.vue @@ -7,11 +7,6 @@ - - { this.$emit('saved'); this.dialog = false; - this.loading = false; - this.alert = { - message: this.$t('exoplatform.perkstore.admin.settings.success'), - type: 'success' - }; + this.$root.$emit('alert-message', this.$t('exoplatform.perkstore.admin.settings.success'), 'success'); }) - .catch(e => { - console.error('Save settings error', e); - this.loading = false; - this.alert = { - message: this.$t('exoplatform.perkstore.admin.settings.error', {0: e && e.message ? e.message : String(e),}), - type: 'error' - }; - }); + .catch(() => this.$root.$emit('alert-message', this.$t('exoplatform.perkstore.admin.settings.error', 'error'))) + .finally(() => this.loading = false); }, }, }; diff --git a/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/main.js b/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/main.js index 88d67a58d..e1e612234 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/main.js +++ b/perk-store-webapps/src/main/webapp/vue-app/perk-store-admin/main.js @@ -25,13 +25,13 @@ const appId = 'PerkStoreAdminApp'; export function init() { exoi18n.loadLanguageAsync(lang, url).then(i18n => { // init Vue app when locale ressources are ready - new Vue({ + Vue.createApp({ mounted() { document.dispatchEvent(new CustomEvent('hideTopBarLoading')); }, template: ``, i18n, vuetify, - }).$mount(`#${appId}`); + }, `#${appId}`, 'Perks Administration'); }); } \ No newline at end of file diff --git a/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/components/PerkStoreOverview.vue b/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/components/PerkStoreOverview.vue index 836ae5837..54dbeddf1 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/components/PerkStoreOverview.vue +++ b/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/components/PerkStoreOverview.vue @@ -46,7 +46,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. :symbol="symbol" :need-password="walletNeedPassword" wallet-enabled /> - diff --git a/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/initComponents.js b/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/initComponents.js index 002e243a4..69331c9e5 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/initComponents.js +++ b/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/initComponents.js @@ -20,14 +20,12 @@ import PerkStoreOverview from './components/PerkStoreOverview.vue'; import ProductDetail from '../components/perk-store/ProductDetail.vue'; import BuyModal from '../components/perk-store/BuyModal.vue'; import BuyForm from '../components/perk-store/BuyForm.vue'; -import PerkStoreAlert from '../components/perk-store/PerkStoreAlert.vue'; const components = { 'perk-store-overview': PerkStoreOverview, 'perk-store-product-detail': ProductDetail, 'perk-store-buy-modal': BuyModal, 'perk-store-buy-form': BuyForm, - 'perk-store-alert': PerkStoreAlert, }; for (const key in components) { diff --git a/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/main.js b/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/main.js index f7a5c0897..2c7c32362 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/main.js +++ b/perk-store-webapps/src/main/webapp/vue-app/perk-store-overview/main.js @@ -31,11 +31,11 @@ const appId = 'PerkStoreOverviewApp'; export function init() { exoi18n.loadLanguageAsync(lang, url).then(i18n => { // init Vue app when locale ressources are ready - new Vue({ + Vue.createApp({ template: ``, i18n, vuetify, - }).$mount(`#${appId}`); + }, `#${appId}`, 'Perks Overview'); // get overrided components if exists extensions.registerPerkStoreOverview(); diff --git a/perk-store-webapps/src/main/webapp/vue-app/perk-store.js b/perk-store-webapps/src/main/webapp/vue-app/perk-store.js index 807573fd6..5527732fb 100644 --- a/perk-store-webapps/src/main/webapp/vue-app/perk-store.js +++ b/perk-store-webapps/src/main/webapp/vue-app/perk-store.js @@ -26,10 +26,10 @@ const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale export function init() { exoi18n.loadLanguageAsync(lang, url).then(i18n => { - new Vue({ + Vue.createApp({ render: (h) => h(PerkStoreApp), i18n, vuetify, - }).$mount('#PerkStoreApp'); + }, '#PerkStoreApp', 'Perks application'); }); }