Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent the duplication of group #782

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions l10n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ OC.L10N.register(
'return to home': 'return to home',
'Email': 'Emails',
'Groups': 'Groups',
'Duplication of groups': 'Duplication of groups',
'The group already exists.': 'The group already exists.',
'Make administrator': 'Assign as Workspace manager',
'Error to rename space': 'Error to rename space',
'The space name already exist. We cannot rename with this name.': 'The space name already exist. We cannot rename with this name.',
Expand Down
2 changes: 2 additions & 0 deletions l10n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ OC.L10N.register(
'Space name': 'Nom de l\'espace de travail',
'Caution, users highlighted in red are not yet member of this workspace. They will be automaticaly added.': "Attention, les utilisateurs surlignés en rouge ne sont pas encore membres de l'espace. Ils seront ajoutés automatiquement à ce dernier.",
'Create group': 'Créer un groupe',
'Duplication of groups': 'Duplication des groupes',
'The group already exists.': 'Le groupe existe déjà.',
'Delete space': "Supprimer l'espace de travail",
'Delete user': "Retirer de l'espace de travail",
'Email': 'Email',
Expand Down
2 changes: 2 additions & 0 deletions l10n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Caution, users highlighted in red are not yet member of this workspace. They will be automaticaly added.": "Attention, les utilisateurs surlignés en rouge ne sont pas encore membres de l'espace. Ils seront ajoutés automatiquement à ce dernier",
"Create group": "Créer un groupe",
"Delete space" : "Supprimer l'espace de travail",
"Duplication of groups": "Duplication des groupes",
"The group already exists.": "Le groupe existe déjà.",
"Delete user" : "Supprimer de l'espace de travail",
"Group name": "Nom du groupe",
"Space name": "Nom de l'espace de travail",
Expand Down
2 changes: 1 addition & 1 deletion src/SpaceDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default {
}

// Creates group
this.$store.dispatch('createGroup', { name: this.$route.params.space, gid })
this.$store.dispatch('createGroup', { name: this.$route.params.space, gid, vueInstance: this })
},
onSpaceRename(e) {
// Hides ActionInput
Expand Down
15 changes: 13 additions & 2 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { addGroupToGroupfolder } from '../services/groupfoldersService.js'
import { ESPACE_MANAGERS_PREFIX, ESPACE_USERS_PREFIX, ESPACE_GID_PREFIX } from '../constants.js'
import { generateUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import NotificationError from '../services/Notifications/NotificationError.js'
import router from '../router.js'

export default {
Expand Down Expand Up @@ -79,12 +80,22 @@ export default {
})
})
},
// Creates a group and navigates to its details page
createGroup(context, { name, gid }) {
// Creates a group and navigates to its details page
createGroup(context, { name, gid, vueInstance = undefined }) {
// Groups must be postfixed with the ID of the space they belong
const space = context.state.spaces[name]
gid = gid + '-' + space.id

const groups = Object.keys(space.groups)
if (groups.includes(gid)) {
const duplicateError = new NotificationError(vueInstance)
duplicateError.push({
title: t('workspace', 'Duplication of groups'),
text: t('workspace', 'The group already exists.'),
})
return
}

// Creates group in frontend
context.commit('addGroupToSpace', { name, gid })

Expand Down