|
@@ -4,6 +4,7 @@ import IntegerSetting from '../helpers/integer_setting.vue'
|
|
import StringSetting from '../helpers/string_setting.vue'
|
|
import StringSetting from '../helpers/string_setting.vue'
|
|
import GroupSetting from '../helpers/group_setting.vue'
|
|
import GroupSetting from '../helpers/group_setting.vue'
|
|
import Popover from 'src/components/popover/popover.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 SharedComputedObject from '../helpers/shared_computed_object.js'
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
@@ -22,12 +23,18 @@ const FrontendsTab = {
|
|
defaultSource: 'admin'
|
|
defaultSource: 'admin'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ data () {
|
|
|
|
+ return {
|
|
|
|
+ working: false
|
|
|
|
+ }
|
|
|
|
+ },
|
|
components: {
|
|
components: {
|
|
BooleanSetting,
|
|
BooleanSetting,
|
|
ChoiceSetting,
|
|
ChoiceSetting,
|
|
IntegerSetting,
|
|
IntegerSetting,
|
|
StringSetting,
|
|
StringSetting,
|
|
GroupSetting,
|
|
GroupSetting,
|
|
|
|
+ PanelLoading,
|
|
Popover
|
|
Popover
|
|
},
|
|
},
|
|
created () {
|
|
created () {
|
|
@@ -42,18 +49,56 @@ const FrontendsTab = {
|
|
...SharedComputedObject()
|
|
...SharedComputedObject()
|
|
},
|
|
},
|
|
methods: {
|
|
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) {
|
|
update (frontend, suggestRef) {
|
|
- const ref = suggestRef || frontend.refs[0]
|
|
|
|
|
|
+ const ref = suggestRef || this.getSuggestedRef(frontend)
|
|
const { name } = frontend
|
|
const { name } = frontend
|
|
const payload = { name, ref }
|
|
const payload = { name, ref }
|
|
|
|
|
|
|
|
+ this.working = true
|
|
this.$store.state.api.backendInteractor.installFrontend({ payload })
|
|
this.$store.state.api.backendInteractor.installFrontend({ payload })
|
|
- .then((externalUser) => {
|
|
|
|
|
|
+ .finally(() => {
|
|
|
|
+ this.working = false
|
|
|
|
+ })
|
|
|
|
+ .then(async (response) => {
|
|
this.$store.dispatch('loadFrontendsStuff')
|
|
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) {
|
|
setDefault (frontend, suggestRef) {
|
|
- const ref = suggestRef || frontend.refs[0]
|
|
|
|
|
|
+ const ref = suggestRef || this.getSuggestedRef(frontend)
|
|
const { name } = frontend
|
|
const { name } = frontend
|
|
|
|
|
|
this.$store.commit('updateAdminDraft', { path: [':pleroma', ':frontends', ':primary'], value: { name, ref } })
|
|
this.$store.commit('updateAdminDraft', { path: [':pleroma', ':frontends', ':primary'], value: { name, ref } })
|