Commit 76a9c8c7 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '350596_restore_previous_behavior' into 'master'

Use groups API for Approvals form by default

See merge request gitlab-org/gitlab!80933
parents db4d88f9 1722e7ad
......@@ -142,6 +142,7 @@ export default {
.then((results) => ({ results }));
},
fetchGroups(term) {
if (this.isFeatureEnabled) {
const hasTerm = term.trim().length > 0;
const DEVELOPER_ACCESS_LEVEL = 30;
......@@ -152,6 +153,16 @@ export default {
shared_visible_only: !this.isFeatureEnabled,
shared_min_access_level: DEVELOPER_ACCESS_LEVEL,
});
}
// Don't includeAll when search is empty. Otherwise, the user could get a lot of garbage choices.
// https://gitlab.com/gitlab-org/gitlab/issues/11566
const includeAll = term.trim().length > 0;
return Api.groups(term, {
skip_groups: this.skipGroupIds,
all_available: includeAll,
});
},
fetchUsers(term) {
return Api.projectUsers(this.projectId, term, {
......
......@@ -76,6 +76,7 @@ describe('Approvals ApproversSelect', () => {
};
beforeEach(() => {
jest.spyOn(Api, 'groups').mockResolvedValue(TEST_GROUPS);
jest.spyOn(Api, 'projectGroups').mockResolvedValue(TEST_GROUPS);
jest.spyOn(Api, 'projectUsers').mockReturnValue(Promise.resolve(TEST_USERS));
});
......@@ -126,12 +127,9 @@ describe('Approvals ApproversSelect', () => {
});
it('fetches all available groups', () => {
expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, {
expect(Api.groups).toHaveBeenCalledWith(term, {
skip_groups: [],
search: term,
with_shared: true,
shared_visible_only: true,
shared_min_access_level: 30,
all_available: true,
});
});
......@@ -191,11 +189,9 @@ describe('Approvals ApproversSelect', () => {
});
it('skips groups and does not fetch all available', () => {
expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, {
shared_min_access_level: 30,
shared_visible_only: true,
expect(Api.groups).toHaveBeenCalledWith('', {
skip_groups: skipGroupIds,
with_shared: true,
all_available: false,
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment