Commit 06f9cc6c authored by Himanshu Kapoor's avatar Himanshu Kapoor

Remove Api.approverUsers to use projectUsers

Api.approverUsers uses a legacy endpoint `/autocomplete/users`.
In effort to reduce gap between CE and EE and to phase out old APIs,
we're replacing approverUsers with a new /api/v4 endpoint.

Requires https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31801
to be merged before merging in EE.
parent 6c222d59
...@@ -8,25 +8,6 @@ export default { ...@@ -8,25 +8,6 @@ export default {
subscriptionPath: '/api/:version/namespaces/:id/gitlab_subscription', subscriptionPath: '/api/:version/namespaces/:id/gitlab_subscription',
childEpicPath: '/api/:version/groups/:id/epics/:epic_iid/epics', childEpicPath: '/api/:version/groups/:id/epics/:epic_iid/epics',
approverUsers(search, options, callback = () => {}) {
const url = Api.buildUrl('/autocomplete/users.json');
return axios
.get(url, {
params: Object.assign(
{
search,
per_page: 20,
},
options,
),
})
.then(({ data }) => {
callback(data);
return data;
});
},
userSubscription(namespaceId) { userSubscription(namespaceId) {
const url = Api.buildUrl(this.subscriptionPath).replace(':id', encodeURIComponent(namespaceId)); const url = Api.buildUrl(this.subscriptionPath).replace(':id', encodeURIComponent(namespaceId));
......
...@@ -136,9 +136,8 @@ export default { ...@@ -136,9 +136,8 @@ export default {
}); });
}, },
fetchUsers(term) { fetchUsers(term) {
return Api.approverUsers(term, { return Api.projectUsers(this.projectId, term, {
skip_users: this.skipUserIds, skip_users: this.skipUserIds,
project_id: this.projectId,
}); });
}, },
onChange() { onChange() {
......
...@@ -74,7 +74,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -74,7 +74,7 @@ describe('Approvals ApproversSelect', () => {
beforeEach(() => { beforeEach(() => {
jasmine.clock().install(); jasmine.clock().install();
spyOn(Api, 'groups').and.returnValue(Promise.resolve(TEST_GROUPS)); spyOn(Api, 'groups').and.returnValue(Promise.resolve(TEST_GROUPS));
spyOn(Api, 'approverUsers').and.returnValue(Promise.resolve(TEST_USERS)); spyOn(Api, 'projectUsers').and.returnValue(Promise.resolve(TEST_USERS));
}); });
afterEach(() => { afterEach(() => {
...@@ -127,9 +127,8 @@ describe('Approvals ApproversSelect', () => { ...@@ -127,9 +127,8 @@ describe('Approvals ApproversSelect', () => {
}); });
it('fetches users', () => { it('fetches users', () => {
expect(Api.approverUsers).toHaveBeenCalledWith(term, { expect(Api.projectUsers).toHaveBeenCalledWith(TEST_PROJECT_ID, term, {
skip_users: [], skip_users: [],
project_id: TEST_PROJECT_ID,
}); });
}); });
}); });
...@@ -161,9 +160,8 @@ describe('Approvals ApproversSelect', () => { ...@@ -161,9 +160,8 @@ describe('Approvals ApproversSelect', () => {
}); });
it('skips users', () => { it('skips users', () => {
expect(Api.approverUsers).toHaveBeenCalledWith('', { expect(Api.projectUsers).toHaveBeenCalledWith(TEST_PROJECT_ID, '', {
skip_users: skipUserIds, skip_users: skipUserIds,
project_id: TEST_PROJECT_ID,
}); });
}); });
}); });
......
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