From eb60f6a7bad8d9230b2ff8ae0cf63804b7ca0584 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Tue, 25 Mar 2025 14:31:45 -0700 Subject: [PATCH] fix(settings): Fix duplicated group options in new account dialog Signed-off-by: Christopher Ng --- .../src/components/Users/NewUserDialog.vue | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/settings/src/components/Users/NewUserDialog.vue b/apps/settings/src/components/Users/NewUserDialog.vue index dd43d4fc710..3e50efc2072 100644 --- a/apps/settings/src/components/Users/NewUserDialog.vue +++ b/apps/settings/src/components/Users/NewUserDialog.vue @@ -71,10 +71,10 @@ :multiple="true" :taggable="true" :required="!settings.isAdmin && !settings.isDelegatedAdmin" - :create-option="(value) => ({ name: value })" - @input="handleGroupInput" + :create-option="(value) => ({ id: value, name: value, isCreating: true })" @search="searchGroups" - @option:created="createGroup" /> + @option:created="createGroup" + @option:selected="options => addGroup(options.at(-1))" /> @@ -272,15 +272,6 @@ export default { } }, - handleGroupInput(groups) { - /** - * Filter out groups with no id to prevent duplicate selected options - * - * Created groups are added programmatically by `createGroup()` - */ - this.newUser.groups = groups.filter(group => Boolean(group.id)) - }, - async searchGroups(query, toggleLoading) { if (this.promise) { this.promise.cancel() @@ -319,6 +310,21 @@ export default { this.loading.groups = false }, + /** + * Add user to group + * + * @param {object} group Group object + */ + async addGroup(group) { + if (group.isCreating) { + return + } + if (group.canAdd === false) { + return + } + this.newUser.groups.push(group) + }, + /** * Validate quota string to make sure it's a valid human file size *