gpg_badges.js 774 Bytes
Newer Older
1
import { parseQueryStringIntoObject } from '~/lib/utils/common_utils';
2 3 4 5
import axios from '~/lib/utils/axios_utils';
import flash from '~/flash';
import { __ } from '~/locale';

6 7
export default class GpgBadges {
  static fetch() {
8
    const badges = $('.js-loading-gpg-badge');
9 10
    const form = $('.commits-search-form');

11 12
    badges.html('<i class="fa fa-spinner fa-spin"></i>');

13
    const params = parseQueryStringIntoObject(form.serialize());
14
    return axios.get(form.data('signatures-path'), { params })
15 16
    .then(({ data }) => {
      data.signatures.forEach((signature) => {
17 18
        badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html);
      });
19
    })
20
    .catch(() => flash(__('An error occurred while loading commits')));
21 22
  }
}