From 757cb786ed611880b49e6ec41c3695575f53ab5e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 4 Jan 2023 20:23:52 +0100 Subject: [PATCH] appv2: implement dismiss logic for app notifications --- app/src/i18n/locales/en.json | 1 + app/src/views/app/AppInfo.vue | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index 96c85ec1..f1a5156c 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -390,6 +390,7 @@ "change_url": "Change access URL of '{name}'", "install": "Install app '{name}'", "set_default": "Redirect '{domain}' domain root to '{name}'", + "dismiss_notification": "Dismiss notification for '{name}'", "uninstall": "Uninstall app '{name}'", "update_config": "Update panel '{id}' of app '{name}' configuration" }, diff --git a/app/src/views/app/AppInfo.vue b/app/src/views/app/AppInfo.vue index bf5efa5e..5dd373d7 100644 --- a/app/src/views/app/AppInfo.vue +++ b/app/src/views/app/AppInfo.vue @@ -9,7 +9,7 @@ variant="primary" size="sm" class="ml-auto mr-2" - @click="dismiss" + @click="dismissNotification($event, 'post_install')" > {{ $t('app.doc.notifications.dismiss') }} @@ -31,7 +31,7 @@ variant="primary" size="sm" class="ml-auto mr-2" - @click="dismiss" + @click="dismissNotification($event, 'post_upgrade')" > {{ $t('app.doc.notifications.dismiss') }} @@ -404,10 +404,10 @@ export default { ].filter(([key, val]) => !!val), doc: { notifications: { - postInstall: notifs.POST_INSTALL.main ? [['main', formatI18nField(notifs.POST_INSTALL.main)]] : [], - postUpgrade: Object.entries(notifs.POST_UPGRADE).map(([key, content]) => { + postInstall: notifs.POST_INSTALL && notifs.POST_INSTALL.main ? [['main', formatI18nField(notifs.POST_INSTALL.main)]] : [], + postUpgrade: notifs.POST_UPGRADE ? Object.entries(notifs.POST_UPGRADE).map(([key, content]) => { return [key, formatI18nField(content)] - }) + }) : [] }, admin: [ formatI18nField(ADMIN), @@ -485,6 +485,14 @@ export default { ).then(this.$refs.view.fetchQueries) }, + async dismissNotification (event, name = false) { + api.put( + `apps/${this.id}/dismiss_notification/${name}`, + {}, + { key: 'apps.dismiss_notification', name: this.app.label } + ).then(this.$refs.view.fetchQueries) + }, + async uninstall () { const confirmed = await this.$askConfirmation( this.$i18n.t('confirm_uninstall', { name: this.id })