2018-02-12 05:58:45 -05:00
|
|
|
import { parseQueryStringIntoObject } from '~/lib/utils/common_utils';
|
2018-02-08 03:47:31 -05:00
|
|
|
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() {
|
2017-08-15 04:20:35 -04:00
|
|
|
const badges = $('.js-loading-gpg-badge');
|
2017-07-25 03:40:23 -04:00
|
|
|
const form = $('.commits-search-form');
|
|
|
|
|
2017-08-15 04:20:35 -04:00
|
|
|
badges.html('<i class="fa fa-spinner fa-spin"></i>');
|
|
|
|
|
2018-02-12 05:58:45 -05:00
|
|
|
const params = parseQueryStringIntoObject(form.serialize());
|
2018-02-20 17:20:48 -05:00
|
|
|
return axios.get(form.data('signaturesPath'), { params })
|
2018-02-08 03:47:31 -05:00
|
|
|
.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);
|
|
|
|
});
|
2018-02-08 03:47:31 -05:00
|
|
|
})
|
2018-02-08 09:37:43 -05:00
|
|
|
.catch(() => flash(__('An error occurred while loading commits')));
|
2017-07-25 03:40:23 -04:00
|
|
|
}
|
|
|
|
}
|