debian-mirror-gitlab/app/assets/javascripts/gpg_badges.js

24 lines
797 B
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2018-03-27 19:54:05 +05:30
import { parseQueryStringIntoObject } from '~/lib/utils/common_utils';
import axios from '~/lib/utils/axios_utils';
import flash from '~/flash';
import { __ } from '~/locale';
2017-09-10 17:25:29 +05:30
export default class GpgBadges {
static fetch() {
const badges = $('.js-loading-gpg-badge');
2018-10-15 14:42:47 +05:30
const tag = $('.js-signature-container');
2017-09-10 17:25:29 +05:30
badges.html('<i class="fa fa-spinner fa-spin"></i>');
2018-10-15 14:42:47 +05:30
const params = parseQueryStringIntoObject(tag.serialize());
return axios.get(tag.data('signaturesPath'), { params })
2018-03-27 19:54:05 +05:30
.then(({ data }) => {
data.signatures.forEach((signature) => {
2017-09-10 17:25:29 +05:30
badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html);
});
2018-03-27 19:54:05 +05:30
})
.catch(() => flash(__('An error occurred while loading commits')));
2017-09-10 17:25:29 +05:30
}
}