normalize headers correctly

i18n flash message
This commit is contained in:
Phil Hughes 2018-01-26 15:04:44 +00:00
parent c49fecdea5
commit cf4fb53f56
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
3 changed files with 5 additions and 13 deletions

View File

@ -77,7 +77,7 @@ export default class Compare {
}).then(({ data }) => {
loading.hide();
$target.html(data);
var className = '.' + $target[0].className.replace(' ', '.');
const className = '.' + $target[0].className.replace(' ', '.');
localTimeAgo($('.js-timeago', className));
});
}

View File

@ -1,4 +1,5 @@
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */
import { __ } from './locale';
import axios from './lib/utils/axios_utils';
import flash from './flash';
@ -19,7 +20,7 @@ export default function initCompareAutocomplete() {
},
}).then(({ data }) => {
callback(data);
}).catch(() => flash('Error fetching refs'));
}).catch(() => flash(__('Error fetching refs')));
},
selectable: true,
filterable: true,

View File

@ -1,6 +1,6 @@
import FilterableList from '~/filterable_list';
import eventHub from './event_hub';
import { getParameterByName } from '../lib/utils/common_utils';
import { normalizeHeaders, getParameterByName } from '../lib/utils/common_utils';
export default class GroupFilterableList extends FilterableList {
constructor({ form, filter, holder, filterEndpoint, pagePath, dropdownSel, filterInputField }) {
@ -97,20 +97,11 @@ export default class GroupFilterableList extends FilterableList {
onFilterSuccess(res, queryData) {
const currentPath = this.getPagePath(queryData);
const paginationData = {
'X-Per-Page': res.headers['x-per-page'],
'X-Page': res.headers['x-page'],
'X-Total': res.headers['x-total'],
'X-Total-Pages': res.headers['x-total-pages'],
'X-Next-Page': res.headers['x-next-page'],
'X-Prev-Page': res.headers['x-prev-page'],
};
window.history.replaceState({
page: currentPath,
}, document.title, currentPath);
eventHub.$emit('updateGroups', res.data, Object.prototype.hasOwnProperty.call(queryData, this.filterInputField));
eventHub.$emit('updatePagination', paginationData);
eventHub.$emit('updatePagination', normalizeHeaders(res.headers));
}
}