diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-02-01 00:01:28 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2018-02-01 00:01:28 +0000 |
commit | b00c48f407bf96d68eac0b393ec78db062637018 (patch) | |
tree | 20a50ef3ecc1c5cafe7bca071d4679d1ac213367 /app/assets | |
parent | c25bbdf8c286d8f7888fb9a209fb01b208ba7ad5 (diff) | |
parent | b8c43a73d3be399271d499800f3ee8e179738788 (diff) | |
download | gitlab-ce-b00c48f407bf96d68eac0b393ec78db062637018.tar.gz |
Merge branch 'axios-find-file' into 'master'
Replace $.ajax in find file with axios
See merge request gitlab-org/gitlab-ce!16841
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/project_find_file.js | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/app/assets/javascripts/project_find_file.js b/app/assets/javascripts/project_find_file.js index 0da32b4a3cc..586d188350f 100644 --- a/app/assets/javascripts/project_find_file.js +++ b/app/assets/javascripts/project_find_file.js @@ -1,6 +1,9 @@ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, quotes, consistent-return, one-var, one-var-declaration-per-line, no-cond-assign, max-len, object-shorthand, no-param-reassign, comma-dangle, prefer-template, no-unused-vars, no-return-assign */ import fuzzaldrinPlus from 'fuzzaldrin-plus'; +import axios from '~/lib/utils/axios_utils'; +import flash from '~/flash'; +import { __ } from '~/locale'; // highlight text(awefwbwgtc -> <b>a</b>wefw<b>b</b>wgt<b>c</b> ) const highlighter = function(element, text, matches) { @@ -72,19 +75,14 @@ export default class ProjectFindFile { // files pathes load load(url) { - return $.ajax({ - url: url, - method: "get", - dataType: "json", - success: (function(_this) { - return function(data) { - _this.element.find(".loading").hide(); - _this.filePaths = data; - _this.findFile(); - return _this.element.find(".files-slider tr.tree-item").eq(0).addClass("selected").focus(); - }; - })(this) - }); + axios.get(url) + .then(({ data }) => { + this.element.find('.loading').hide(); + this.filePaths = data; + this.findFile(); + this.element.find('.files-slider tr.tree-item').eq(0).addClass('selected').focus(); + }) + .catch(() => flash(__('An error occurred while loading filenames'))); } // render result |