diff options
Diffstat (limited to 'apps/settings/src/components/Users/NewUserDialog.vue')
-rw-r--r-- | apps/settings/src/components/Users/NewUserDialog.vue | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/apps/settings/src/components/Users/NewUserDialog.vue b/apps/settings/src/components/Users/NewUserDialog.vue index 3e50efc2072..ef401b565fa 100644 --- a/apps/settings/src/components/Users/NewUserDialog.vue +++ b/apps/settings/src/components/Users/NewUserDialog.vue @@ -61,6 +61,7 @@ :required="newUser.password === '' || settings.newUserRequireEmail" /> <div class="dialog__item"> <NcSelect class="dialog__select" + data-test="groups" :input-label="!settings.isAdmin && !settings.isDelegatedAdmin ? t('settings', 'Member of the following groups (required)') : t('settings', 'Member of the following groups')" :placeholder="t('settings', 'Set account groups')" :disabled="loading.groups || loading.all" @@ -69,7 +70,7 @@ label="name" :close-on-select="false" :multiple="true" - :taggable="true" + :taggable="settings.isAdmin || settings.isDelegatedAdmin" :required="!settings.isAdmin && !settings.isDelegatedAdmin" :create-option="(value) => ({ id: value, name: value, isCreating: true })" @search="searchGroups" @@ -85,7 +86,7 @@ :input-label="t('settings', 'Admin of the following groups')" :placeholder="t('settings', 'Set account as admin for …')" :disabled="loading.groups || loading.all" - :options="subAdminsGroups" + :options="availableGroups" :close-on-select="false" :multiple="true" label="name" @@ -178,7 +179,6 @@ export default { data() { return { - availableGroups: this.$store.getters.getSortedGroups.filter(group => group.id !== '__nc_internal_recent' && group.id !== 'disabled'), possibleManagers: [], // TRANSLATORS This string describes a manager in the context of an organization managerInputLabel: t('settings', 'Manager'), @@ -209,9 +209,12 @@ export default { return this.$store.getters.getPasswordPolicyMinLength }, - subAdminsGroups() { - // data provided php side - return this.availableGroups.filter(group => group.id !== 'admin' && group.id !== '__nc_internal_recent' && group.id !== 'disabled') + availableGroups() { + const groups = (this.settings.isAdmin || this.settings.isDelegatedAdmin) + ? this.$store.getters.getSortedGroups + : this.$store.getters.getSubAdminGroups + + return groups.filter(group => group.id !== '__nc_internal_recent' && group.id !== 'disabled') }, languages() { @@ -273,6 +276,11 @@ export default { }, async searchGroups(query, toggleLoading) { + if (!this.settings.isAdmin && !this.settings.isDelegatedAdmin) { + // managers cannot search for groups + return + } + if (this.promise) { this.promise.cancel() } @@ -284,7 +292,10 @@ export default { limit: 25, }) const groups = await this.promise - this.availableGroups = groups + // Populate store from server request + for (const group of groups) { + this.$store.commit('addGroup', group) + } } catch (error) { logger.error(t('settings', 'Failed to search groups'), { error }) } @@ -302,7 +313,6 @@ export default { this.loading.groups = true try { await this.$store.dispatch('addGroup', gid) - this.availableGroups.push({ id: gid, name: gid }) this.newUser.groups.push({ id: gid, name: gid }) } catch (error) { logger.error(t('settings', 'Failed to create group'), { error }) @@ -336,7 +346,7 @@ export default { const validQuota = OC.Util.computerFileSize(quota) if (validQuota !== null && validQuota >= 0) { // unify format output - quota = formatFileSize(parseFileSize(quota)) + quota = formatFileSize(parseFileSize(quota, true)) this.newUser.quota = { id: quota, label: quota } return this.newUser.quota } |