0b38e0a247
This is one of many MRs opened in order to improve the overall internationalisation of the GitLab codebase. This commit only targets Vanilla JS files. i18n documentation https://docs.gitlab.com/ee/development/i18n/externalization.html
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import $ from 'jquery';
|
|
import { parseQueryStringIntoObject } from '~/lib/utils/common_utils';
|
|
import axios from '~/lib/utils/axios_utils';
|
|
import createFlash from '~/flash';
|
|
import { __ } from '~/locale';
|
|
|
|
export default class GpgBadges {
|
|
static fetch() {
|
|
const tag = $('.js-signature-container');
|
|
if (tag.length === 0) {
|
|
return Promise.resolve();
|
|
}
|
|
|
|
const badges = $('.js-loading-gpg-badge');
|
|
|
|
badges.html('<i class="fa fa-spinner fa-spin"></i>');
|
|
|
|
const displayError = () => createFlash(__('An error occurred while loading commit signatures'));
|
|
|
|
const endpoint = tag.data('signaturesPath');
|
|
if (!endpoint) {
|
|
displayError();
|
|
return Promise.reject(new Error(__('Missing commit signatures endpoint!')));
|
|
}
|
|
|
|
const params = parseQueryStringIntoObject(tag.serialize());
|
|
return axios
|
|
.get(endpoint, { params })
|
|
.then(({ data }) => {
|
|
data.signatures.forEach(signature => {
|
|
badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html);
|
|
});
|
|
})
|
|
.catch(displayError);
|
|
}
|
|
}
|