Commit 086e94ec authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Use scoped routing for autocomplete

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