From 04c524c8ae2d755681562dd0de60dce8ada889f5 Mon Sep 17 00:00:00 2001 From: zak39 Date: Tue, 28 Dec 2021 17:26:51 +0100 Subject: [PATCH 01/35] feat(Vue): Get groupfolders aren't spaces The idea is to have a button 'Settings & Import / Convert' and select the groupfolders to import / convert. The SelectGroupfolders component is created to be in a modal and select the groupfolders to convert / import --- src/Home.vue | 23 +++++++ src/SelectGroupfolders.vue | 125 +++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 src/SelectGroupfolders.vue diff --git a/src/Home.vue b/src/Home.vue index 1475ac5e..0a05d2d0 100644 --- a/src/Home.vue +++ b/src/Home.vue @@ -28,6 +28,11 @@ class="notifications" close-on-click="true" /> + + + + @@ -83,10 +92,13 @@ import AppNavigation from '@nextcloud/vue/dist/Components/AppNavigation' import AppNavigationIconBullet from '@nextcloud/vue/dist/Components/AppNavigationIconBullet' import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem' import AppNavigationNewItem from '@nextcloud/vue/dist/Components/AppNavigationNewItem' +import Modal from '@nextcloud/vue/dist/Components/Modal' +import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import Content from '@nextcloud/vue/dist/Components/Content' import { generateUrl } from '@nextcloud/router' import { getLocale } from '@nextcloud/l10n' import { get, formatGroups, create, formatUsers } from './services/groupfoldersService' +import SelectGroupfolders from './SelectGroupfolders' export default { name: 'Home', @@ -96,8 +108,16 @@ export default { AppNavigation, AppNavigationIconBullet, AppNavigationItem, + ActionButton, AppNavigationNewItem, Content, + Modal, + SelectGroupfolders, + }, + data() { + return { + showSelectGroupfoldersModal: false, + } }, beforeCreate() { if (this.$root.$data.canAccessApp === 'false') { @@ -321,6 +341,9 @@ export default { return groups }, + toggleShowSelectGroupfoldersModal() { + this.showSelectGroupfoldersModal = !this.showSelectGroupfoldersModal + }, }, } diff --git a/src/SelectGroupfolders.vue b/src/SelectGroupfolders.vue new file mode 100644 index 00000000..80728dff --- /dev/null +++ b/src/SelectGroupfolders.vue @@ -0,0 +1,125 @@ + + + + + + + From 3e4997b788916d95fe29b8a0afac16b9506bdc2d Mon Sep 17 00:00:00 2001 From: zak39 Date: Wed, 29 Dec 2021 09:49:54 +0100 Subject: [PATCH 02/35] feat(Vue): Add groupfolders which aren't space in the groupfolders var from the store With the groupfolders var from the store, I will print in the SelectGroupfolders modal --- src/SelectGroupfolders.vue | 23 +++++++++++------------ src/store/actions.js | 3 +++ src/store/index.js | 1 + src/store/mutations.js | 3 +++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/SelectGroupfolders.vue b/src/SelectGroupfolders.vue index 80728dff..49b8bce2 100644 --- a/src/SelectGroupfolders.vue +++ b/src/SelectGroupfolders.vue @@ -40,24 +40,23 @@ export default { }, data() { return { - groupfolders: [], } }, created() { - console.debug('Hey !') - console.debug('Before this.groupfolders', this.groupfolders) this.getGroupfolders() .then(resultat => { - console.debug('resultat', resultat) - // TODO: update from store - this.groupfolders = resultat + resultat.forEach(groupfolder => { + this.$store.dispatch('updateGroupfolders', { + groupfolder, + }) + }) }) .catch(error => { console.error('Error to get groupfolders to convert in space', error) }) - console.debug('After this.groupfolders', this.groupfolders) }, methods: { + // get groupfolders whithout spaces. async getGroupfolders() { const groupfolders = await getAll() .then(resp => { @@ -82,15 +81,15 @@ export default { const groupfoldersKey = Object.keys(groupfolders) // Get the difference between spaces and groupfolders to get groupfoders which aren't spaces - const groupfoldersKeysNotSpace = groupfoldersKey.filter(groupfolderKey => !groupfoldersIdFromSpaces.includes(groupfolderKey)) + const groupfoldersKeysWhithoutSpace = groupfoldersKey.filter(groupfolderKey => !groupfoldersIdFromSpaces.includes(groupfolderKey)) // Build a Groupfolders' array - const groupfoldersNotSpace = [] - for (const key of groupfoldersKeysNotSpace) { - groupfoldersNotSpace.push(groupfolders[key]) + const groupfoldersWhithoutSpace = [] + for (const key of groupfoldersKeysWhithoutSpace) { + groupfoldersWhithoutSpace.push(groupfolders[key]) } - return groupfoldersNotSpace + return groupfoldersWhithoutSpace }, }, } diff --git a/src/store/actions.js b/src/store/actions.js index 493614d1..6c4c4773 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -353,4 +353,7 @@ export default { updateColor(context, { name, colorCode }) { context.commit('UPDATE_COLOR', { name, colorCode }) }, + updateGroupfolders(context, { groupfolder }) { + context.commit('UPDATE_GROUPFOLDERS', { groupfolder }) + }, } diff --git a/src/store/index.js b/src/store/index.js index 18410b45..8573f4cd 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -34,6 +34,7 @@ const store = new Store({ state: { loading: true, spaces: {}, + groupfolders: [], }, mutations, actions, diff --git a/src/store/mutations.js b/src/store/mutations.js index a3f9e1a0..9c471aed 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -158,4 +158,7 @@ export default { space.color = colorCode Vue.set(state.spaces, name, space) }, + UPDATE_GROUPFOLDERS(state, { groupfolder }) { + state.groupfolders.push(groupfolder) + }, } From a222641ef5a8c07f47e3d6c59794b41b27e7323b Mon Sep 17 00:00:00 2001 From: zak39 Date: Wed, 29 Dec 2021 14:49:32 +0100 Subject: [PATCH 03/35] feat(Vue): Fill and Empy the groupfolders list in SelectGroupfolders Fill the groupfolders list in SelectGroupfolders list when the general manager open the modal. Then, empty this list when the general manager close this modal window --- src/Home.vue | 1 + src/SelectGroupfolders.vue | 80 ++++++++++++++++++++++++++++++++++++++ src/store/actions.js | 3 ++ src/store/index.js | 2 +- src/store/mutations.js | 5 ++- 5 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/Home.vue b/src/Home.vue index 0a05d2d0..d6bea4c6 100644 --- a/src/Home.vue +++ b/src/Home.vue @@ -342,6 +342,7 @@ export default { return groups }, toggleShowSelectGroupfoldersModal() { + this.$store.dispatch('emptyGroupfolders') this.showSelectGroupfoldersModal = !this.showSelectGroupfoldersModal }, }, diff --git a/src/SelectGroupfolders.vue b/src/SelectGroupfolders.vue index 49b8bce2..1cc53376 100644 --- a/src/SelectGroupfolders.vue +++ b/src/SelectGroupfolders.vue @@ -26,20 +26,48 @@

{{ t('workspace', 'Select groupfolders to convert in workspace') }}

+ + + + +
+
+
+ {{ groupfolder.mount_point }} +
+ +
+
+
+
diff --git a/src/SelectGroupfolders.vue b/src/SelectGroupfolders.vue new file mode 100644 index 00000000..80728dff --- /dev/null +++ b/src/SelectGroupfolders.vue @@ -0,0 +1,125 @@ + + + + + + + From 8f6e831e84d2511480f1767c4cabd56a9fd56fc2 Mon Sep 17 00:00:00 2001 From: zak39 Date: Wed, 29 Dec 2021 09:49:54 +0100 Subject: [PATCH 18/35] feat(Vue): Add groupfolders which aren't space in the groupfolders var from the store With the groupfolders var from the store, I will print in the SelectGroupfolders modal --- src/SelectGroupfolders.vue | 23 +++++++++++------------ src/store/actions.js | 3 +++ src/store/index.js | 1 + src/store/mutations.js | 3 +++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/SelectGroupfolders.vue b/src/SelectGroupfolders.vue index 80728dff..49b8bce2 100644 --- a/src/SelectGroupfolders.vue +++ b/src/SelectGroupfolders.vue @@ -40,24 +40,23 @@ export default { }, data() { return { - groupfolders: [], } }, created() { - console.debug('Hey !') - console.debug('Before this.groupfolders', this.groupfolders) this.getGroupfolders() .then(resultat => { - console.debug('resultat', resultat) - // TODO: update from store - this.groupfolders = resultat + resultat.forEach(groupfolder => { + this.$store.dispatch('updateGroupfolders', { + groupfolder, + }) + }) }) .catch(error => { console.error('Error to get groupfolders to convert in space', error) }) - console.debug('After this.groupfolders', this.groupfolders) }, methods: { + // get groupfolders whithout spaces. async getGroupfolders() { const groupfolders = await getAll() .then(resp => { @@ -82,15 +81,15 @@ export default { const groupfoldersKey = Object.keys(groupfolders) // Get the difference between spaces and groupfolders to get groupfoders which aren't spaces - const groupfoldersKeysNotSpace = groupfoldersKey.filter(groupfolderKey => !groupfoldersIdFromSpaces.includes(groupfolderKey)) + const groupfoldersKeysWhithoutSpace = groupfoldersKey.filter(groupfolderKey => !groupfoldersIdFromSpaces.includes(groupfolderKey)) // Build a Groupfolders' array - const groupfoldersNotSpace = [] - for (const key of groupfoldersKeysNotSpace) { - groupfoldersNotSpace.push(groupfolders[key]) + const groupfoldersWhithoutSpace = [] + for (const key of groupfoldersKeysWhithoutSpace) { + groupfoldersWhithoutSpace.push(groupfolders[key]) } - return groupfoldersNotSpace + return groupfoldersWhithoutSpace }, }, } diff --git a/src/store/actions.js b/src/store/actions.js index 36da03a3..8f226d02 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -361,4 +361,7 @@ export default { updateColor(context, { name, colorCode }) { context.commit('UPDATE_COLOR', { name, colorCode }) }, + updateGroupfolders(context, { groupfolder }) { + context.commit('UPDATE_GROUPFOLDERS', { groupfolder }) + }, } diff --git a/src/store/index.js b/src/store/index.js index 7318a2df..f52c62d7 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -34,6 +34,7 @@ const store = new Store({ state: { loading: true, spaces: {}, + groupfolders: [], }, mutations, actions, diff --git a/src/store/mutations.js b/src/store/mutations.js index a77aa819..6a62e75d 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -158,4 +158,7 @@ export default { space.color = colorCode Vue.set(state.spaces, name, space) }, + UPDATE_GROUPFOLDERS(state, { groupfolder }) { + state.groupfolders.push(groupfolder) + }, } From 40125af66c238f1950683e8c2e498da12c0c3c64 Mon Sep 17 00:00:00 2001 From: zak39 Date: Wed, 29 Dec 2021 14:49:32 +0100 Subject: [PATCH 19/35] feat(Vue): Fill and Empy the groupfolders list in SelectGroupfolders Fill the groupfolders list in SelectGroupfolders list when the general manager open the modal. Then, empty this list when the general manager close this modal window --- src/Home.vue | 1 + src/SelectGroupfolders.vue | 80 ++++++++++++++++++++++++++++++++++++++ src/store/actions.js | 3 ++ src/store/index.js | 2 +- src/store/mutations.js | 5 ++- 5 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/Home.vue b/src/Home.vue index e579dc98..28e9fbaf 100644 --- a/src/Home.vue +++ b/src/Home.vue @@ -340,6 +340,7 @@ export default { return groups }, toggleShowSelectGroupfoldersModal() { + this.$store.dispatch('emptyGroupfolders') this.showSelectGroupfoldersModal = !this.showSelectGroupfoldersModal }, }, diff --git a/src/SelectGroupfolders.vue b/src/SelectGroupfolders.vue index 49b8bce2..1cc53376 100644 --- a/src/SelectGroupfolders.vue +++ b/src/SelectGroupfolders.vue @@ -26,20 +26,48 @@

{{ t('workspace', 'Select groupfolders to convert in workspace') }}

+ + + + +
+
+
+ {{ groupfolder.mount_point }} +
+ +
+
+
+