From 37a83eeab9f8edc7d83e8fc18860365d7074d73f Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sat, 8 Jan 2022 00:15:55 +0100 Subject: [PATCH 1/3] Manage default application using DomainConfig --- app/src/helpers/yunohostArguments.js | 2 +- app/src/store/data.js | 20 ++++++++++++++++++++ app/src/views/domain/DomainConfig.vue | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/helpers/yunohostArguments.js b/app/src/helpers/yunohostArguments.js index 0fc02bbd..3ac6453b 100644 --- a/app/src/helpers/yunohostArguments.js +++ b/app/src/helpers/yunohostArguments.js @@ -115,7 +115,7 @@ export function formatYunoHostArgument (arg) { props: ['id:name', 'choices'] }, { - types: ['user', 'domain'], + types: ['user', 'domain', 'app'], name: 'SelectItem', props: ['id:name', 'choices'], callback: function () { diff --git a/app/src/store/data.js b/app/src/store/data.js index df2255f4..8f5ae10a 100644 --- a/app/src/store/data.js +++ b/app/src/store/data.js @@ -11,6 +11,7 @@ export default { users: undefined, // basic user data: Object {username: {data}} users_details: {}, // precise user data: Object {username: {data}} groups: undefined, + apps: undefined, permissions: undefined }), @@ -44,6 +45,15 @@ export default { Vue.set(state.users, user.username, user) }, + 'SET_APPS' (state, [apps]) { + state.apps = apps || null + }, + + 'ADD_APPS' (state, [app]) { + if (!state.apps) state.apps = {} + Vue.set(state.apps, app.id, app) + }, + 'SET_USERS_DETAILS' (state, [username, userData]) { Vue.set(state.users_details, username, userData) if (!state.users) return @@ -185,6 +195,16 @@ export default { mainDomain: state => state.main_domain, + appsAsChoices: state => { + const choices = [{ value: "_none", text: "---" }] + if (state.apps) { + return choices.concat(Object.values(state.apps).map(({ id, name, domain_path }) => { + return { value: id, text: `${name} (${domain_path})` } + })) + } + return choices + }, + domainsAsChoices: state => { const mainDomain = state.main_domain return state.domains.map(domain => { diff --git a/app/src/views/domain/DomainConfig.vue b/app/src/views/domain/DomainConfig.vue index fdf670f8..22e24675 100644 --- a/app/src/views/domain/DomainConfig.vue +++ b/app/src/views/domain/DomainConfig.vue @@ -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, From 91a470d2aad83b7b94aaad3dba7c68f636f26d4f Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Wed, 12 Jan 2022 19:47:07 +0100 Subject: [PATCH 2/3] [enh] Add a Reverse makedefault button --- app/src/views/app/AppInfo.vue | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/views/app/AppInfo.vue b/app/src/views/app/AppInfo.vue index 3aba2d31..e86cbbc0 100644 --- a/app/src/views/app/AppInfo.vue +++ b/app/src/views/app/AppInfo.vue @@ -101,15 +101,23 @@
- + - - {{ $t('app_make_default') }} - + + +
@@ -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) From 9f704e7f75f6ad29c1c155f92da5fade2d24f2b3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 24 Jan 2022 18:30:18 +0100 Subject: [PATCH 3/3] Cleanup unused code, app choices to be handled by the core --- app/src/store/data.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/app/src/store/data.js b/app/src/store/data.js index 58984423..50e39b48 100644 --- a/app/src/store/data.js +++ b/app/src/store/data.js @@ -11,7 +11,6 @@ export default { users: undefined, // basic user data: Object {username: {data}} users_details: {}, // precise user data: Object {username: {data}} groups: undefined, - apps: undefined, permissions: undefined }), @@ -45,15 +44,6 @@ export default { Vue.set(state.users, user.username, user) }, - 'SET_APPS' (state, [apps]) { - state.apps = apps || null - }, - - 'ADD_APPS' (state, [app]) { - if (!state.apps) state.apps = {} - Vue.set(state.apps, app.id, app) - }, - 'SET_USERS_DETAILS' (state, [username, userData]) { Vue.set(state.users_details, username, userData) if (!state.users) return @@ -186,16 +176,6 @@ export default { mainDomain: state => state.main_domain, - appsAsChoices: state => { - const choices = [{ value: "_none", text: "---" }] - if (state.apps) { - return choices.concat(Object.values(state.apps).map(({ id, name, domain_path }) => { - return { value: id, text: `${name} (${domain_path})` } - })) - } - return choices - }, - domainsAsChoices: state => { const mainDomain = state.main_domain return state.domains.map(domain => {