diff options
Diffstat (limited to 'src/components/settings_modal/admin_tabs')
4 files changed, 90 insertions, 13 deletions
diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.js b/src/components/settings_modal/admin_tabs/frontends_tab.js index a2c27c2a..8163af59 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 () { @@ -42,18 +49,56 @@ 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.working = true this.$store.state.api.backendInteractor.installFrontend({ payload }) - .then((externalUser) => { + .finally(() => { + this.working = false + }) + .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 } }) 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 25b08eb7..dd4c9790 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.vue +++ b/src/components/settings_modal/admin_tabs/frontends_tab.vue @@ -10,7 +10,6 @@ <li> <h3>{{ $t('admin_dash.frontend.default_frontend') }}</h3> <p>{{ $t('admin_dash.frontend.default_frontend_tip') }}</p> - <p>{{ $t('admin_dash.frontend.default_frontend_tip2') }}</p> <ul class="setting-list"> <li> <StringSetting path=":pleroma.:frontends.:primary.name" /> @@ -24,7 +23,8 @@ </ul> </li> </ul> - <div class="setting-list"> + <div class="setting-list relative"> + <PanelLoading class="overlay" v-if="working"/> <h3>{{ $t('admin_dash.frontend.available_frontends') }}</h3> <ul class="cards-list"> <li @@ -86,6 +86,11 @@ ? $t('admin_dash.frontend.reinstall') : $t('admin_dash.frontend.install') }} + <code> + {{ + getSuggestedRef(frontend) + }} + </code> </button> <Popover v-if="frontend.refs.length > 1" @@ -93,13 +98,14 @@ class="button-dropdown" placement="bottom" > - <template #content> + <template #content="{close}"> <div class="dropdown-menu"> <button v-for="ref in frontend.refs" :key="ref" class="button-default dropdown-item" - @click="update(frontend, ref)" + @click.prevent="update(frontend, ref)" + @click="close" > <i18n-t keypath="admin_dash.frontend.install_version"> <template #version> @@ -128,14 +134,19 @@ class="button button-default btn" type="button" :disabled=" - adminDraft[':pleroma'][':frontends'][':primary'].name === frontend.name && - adminDraft[':pleroma'][':frontends'][':primary'].ref === frontend.refs[0] + adminDraft[':pleroma'][':frontends'][':primary']?.name === frontend.name && + adminDraft[':pleroma'][':frontends'][':primary']?.ref === frontend.refs[0] " @click="setDefault(frontend)" > {{ $t('admin_dash.frontend.set_default') }} + <code> + {{ + getSuggestedRef(frontend) + }} + </code> </button> {{ ' ' }} <Popover @@ -144,13 +155,14 @@ class="button-dropdown" placement="bottom" > - <template #content> + <template #content="{close}"> <div class="dropdown-menu"> <button - v-for="ref in frontend.refs.slice(1)" + v-for="ref in frontend.installedRefs || frontend.refs" :key="ref" class="button-default dropdown-item" - @click="setDefault(frontend, ref)" + @click.prevent="setDefault(frontend, ref)" + @click="close" > <i18n-t keypath="admin_dash.frontend.set_default_version"> <template #version> diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue index a6be776b..a0e3351e 100644 --- a/src/components/settings_modal/admin_tabs/instance_tab.vue +++ b/src/components/settings_modal/admin_tabs/instance_tab.vue @@ -6,6 +6,10 @@ <li> <StringSetting path=":pleroma.:instance.:name" /> </li> + <!-- See https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3963 --> + <li v-if="adminDraft[':pleroma'][':instance'][':favicon'] !== undefined"> + <AttachmentSetting compact path=":pleroma.:instance.:favicon" /> + </li> <li> <StringSetting path=":pleroma.:instance.:email" /> </li> @@ -16,7 +20,7 @@ <StringSetting path=":pleroma.:instance.:short_description" /> </li> <li> - <AttachmentSetting path=":pleroma.:instance.:instance_thumbnail" /> + <AttachmentSetting compact path=":pleroma.:instance.:instance_thumbnail" /> </li> <li> <AttachmentSetting path=":pleroma.:instance.:background_image" /> |
