summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-20 09:06:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-20 09:06:17 +0000
commit8ac91ecfd1bb445a0a1572b3c0885c41c9037e8a (patch)
tree4b8c9d2a99ad50ef84421b57758869863ea477a2 /app/assets/javascripts/blob
parent7e20809103e1f9c0c96c3a96705224c81bf448d5 (diff)
downloadgitlab-ce-8ac91ecfd1bb445a0a1572b3c0885c41c9037e8a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/blob')
-rw-r--r--app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js37
1 files changed, 17 insertions, 20 deletions
diff --git a/app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js b/app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js
index 75777b910ca..87c8568802e 100644
--- a/app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js
+++ b/app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js
@@ -1,5 +1,7 @@
import sqljs from 'sql.js';
import { template as _template } from 'underscore';
+import axios from '~/lib/utils/axios_utils';
+import { successCodes } from '~/lib/utils/http_status';
const PREVIEW_TEMPLATE = _template(`
<div class="card">
@@ -16,30 +18,25 @@ class BalsamiqViewer {
}
loadFile(endpoint) {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest();
-
- xhr.open('GET', endpoint, true);
- xhr.responseType = 'arraybuffer';
- xhr.onload = loadEvent => this.fileLoaded(loadEvent, resolve, reject);
- xhr.onerror = reject;
-
- xhr.send();
- });
- }
-
- fileLoaded(loadEvent, resolve, reject) {
- if (loadEvent.target.status !== 200) return reject();
-
- this.renderFile(loadEvent);
-
- return resolve();
+ return axios
+ .get(endpoint, {
+ responseType: 'arraybuffer',
+ validateStatus(status) {
+ return status !== successCodes.OK;
+ },
+ })
+ .then(({ data }) => {
+ this.renderFile(data);
+ })
+ .catch(e => {
+ throw new Error(e);
+ });
}
- renderFile(loadEvent) {
+ renderFile(fileBuffer) {
const container = document.createElement('ul');
- this.initDatabase(loadEvent.target.response);
+ this.initDatabase(fileBuffer);
const previews = this.getPreviews();
previews.forEach(preview => {