Merge pull request #422 from Tagadda/enh-domain-default-app

Manage default application using DomainConfig
This commit is contained in:
Alexandre Aubin 2022-01-24 18:49:34 +01:00 committed by GitHub
commit 975acaadab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

View file

@ -110,11 +110,11 @@ export function formatYunoHostArgument (arg) {
}
},
{
types: ['select', 'user', 'domain'],
types: ['select', 'user', 'domain', 'app'],
name: 'SelectItem',
props: ['id:name', 'choices'],
callback: function () {
if ((arg.type === 'domain') || (arg.type === 'user')) {
if ((arg.type !== 'select')) {
field.link = { name: arg.type + '-list', text: i18n.t(`manage_${arg.type}s`) }
}
}

View file

@ -101,15 +101,23 @@
</b-form-group>
<hr v-if="app.is_webapp">
<!-- CHANGE DOMAIN -->
<!-- MAKE DEFAULT -->
<b-form-group
:label="$t('app_info_default_desc', { domain: app.domain })" label-for="main-domain"
label-class="font-weight-bold" label-cols-md="4"
v-if="app.is_webapp"
>
<b-button @click="setAsDefaultDomain" id="main-domain" variant="success">
<icon iname="star" /> {{ $t('app_make_default') }}
</b-button>
<template v-if="!app.is_default">
<b-button @click="setAsDefaultDomain($event, false)" id="main-domain" variant="success">
<icon iname="star" /> {{ $t('app_make_default') }}
</b-button>
</template>
<template v-else>
<b-button @click="setAsDefaultDomain($event, true)" id="main-domain" variant="warning">
<icon iname="star" /> {{ $t('app_make_not_default') }}
</b-button>
</template>
</b-form-group>
<hr v-if="app.is_webapp">
@ -250,10 +258,14 @@ export default {
this.app = {
domain: app.settings.domain,
is_webapp: app.is_webapp,
is_default: app.is_default,
supports_change_url: app.supports_change_url,
supports_config_panel: app.supports_config_panel,
permissions
}
if (this.app.is_webapp) {
this.app.is_default = app.is_default
}
},
changeLabel (permName, data) {
@ -277,12 +289,12 @@ export default {
).then(this.$refs.view.fetchQueries)
},
async setAsDefaultDomain () {
async setAsDefaultDomain (event, undo = false) {
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_app_default'))
if (!confirmed) return
api.put(
`apps/${this.id}/default`,
`apps/${this.id}/default${undo ? '?undo' : ''}`,
{},
{ key: 'apps.set_default', name: this.infos.label, domain: this.app.domain }
).then(this.$refs.view.fetchQueries)

View file

@ -58,7 +58,8 @@ export default {
data () {
return {
queries: [
['GET', `domains/${this.name}/config?full`]
['GET', `domains/${this.name}/config?full`],
['GET', { uri: 'apps', storeKey: 'apps' }]
],
panels: undefined,
forms: undefined,