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 From bfdad56b0d4b4f8ed89295661ff8abba22dca7f0 Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Thu, 21 Dec 2023 00:48:14 +0300 Subject: Make the frontend config work somewhat even without DB config --- src/components/settings_modal/admin_tabs/frontends_tab.js | 10 +++++++--- src/components/settings_modal/admin_tabs/frontends_tab.vue | 14 +++++++++----- src/components/settings_modal/helpers/setting.js | 3 ++- src/i18n/en.json | 1 + 4 files changed, 19 insertions(+), 9 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 8163af59..f57310ee 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.js +++ b/src/components/settings_modal/admin_tabs/frontends_tab.js @@ -55,9 +55,13 @@ const FrontendsTab = { 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 + if (this.adminDraft) { + const defaultFe = this.adminDraft[':pleroma'][':frontends'][':primary'] + if (defaultFe?.name === frontend.name && this.canInstall(defaultFe)) { + return defaultFe.ref + } else { + return frontend.refs[0] + } } else { return frontend.refs[0] } diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.vue b/src/components/settings_modal/admin_tabs/frontends_tab.vue index dd4c9790..097877bc 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.vue +++ b/src/components/settings_modal/admin_tabs/frontends_tab.vue @@ -6,7 +6,7 @@

    {{ $t('admin_dash.tabs.frontends') }}

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

    -
      +
      • {{ $t('admin_dash.frontend.default_frontend') }}

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

        @@ -23,6 +23,10 @@
    +
    + {{ $t('admin_dash.frontend.default_frontend_unavail') }} +
    +

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

    @@ -33,9 +37,9 @@ > {{ frontend.name }} {{ ' ' }} - + @@ -134,7 +138,7 @@ class="button button-default btn" type="button" :disabled=" - adminDraft[':pleroma'][':frontends'][':primary']?.name === frontend.name && + !adminDraft || adminDraft[':pleroma'][':frontends'][':primary']?.name === frontend.name && adminDraft[':pleroma'][':frontends'][':primary']?.ref === frontend.refs[0] " @click="setDefault(frontend)" diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index b3add346..abf9cfdf 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -195,7 +195,8 @@ export default { } }, canHardReset () { - return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.canonPath.join(' -> ')) + return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths && + this.$store.state.adminSettings.modifiedPaths.has(this.canonPath.join(' -> ')) }, matchesExpertLevel () { return (this.expert || 0) <= this.$store.state.config.expertLevel > 0 diff --git a/src/i18n/en.json b/src/i18n/en.json index 09ba7025..62316a3f 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -928,6 +928,7 @@ "wip_notice": "Please note that this section is a WIP and lacks certain features as backend implementation of front-end management is incomplete.", "default_frontend": "Default front-end", "default_frontend_tip": "Default front-end will be shown to all users. Currently there's no way to for a user to select personal front-end. If you switch away from PleromaFE you'll most likely have to use old and buggy AdminFE to do instance configuration until we replace it.", + "default_frontend_unavail": "Default frontend settings are not available, as this requires configuration in the database", "available_frontends": "Available for install", "failure_installing_frontend": "Failed to install frontend {version}: {reason}", "success_installing_frontend": "Frontend {version} successfully installed" -- cgit v1.2.3-70-g09d2