Commit 1af3c172 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'dz-use-scoped-autocomplete-routes' into 'master'

Use scoped routing for autocomplete

See merge request gitlab-org/gitlab!34769
parents 1dfba3bc 086e94ec
......@@ -126,7 +126,7 @@ export default {
updateAssigneesDropdown() {
this.isDropdownSearching = true;
return axios
.get(this.buildUrl(gon.relative_url_root, '/autocomplete/users.json'), {
.get(this.buildUrl(gon.relative_url_root, '/-/autocomplete/users.json'), {
params: {
search: this.search,
per_page: 20,
......
......@@ -10,7 +10,7 @@ export default class DropdownEmoji extends FilteredSearchDropdown {
super(options);
this.config = {
Ajax: {
endpoint: `${gon.relative_url_root || ''}/autocomplete/award_emojis`,
endpoint: `${gon.relative_url_root || ''}/-/autocomplete/award_emojis`,
method: 'setData',
loadingTemplate: this.loadingTemplate,
onError() {
......
......@@ -5,7 +5,7 @@ export default class DropdownUser extends DropdownAjaxFilter {
constructor(options = {}) {
super({
...options,
endpoint: '/autocomplete/users.json',
endpoint: '/-/autocomplete/users.json',
symbol: '@',
});
}
......
......@@ -18,7 +18,7 @@ export default {
fetchAuthors({ dispatch, state }, author = null) {
const { projectId } = state;
return axios
.get(joinPaths(gon.relative_url_root || '', '/autocomplete/users.json'), {
.get(joinPaths(gon.relative_url_root || '', '/-/autocomplete/users.json'), {
params: {
project_id: projectId,
active: true,
......
......@@ -21,8 +21,8 @@ function UsersSelect(currentUser, els, options = {}) {
const $els = $(els || '.js-user-search');
this.users = this.users.bind(this);
this.user = this.user.bind(this);
this.usersPath = '/autocomplete/users.json';
this.userPath = '/autocomplete/users/:id.json';
this.usersPath = '/-/autocomplete/users.json';
this.userPath = '/-/autocomplete/users/:id.json';
if (currentUser != null) {
if (typeof currentUser === 'object') {
this.currentUser = currentUser;
......
......@@ -58,7 +58,7 @@ document.addEventListener('DOMContentLoaded', () => {
.select2(
getDropdownConfig(
s__('Elastic|None. Select namespaces to index.'),
'/autocomplete/namespace_routes.json',
'/-/autocomplete/namespace_routes.json',
),
);
......@@ -67,7 +67,7 @@ document.addEventListener('DOMContentLoaded', () => {
.select2(
getDropdownConfig(
s__('Elastic|None. Select projects to index.'),
'/autocomplete/project_routes.json',
'/-/autocomplete/project_routes.json',
),
);
});
......@@ -14,8 +14,8 @@ export default class AccessDropdown {
this.accessLevelsData = accessLevelsData.roles;
this.$dropdown = $dropdown;
this.$wrap = this.$dropdown.closest(`.${this.accessLevel}-container`);
this.usersPath = '/autocomplete/users.json';
this.groupsPath = '/autocomplete/project_groups.json';
this.usersPath = '/-/autocomplete/users.json';
this.groupsPath = '/-/autocomplete/project_groups.json';
this.defaultLabel = this.$dropdown.data('defaultLabel');
this.setSelectedItems([]);
......
......@@ -90,7 +90,7 @@ describe('Assignee select component', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
mock.onGet('/autocomplete/users.json').reply(200, [assignee, assignee2]);
mock.onGet('/-/autocomplete/users.json').reply(200, [assignee, assignee2]);
});
afterEach(() => {
......
......@@ -70,7 +70,7 @@ describe('Alert Details Sidebar Assignees', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
const path = '/autocomplete/users.json';
const path = '/-/autocomplete/users.json';
const users = [
{
avatar_url:
......
......@@ -48,13 +48,13 @@ describe('Dropdown User', () => {
};
const dropdown = new DropdownUser();
expect(dropdown.config.AjaxFilter.endpoint).toBe('/autocomplete/users.json');
expect(dropdown.config.AjaxFilter.endpoint).toBe('/-/autocomplete/users.json');
});
it('should return endpoint when relative_url_root is undefined', () => {
const dropdown = new DropdownUser();
expect(dropdown.config.AjaxFilter.endpoint).toBe('/autocomplete/users.json');
expect(dropdown.config.AjaxFilter.endpoint).toBe('/-/autocomplete/users.json');
});
it('should return endpoint with relative url when available', () => {
......@@ -63,7 +63,9 @@ describe('Dropdown User', () => {
};
const dropdown = new DropdownUser();
expect(dropdown.config.AjaxFilter.endpoint).toBe('/gitlab_directory/autocomplete/users.json');
expect(dropdown.config.AjaxFilter.endpoint).toBe(
'/gitlab_directory/-/autocomplete/users.json',
);
});
afterEach(() => {
......
......@@ -45,7 +45,7 @@ describe('Project commits actions', () => {
describe('fetchAuthors', () => {
it('dispatches request/receive', () => {
const path = '/autocomplete/users.json';
const path = '/-/autocomplete/users.json';
state.projectId = '8';
const data = [{ id: 1 }];
......@@ -60,7 +60,7 @@ describe('Project commits actions', () => {
});
it('dispatches request/receive on error', () => {
const path = '/autocomplete/users.json';
const path = '/-/autocomplete/users.json';
mock.onGet(path).replyOnce(500);
testAction(actions.fetchAuthors, null, state, [], [{ type: 'receiveAuthorsError' }]);
......
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