diff options
Diffstat (limited to 'app/assets/javascripts/gpg_badges.js')
-rw-r--r-- | app/assets/javascripts/gpg_badges.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/assets/javascripts/gpg_badges.js b/app/assets/javascripts/gpg_badges.js new file mode 100644 index 00000000000..502e3569321 --- /dev/null +++ b/app/assets/javascripts/gpg_badges.js @@ -0,0 +1,23 @@ +import $ from 'jquery'; +import { parseQueryStringIntoObject } from '~/lib/utils/common_utils'; +import axios from '~/lib/utils/axios_utils'; +import flash from '~/flash'; +import { __ } from '~/locale'; + +export default class GpgBadges { + static fetch() { + const badges = $('.js-loading-gpg-badge'); + const form = $('.commits-search-form'); + + badges.html('<i class="fa fa-spinner fa-spin"></i>'); + + const params = parseQueryStringIntoObject(form.serialize()); + return axios.get(form.data('signaturesPath'), { params }) + .then(({ data }) => { + data.signatures.forEach((signature) => { + badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html); + }); + }) + .catch(() => flash(__('An error occurred while loading commits'))); + } +} |