Commit e821a4ba authored by Phil Hughes's avatar Phil Hughes

Move EE differences from CE api.js

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/10098
parent 489b3a2d
......@@ -18,7 +18,6 @@ const Api = {
projectRunnersPath: '/api/:version/projects/:id/runners',
mergeRequestsPath: '/api/:version/merge_requests',
groupLabelsPath: '/groups/:namespace_path/-/labels',
ldapGroupsPath: '/api/:version/ldap/:provider/groups.json',
issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key',
projectTemplatePath: '/api/:version/projects/:id/templates/:type/:key',
projectTemplatesPath: '/api/:version/projects/:id/templates/:type',
......@@ -31,8 +30,6 @@ const Api = {
commitPipelinesPath: '/:project_id/commit/:sha/pipelines',
branchSinglePath: '/api/:version/projects/:id/repository/branches/:branch',
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',
group(groupId, callback) {
......@@ -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) {
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';
import 'select2/select2';
import _ from 'underscore';
import { __ } from '~/locale';
import Api from '~/api';
import Api from 'ee/api';
import { TYPE_USER, TYPE_GROUP } from '../constants';
import { renderAvatar } from '~/helpers/avatar_helper';
......
import $ from 'jquery';
import _ from 'underscore';
import Api from '~/api';
import Api from 'ee/api';
import { __ } from '~/locale';
import Flash from '~/flash';
import axios from '~/lib/utils/axios_utils';
......
import API from 'ee/api';
import * as types from './mutation_types';
import createFlash from '~/flash';
import { __ } from '~/locale';
import API from '~/api';
/**
* SUBSCRIPTION TABLE
......
import axios from '~/lib/utils/axios_utils';
import Api from '~/api';
import Api from 'ee/api';
export default class GeoNodesService {
constructor() {
......
/* eslint-disable prefer-arrow-callback, no-var, one-var, object-shorthand, consistent-return, no-unused-vars, func-names */
import $ from 'jquery';
import Api from '~/api';
import Api from 'ee/api';
export default function initLDAPGroupsSelect() {
var groupFormatSelection, ldapGroupResult;
......@@ -23,7 +23,7 @@ export default function initLDAPGroupsSelect() {
query: function(query) {
var provider;
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;
data = {
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 $ from 'jquery';
import Api from '~/api';
import Api from 'ee/api';
import ApproversSelect from 'ee/approvals/components/approvers_select.vue';
import { TYPE_USER, TYPE_GROUP } from 'ee/approvals/constants';
import { TEST_HOST } from 'spec/test_constants';
......
......@@ -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', () => {
it('fetches single user', done => {
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