diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-02-12 17:43:29 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-02-12 17:43:29 +0000 |
commit | 94e53df015c01851599396072e72330f6289f36b (patch) | |
tree | 48fb6c58175a75613221bee3ff1e203035df8611 | |
parent | 80c1626b2776b300acaaee85d11012b96893d004 (diff) | |
parent | 118619ea8203d0d4b9da119238a7486075e87f99 (diff) | |
download | gitlab-ce-94e53df015c01851599396072e72330f6289f36b.tar.gz |
Merge branch 'groups-select-axios' into 'master'
Convert groups_select ajax to use axios
See merge request gitlab-org/gitlab-ce!17041
-rw-r--r-- | app/assets/javascripts/groups_select.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/app/assets/javascripts/groups_select.js b/app/assets/javascripts/groups_select.js index a69a0bde17b..65a2395fe29 100644 --- a/app/assets/javascripts/groups_select.js +++ b/app/assets/javascripts/groups_select.js @@ -1,5 +1,6 @@ +import axios from './lib/utils/axios_utils'; import Api from './api'; -import { normalizeCRLFHeaders } from './lib/utils/common_utils'; +import { normalizeHeaders } from './lib/utils/common_utils'; export default function groupsSelect() { // Needs to be accessible in rspec @@ -17,24 +18,23 @@ export default function groupsSelect() { dataType: 'json', quietMillis: 250, transport(params) { - return $.ajax(params) - .then((data, status, xhr) => { - const results = data || []; - - const headers = normalizeCRLFHeaders(xhr.getAllResponseHeaders()); + axios[params.type.toLowerCase()](params.url, { + params: params.data, + }) + .then((res) => { + const results = res.data || []; + const headers = normalizeHeaders(res.headers); const currentPage = parseInt(headers['X-PAGE'], 10) || 0; const totalPages = parseInt(headers['X-TOTAL-PAGES'], 10) || 0; const more = currentPage < totalPages; - return { + params.success({ results, pagination: { more, }, - }; - }) - .then(params.success) - .fail(params.error); + }); + }).catch(params.error); }, data(search, page) { return { |