Commit fc53a115 authored by Phil Hughes's avatar Phil Hughes

Converted users_select to use axios

parent 7c4dfb5a
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* global Issuable */ /* global Issuable */
/* global emitSidebarEvent */ /* global emitSidebarEvent */
import _ from 'underscore'; import _ from 'underscore';
import axios from './lib/utils/axios_utils';
// TODO: remove eventHub hack after code splitting refactor // TODO: remove eventHub hack after code splitting refactor
window.emitSidebarEvent = window.emitSidebarEvent || $.noop; window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
...@@ -177,12 +178,8 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -177,12 +178,8 @@ function UsersSelect(currentUser, els, options = {}) {
$loading.removeClass('hidden').fadeIn(); $loading.removeClass('hidden').fadeIn();
$dropdown.trigger('loading.gl.dropdown'); $dropdown.trigger('loading.gl.dropdown');
return $.ajax({ return axios.put(issueURL, data)
type: 'PUT', .then(({ data }) => {
dataType: 'json',
url: issueURL,
data: data
}).done(function(data) {
var user; var user;
$dropdown.trigger('loaded.gl.dropdown'); $dropdown.trigger('loaded.gl.dropdown');
$loading.fadeOut(); $loading.fadeOut();
...@@ -660,22 +657,17 @@ UsersSelect.prototype.user = function(user_id, callback) { ...@@ -660,22 +657,17 @@ UsersSelect.prototype.user = function(user_id, callback) {
var url; var url;
url = this.buildUrl(this.userPath); url = this.buildUrl(this.userPath);
url = url.replace(':id', user_id); url = url.replace(':id', user_id);
return $.ajax({ return axios.get(url)
url: url, .then(({ data }) => {
dataType: "json" callback(data);
}).done(function(user) {
return callback(user);
}); });
}; };
// Return users list. Filtered by query // Return users list. Filtered by query
// Only active users retrieved // Only active users retrieved
UsersSelect.prototype.users = function(query, options, callback) { UsersSelect.prototype.users = function(query, options, callback) {
var url; const url = this.buildUrl(this.usersPath);
url = this.buildUrl(this.usersPath); const params = {
return $.ajax({
url: url,
data: {
search: query, search: query,
per_page: options.perPage || 20, per_page: options.perPage || 20,
active: true, active: true,
...@@ -687,10 +679,10 @@ UsersSelect.prototype.users = function(query, options, callback) { ...@@ -687,10 +679,10 @@ UsersSelect.prototype.users = function(query, options, callback) {
current_user: options.showCurrentUser || null, current_user: options.showCurrentUser || null,
author_id: options.authorId || null, author_id: options.authorId || null,
skip_users: options.skipUsers || null skip_users: options.skipUsers || null
}, };
dataType: "json" return axios.get(url, { params })
}).done(function(users) { .then(({ data }) => {
return callback(users); callback(data);
}); });
}; };
......
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