diff options
Diffstat (limited to 'app/assets/javascripts/invite_members/components/group_select.vue')
-rw-r--r-- | app/assets/javascripts/invite_members/components/group_select.vue | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/app/assets/javascripts/invite_members/components/group_select.vue b/app/assets/javascripts/invite_members/components/group_select.vue index 216078ed35e..04a8ec3400f 100644 --- a/app/assets/javascripts/invite_members/components/group_select.vue +++ b/app/assets/javascripts/invite_members/components/group_select.vue @@ -24,6 +24,10 @@ export default { prop: 'selectedGroup', }, props: { + accessLevels: { + type: Object, + required: true, + }, groupsFilter: { type: String, required: false, @@ -34,6 +38,10 @@ export default { required: false, default: null, }, + invalidGroups: { + type: Array, + required: true, + }, }, data() { return { @@ -50,6 +58,13 @@ export default { isFetchResultEmpty() { return this.groups.length === 0; }, + defaultFetchOptions() { + return { + exclude_internal: true, + active: true, + min_access_level: this.accessLevels.Guest, + }; + }, }, watch: { searchTerm() { @@ -64,18 +79,26 @@ export default { this.isFetching = true; return this.fetchGroups() .then((response) => { - this.groups = response.map((group) => ({ - id: group.id, - name: group.full_name, - path: group.path, - avatarUrl: group.avatar_url, - })); + this.groups = this.processGroups(response); this.isFetching = false; }) .catch(() => { this.isFetching = false; }); }, SEARCH_DELAY), + processGroups(response) { + const rawGroups = response.map((group) => ({ + id: group.id, + name: group.full_name, + path: group.path, + avatarUrl: group.avatar_url, + })); + + return this.filterOutInvalidGroups(rawGroups); + }, + filterOutInvalidGroups(groups) { + return groups.filter((group) => this.invalidGroups.indexOf(group.id) === -1); + }, selectGroup(group) { this.selectedGroup = group; @@ -84,13 +107,9 @@ export default { fetchGroups() { switch (this.groupsFilter) { case GROUP_FILTERS.DESCENDANT_GROUPS: - return getDescendentGroups( - this.parentGroupId, - this.searchTerm, - this.$options.defaultFetchOptions, - ); + return getDescendentGroups(this.parentGroupId, this.searchTerm, this.defaultFetchOptions); default: - return getGroups(this.searchTerm, this.$options.defaultFetchOptions); + return getGroups(this.searchTerm, this.defaultFetchOptions); } }, }, @@ -99,10 +118,6 @@ export default { searchPlaceholder: s__('GroupSelect|Search groups'), emptySearchResult: s__('GroupSelect|No matching results'), }, - defaultFetchOptions: { - exclude_internal: true, - active: true, - }, }; </script> <template> |