mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
AppInfo: properly display config panel init error without blocking the app info page
This commit is contained in:
parent
057a33e8bf
commit
3fbf4cfdeb
3 changed files with 33 additions and 12 deletions
|
@ -28,6 +28,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
_icon () {
|
_icon () {
|
||||||
|
if (this.icon) return this.icon
|
||||||
return DEFAULT_STATUS_ICON[this.variant]
|
return DEFAULT_STATUS_ICON[this.variant]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"forum": "Search or ask the forum!",
|
"forum": "Search or ask the forum!",
|
||||||
"problem": "A problem with this app?"
|
"problem": "A problem with this app?",
|
||||||
|
"config_panel_error": "An error prevents the configuration panel from being displayed:"
|
||||||
},
|
},
|
||||||
"install": {
|
"install": {
|
||||||
"license": "License: {license}",
|
"license": "License: {license}",
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<view-base :queries="queries" @queries-response="onQueriesResponse" ref="view">
|
<view-base
|
||||||
|
:queries="queries" @queries-response="onQueriesResponse" :loading="loading"
|
||||||
|
ref="view"
|
||||||
|
>
|
||||||
<yuno-alert v-if="app && app.doc && app.doc.notifications && app.doc.notifications.postInstall.length" variant="info" class="my-4">
|
<yuno-alert v-if="app && app.doc && app.doc.notifications && app.doc.notifications.postInstall.length" variant="info" class="my-4">
|
||||||
<div class="d-md-flex align-items-center mb-3">
|
<div class="d-md-flex align-items-center mb-3">
|
||||||
<h2 v-t="'app.doc.notifications.post_install'" class="md-m-0" />
|
<h2 v-t="'app.doc.notifications.post_install'" class="md-m-0" />
|
||||||
|
@ -89,6 +92,14 @@
|
||||||
<vue-showdown :markdown="app.description" flavor="github" />
|
<vue-showdown :markdown="app.description" flavor="github" />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<yuno-alert
|
||||||
|
v-if="config_panel_err"
|
||||||
|
class="mb-4" variant="danger" icon="bug"
|
||||||
|
>
|
||||||
|
<p>{{ $t('app.info.config_panel_error') }}</p>
|
||||||
|
<p>{{ config_panel_err }}</p>
|
||||||
|
</yuno-alert>
|
||||||
|
|
||||||
<!-- BASIC INFOS -->
|
<!-- BASIC INFOS -->
|
||||||
<config-panels v-bind="config" @submit="onConfigSubmit">
|
<config-panels v-bind="config" @submit="onConfigSubmit">
|
||||||
<!-- OPERATIONS TAB -->
|
<!-- OPERATIONS TAB -->
|
||||||
|
@ -289,11 +300,12 @@ export default {
|
||||||
queries: [
|
queries: [
|
||||||
['GET', `apps/${this.id}?full`],
|
['GET', `apps/${this.id}?full`],
|
||||||
['GET', { uri: 'users/permissions?full', storeKey: 'permissions' }],
|
['GET', { uri: 'users/permissions?full', storeKey: 'permissions' }],
|
||||||
['GET', { uri: 'domains' }],
|
['GET', { uri: 'domains' }]
|
||||||
['GET', `apps/${this.id}/config?full`]
|
|
||||||
],
|
],
|
||||||
|
loading: true,
|
||||||
app: undefined,
|
app: undefined,
|
||||||
form: undefined,
|
form: undefined,
|
||||||
|
config_panel_err: null,
|
||||||
config: {
|
config: {
|
||||||
panels: [
|
panels: [
|
||||||
// Fake integration of operations in config panels
|
// Fake integration of operations in config panels
|
||||||
|
@ -346,14 +358,8 @@ export default {
|
||||||
}
|
}
|
||||||
return linksIcons[linkType]
|
return linksIcons[linkType]
|
||||||
},
|
},
|
||||||
onQueriesResponse (app, _, __, config) {
|
|
||||||
if (app.supports_config_panel) {
|
|
||||||
const config_ = formatYunoHostConfigPanels(config)
|
|
||||||
// reinject 'operations' fake config tab
|
|
||||||
config_.panels.unshift(this.config.panels[0])
|
|
||||||
this.config = config_
|
|
||||||
}
|
|
||||||
|
|
||||||
|
async onQueriesResponse (app) {
|
||||||
const form = { labels: [] }
|
const form = { labels: [] }
|
||||||
|
|
||||||
const mainPermission = app.permissions[this.id + '.main']
|
const mainPermission = app.permissions[this.id + '.main']
|
||||||
|
@ -430,6 +436,18 @@ export default {
|
||||||
if (!Object.values(this.app.doc.notifications).some((notif) => notif.length)) {
|
if (!Object.values(this.app.doc.notifications).some((notif) => notif.length)) {
|
||||||
this.app.doc.notifications = null
|
this.app.doc.notifications = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (app.supports_config_panel) {
|
||||||
|
await api.get(`apps/${this.id}/config?full`).then((config) => {
|
||||||
|
const config_ = formatYunoHostConfigPanels(config)
|
||||||
|
// reinject 'operations' fake config tab
|
||||||
|
config_.panels.unshift(this.config.panels[0])
|
||||||
|
this.config = config_
|
||||||
|
}).catch((err) => {
|
||||||
|
this.config_panel_err = err.message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.loading = false
|
||||||
},
|
},
|
||||||
|
|
||||||
async onConfigSubmit ({ id, form, action, name }) {
|
async onConfigSubmit ({ id, form, action, name }) {
|
||||||
|
@ -442,7 +460,8 @@ export default {
|
||||||
isEmptyValue(args) ? {} : { args: objectToParams(args) },
|
isEmptyValue(args) ? {} : { args: objectToParams(args) },
|
||||||
{ key: `apps.${action ? 'action' : 'update'}_config`, id, name: this.id }
|
{ key: `apps.${action ? 'action' : 'update'}_config`, id, name: this.id }
|
||||||
).then(() => {
|
).then(() => {
|
||||||
this.$refs.view.fetchQueries({ triggerLoading: true })
|
this.loading = true
|
||||||
|
this.$refs.view.fetchQueries()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.name !== 'APIBadRequestError') throw err
|
if (err.name !== 'APIBadRequestError') throw err
|
||||||
const panel = this.config.panels.find(panel => panel.id === id)
|
const panel = this.config.panels.find(panel => panel.id === id)
|
||||||
|
|
Loading…
Reference in a new issue