From 127b21b493323034eff6944c0ec7a808529e7529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 29 May 2018 22:40:31 +0200 Subject: [PATCH] Implement app bundle management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- settings/src/components/appList.vue | 32 ++++++++++++++++++++++++++++- settings/src/store/apps.js | 28 ++++++++++++++++++------- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/settings/src/components/appList.vue b/settings/src/components/appList.vue index 78e6cdb5ad..36980f5708 100644 --- a/settings/src/components/appList.vue +++ b/settings/src/components/appList.vue @@ -113,10 +113,40 @@ export default { }, useBundleView() { return (this.category === 'app-bundles'); + }, + allBundlesEnabled() { + return function(id) { + console.log(this.bundleApps(id).filter(app => !app.active)); + return this.bundleApps(id).filter(app => !app.active).length === 0; + } + }, + bundleToggleText() { + return function(id) { + if (this.allBundlesEnabled(id)) { + return t('settings', 'Disable all'); + } + return t('settings', 'Enable all'); + } } }, methods: { - + toggleBundle(id) { + if (this.allBundlesEnabled) { + return this.disableBundle(id); + } + return this.enableBundle(id); + }, + enableBundle(id) { + let apps = this.bundleApps(id).map(app => app.id); + console.log(apps); + this.$store.dispatch('enableApp', { appId: apps, groups: [] }) + .catch((error) => { console.log(error); OC.Notification.show(error)}); + }, + disableBundle(id) { + let apps = this.bundleApps(id).map(app => app.id); + this.$store.dispatch('disableApp', { appId: apps, groups: [] }) + .catch((error) => { OC.Notification.show(error)}); + } }, } diff --git a/settings/src/store/apps.js b/settings/src/store/apps.js index 5d935f5929..09bc00a396 100644 --- a/settings/src/store/apps.js +++ b/settings/src/store/apps.js @@ -138,28 +138,42 @@ const getters = { const actions = { enableApp(context, { appId, groups }) { + let apps; + if (Array.isArray(appId)) { + apps = appId; + } else { + apps = [appId]; + } return api.requireAdmin().then((response) => { - return api.post(OC.generateUrl(`settings/apps/enable/${appId}`), { - groups: groups - }) + return api.post(OC.generateUrl(`settings/apps/enable`), {appIds: apps, groups: groups}) .then((response) => { - context.commit('enableApp', {appId: appId, groups: groups}); + apps.forEach(_appId => { + context.commit('enableApp', {appId: _appId, groups: groups}); + }); return true; }) .catch((error) => context.commit('APPS_API_FAILURE', { appId, error })) }).catch((error) => context.commit('API_FAILURE', { appId, error })); - }, disableApp(context, { appId }) { + let apps; + if (Array.isArray(appId)) { + apps = appId; + } else { + apps = [appId]; + } return api.requireAdmin().then((response) => { - return api.get(OC.generateUrl(`settings/apps/disable/${appId}`)) + return api.post(OC.generateUrl(`settings/apps/disable`), {appIds: apps}) .then((response) => { - context.commit('disableApp', appId); + apps.forEach(_appId => { + context.commit('disableApp', _appId); + }); return true; }) .catch((error) => context.commit('APPS_API_FAILURE', { appId, error })) }).catch((error) => context.commit('API_FAILURE', { appId, error })); }, + // TODO: use enable app installApp(context, { appId }) { return api.requireAdmin().then((response) => { return api.get(OC.generateUrl(`settings/apps/enable/${appId}`))