Commit 6abfc790 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'api-js-ee-differences' into 'master'

Move EE differences from CE api.js

Closes #10098

See merge request gitlab-org/gitlab-ee!9765
parents c80ef908 e821a4ba
...@@ -18,7 +18,6 @@ const Api = { ...@@ -18,7 +18,6 @@ const Api = {
projectRunnersPath: '/api/:version/projects/:id/runners', projectRunnersPath: '/api/:version/projects/:id/runners',
mergeRequestsPath: '/api/:version/merge_requests', mergeRequestsPath: '/api/:version/merge_requests',
groupLabelsPath: '/groups/:namespace_path/-/labels', groupLabelsPath: '/groups/:namespace_path/-/labels',
ldapGroupsPath: '/api/:version/ldap/:provider/groups.json',
issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key', issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key',
projectTemplatePath: '/api/:version/projects/:id/templates/:type/:key', projectTemplatePath: '/api/:version/projects/:id/templates/:type/:key',
projectTemplatesPath: '/api/:version/projects/:id/templates/:type', projectTemplatesPath: '/api/:version/projects/:id/templates/:type',
...@@ -31,8 +30,6 @@ const Api = { ...@@ -31,8 +30,6 @@ const Api = {
commitPipelinesPath: '/:project_id/commit/:sha/pipelines', commitPipelinesPath: '/:project_id/commit/:sha/pipelines',
branchSinglePath: '/api/:version/projects/:id/repository/branches/:branch', branchSinglePath: '/api/:version/projects/:id/repository/branches/:branch',
createBranchPath: '/api/:version/projects/:id/repository/branches', createBranchPath: '/api/:version/projects/:id/repository/branches',
geoNodesPath: '/api/:version/geo_nodes',
subscriptionPath: '/api/:version/namespaces/:id/gitlab_subscription',
releasesPath: '/api/:version/projects/:id/releases', releasesPath: '/api/:version/projects/:id/releases',
group(groupId, callback) { group(groupId, callback) {
...@@ -318,48 +315,6 @@ const Api = { ...@@ -318,48 +315,6 @@ const Api = {
}); });
}, },
approverUsers(search, options, callback = $.noop) {
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;
});
},
ldap_groups(query, provider, callback) {
const url = Api.buildUrl(this.ldapGroupsPath).replace(':provider', provider);
return axios
.get(url, {
params: {
search: query,
per_page: 20,
active: true,
},
})
.then(({ data }) => {
callback(data);
return data;
});
},
userSubscription(namespaceId) {
const url = Api.buildUrl(this.subscriptionPath).replace(':id', encodeURIComponent(namespaceId));
return axios.get(url);
},
releases(id) { releases(id) {
const url = Api.buildUrl(this.releasesPath).replace(':id', encodeURIComponent(id)); const url = Api.buildUrl(this.releasesPath).replace(':id', encodeURIComponent(id));
......
import Api from '~/api';
import axios from '~/lib/utils/axios_utils';
export default {
...Api,
geoNodesPath: '/api/:version/geo_nodes',
ldapGroupsPath: '/api/:version/ldap/:provider/groups.json',
subscriptionPath: '/api/:version/namespaces/:id/gitlab_subscription',
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) {
const url = Api.buildUrl(this.subscriptionPath).replace(':id', encodeURIComponent(namespaceId));
return axios.get(url);
},
ldapGroups(query, provider, callback) {
const url = Api.buildUrl(this.ldapGroupsPath).replace(':provider', provider);
return axios
.get(url, {
params: {
search: query,
per_page: 20,
active: true,
},
})
.then(({ data }) => {
callback(data);
return data;
});
},
};
...@@ -3,7 +3,7 @@ import $ from 'jquery'; ...@@ -3,7 +3,7 @@ import $ from 'jquery';
import 'select2/select2'; import 'select2/select2';
import _ from 'underscore'; import _ from 'underscore';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Api from '~/api'; import Api from 'ee/api';
import { TYPE_USER, TYPE_GROUP } from '../constants'; import { TYPE_USER, TYPE_GROUP } from '../constants';
import { renderAvatar } from '~/helpers/avatar_helper'; import { renderAvatar } from '~/helpers/avatar_helper';
......
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
import Api from '~/api'; import Api from 'ee/api';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Flash from '~/flash'; import Flash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
......
import API from 'ee/api';
import * as types from './mutation_types'; import * as types from './mutation_types';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import API from '~/api';
/** /**
* SUBSCRIPTION TABLE * SUBSCRIPTION TABLE
......
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import Api from 'ee/api';
import Api from '~/api';
export default class GeoNodesService { export default class GeoNodesService {
constructor() { constructor() {
......
/* eslint-disable prefer-arrow-callback, no-var, one-var, object-shorthand, consistent-return, no-unused-vars, func-names */ /* eslint-disable prefer-arrow-callback, no-var, one-var, object-shorthand, consistent-return, no-unused-vars, func-names */
import $ from 'jquery'; import $ from 'jquery';
import Api from '~/api'; import Api from 'ee/api';
export default function initLDAPGroupsSelect() { export default function initLDAPGroupsSelect() {
var groupFormatSelection, ldapGroupResult; var groupFormatSelection, ldapGroupResult;
...@@ -23,7 +23,7 @@ export default function initLDAPGroupsSelect() { ...@@ -23,7 +23,7 @@ export default function initLDAPGroupsSelect() {
query: function(query) { query: function(query) {
var provider; var provider;
provider = $('#ldap_group_link_provider').val(); provider = $('#ldap_group_link_provider').val();
return Api.ldap_groups(query.term, provider, function(groups) { return Api.ldapGroups(query.term, provider, function(groups) {
var data; var data;
data = { data = {
results: groups, results: groups,
......
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import Api from 'ee/api';
describe('Api', () => {
const dummyApiVersion = 'v3000';
const dummyUrlRoot = 'http://host.invalid';
const dummyGon = {
api_version: dummyApiVersion,
relative_url_root: dummyUrlRoot,
};
let originalGon;
let mock;
beforeEach(() => {
mock = new MockAdapter(axios);
originalGon = window.gon;
window.gon = Object.assign({}, dummyGon);
});
afterEach(() => {
mock.restore();
window.gon = originalGon;
});
describe('ldapGroups', () => {
it('calls callback on completion', done => {
const query = 'query';
const provider = 'provider';
const callback = jasmine.createSpy();
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/ldap/${provider}/groups.json`;
mock.onGet(expectedUrl).reply(200, [
{
name: 'test',
},
]);
Api.ldapGroups(query, provider, callback)
.then(response => {
expect(callback).toHaveBeenCalledWith(response);
})
.then(done)
.catch(done.fail);
});
});
});
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
import $ from 'jquery'; import $ from 'jquery';
import Api from '~/api'; import Api from 'ee/api';
import ApproversSelect from 'ee/approvals/components/approvers_select.vue'; import ApproversSelect from 'ee/approvals/components/approvers_select.vue';
import { TYPE_USER, TYPE_GROUP } from 'ee/approvals/constants'; import { TYPE_USER, TYPE_GROUP } from 'ee/approvals/constants';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
......
...@@ -349,28 +349,6 @@ describe('Api', () => { ...@@ -349,28 +349,6 @@ describe('Api', () => {
}); });
}); });
describe('ldap_groups', () => {
it('calls callback on completion', done => {
const query = 'query';
const provider = 'provider';
const callback = jasmine.createSpy();
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/ldap/${provider}/groups.json`;
mock.onGet(expectedUrl).reply(200, [
{
name: 'test',
},
]);
Api.ldap_groups(query, provider, callback)
.then(response => {
expect(callback).toHaveBeenCalledWith(response);
})
.then(done)
.catch(done.fail);
});
});
describe('user', () => { describe('user', () => {
it('fetches single user', done => { it('fetches single user', done => {
const userId = '123456'; const userId = '123456';
......
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