gitlab-org--gitlab-foss/app/assets/javascripts/gpg_badges.js

23 lines
773 B
JavaScript
Raw Normal View History

import { parseQueryStringIntoObject } from '~/lib/utils/common_utils';
import axios from '~/lib/utils/axios_utils';
import flash from '~/flash';
import { __ } from '~/locale';
2017-07-25 03:40:23 -04:00
export default class GpgBadges {
static fetch() {
const badges = $('.js-loading-gpg-badge');
2017-07-25 03:40:23 -04:00
const form = $('.commits-search-form');
badges.html('<i class="fa fa-spinner fa-spin"></i>');
const params = parseQueryStringIntoObject(form.serialize());
2018-02-20 17:20:48 -05:00
return axios.get(form.data('signaturesPath'), { params })
.then(({ data }) => {
data.signatures.forEach((signature) => {
2017-07-25 03:40:23 -04:00
badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html);
});
})
.catch(() => flash(__('An error occurred while loading commits')));
2017-07-25 03:40:23 -04:00
}
}