From f354cef01065ab3ff9b00e522ec6ae9b1aabcc97 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 1 Nov 2023 21:44:14 +0200 Subject: fix no feedback and no dropdown close for actions in frontends tab, better default suggest --- .../settings_modal/admin_tabs/frontends_tab.js | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src/components/settings_modal/admin_tabs/frontends_tab.js') diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.js b/src/components/settings_modal/admin_tabs/frontends_tab.js index a2c27c2a..57825a46 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.js +++ b/src/components/settings_modal/admin_tabs/frontends_tab.js @@ -42,18 +42,52 @@ const FrontendsTab = { ...SharedComputedObject() }, methods: { + canInstall (frontend) { + const fe = this.frontends.find(f => f.name === frontend.name) + if (!fe) return false + return fe.refs.includes(frontend.ref) + }, + getSuggestedRef (frontend) { + const defaultFe = this.adminDraft[':pleroma'][':frontends'][':primary'] + if (defaultFe.name === frontend.name && this.canInstall(defaultFe)) { + return defaultFe.ref + } else { + return frontend.refs[0] + } + }, update (frontend, suggestRef) { - const ref = suggestRef || frontend.refs[0] + const ref = suggestRef || this.getSuggestedRef(frontend) const { name } = frontend const payload = { name, ref } this.$store.state.api.backendInteractor.installFrontend({ payload }) - .then((externalUser) => { + .then(async (response) => { this.$store.dispatch('loadFrontendsStuff') + if (response.error) { + const reason = await response.error.json() + this.$store.dispatch('pushGlobalNotice', { + level: 'error', + messageKey: 'admin_dash.frontend.failure_installing_frontend', + messageArgs: { + version: name + '/' + ref, + reason: reason.error + }, + timeout: 5000 + }) + } else { + this.$store.dispatch('pushGlobalNotice', { + level: 'success', + messageKey: 'admin_dash.frontend.success_installing_frontend', + messageArgs: { + version: name + '/' + ref + }, + timeout: 2000 + }) + } }) }, setDefault (frontend, suggestRef) { - const ref = suggestRef || frontend.refs[0] + const ref = suggestRef || this.getSuggestedRef(frontend) const { name } = frontend this.$store.commit('updateAdminDraft', { path: [':pleroma', ':frontends', ':primary'], value: { name, ref } }) -- cgit v1.2.3-70-g09d2 From b6a4b62058ca8e6a1a0f91aa23cf3cd78cd33009 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 1 Nov 2023 21:53:50 +0200 Subject: add better indication that stuff is happening --- .../settings_modal/admin_tabs/frontends_tab.js | 11 +++++++++++ .../settings_modal/admin_tabs/frontends_tab.scss | 16 ++++++++++++++++ .../settings_modal/admin_tabs/frontends_tab.vue | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/components/settings_modal/admin_tabs/frontends_tab.js') diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.js b/src/components/settings_modal/admin_tabs/frontends_tab.js index 57825a46..57af2c27 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.js +++ b/src/components/settings_modal/admin_tabs/frontends_tab.js @@ -4,6 +4,7 @@ import IntegerSetting from '../helpers/integer_setting.vue' import StringSetting from '../helpers/string_setting.vue' import GroupSetting from '../helpers/group_setting.vue' import Popover from 'src/components/popover/popover.vue' +import PanelLoading from 'src/components/panel_loading/panel_loading.vue' import SharedComputedObject from '../helpers/shared_computed_object.js' import { library } from '@fortawesome/fontawesome-svg-core' @@ -22,12 +23,18 @@ const FrontendsTab = { defaultSource: 'admin' } }, + data () { + return { + working: false + } + }, components: { BooleanSetting, ChoiceSetting, IntegerSetting, StringSetting, GroupSetting, + PanelLoading, Popover }, created () { @@ -60,7 +67,11 @@ const FrontendsTab = { const { name } = frontend const payload = { name, ref } + this.working = true this.$store.state.api.backendInteractor.installFrontend({ payload }) + .finally(() => { + this.working = false + }) .then(async (response) => { this.$store.dispatch('loadFrontendsStuff') if (response.error) { diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.scss b/src/components/settings_modal/admin_tabs/frontends_tab.scss index e3e04bc6..420d20b3 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.scss +++ b/src/components/settings_modal/admin_tabs/frontends_tab.scss @@ -3,6 +3,22 @@ padding: 0; } + .relative { + position: relative; + } + + .overlay { + position: absolute; + background: var(--bg); + // fix buttons showing through + z-index: 2; + opacity: 0.9; + top: 0; + bottom: 0; + left: 0; + right: 0; + } + dd { text-overflow: ellipsis; word-wrap: nowrap; diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.vue b/src/components/settings_modal/admin_tabs/frontends_tab.vue index 3b8d0eab..08e621fa 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.vue +++ b/src/components/settings_modal/admin_tabs/frontends_tab.vue @@ -24,7 +24,8 @@ -
+
+

{{ $t('admin_dash.frontend.available_frontends') }}

  • Date: Mon, 13 Nov 2023 17:31:12 +0200 Subject: account for if there's no primary frontend setup --- src/components/settings_modal/admin_tabs/frontends_tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/settings_modal/admin_tabs/frontends_tab.js') diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.js b/src/components/settings_modal/admin_tabs/frontends_tab.js index 57af2c27..8163af59 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.js +++ b/src/components/settings_modal/admin_tabs/frontends_tab.js @@ -56,7 +56,7 @@ const FrontendsTab = { }, getSuggestedRef (frontend) { const defaultFe = this.adminDraft[':pleroma'][':frontends'][':primary'] - if (defaultFe.name === frontend.name && this.canInstall(defaultFe)) { + if (defaultFe?.name === frontend.name && this.canInstall(defaultFe)) { return defaultFe.ref } else { return frontend.refs[0] -- cgit v1.2.3-70-g09d2