d4ed2f74e3
This is one of many MRs opened in order to improve the overall internationalisation of the GitLab codebase. This commit only targets Vanilla JS files. i18n documentation https://docs.gitlab.com/ee/development/i18n/externalization.html
32 lines
935 B
JavaScript
32 lines
935 B
JavaScript
import $ from 'jquery';
|
|
import axios from './lib/utils/axios_utils';
|
|
import Flash, { hideFlash } from './flash';
|
|
import { parseBoolean } from './lib/utils/common_utils';
|
|
import { __ } from './locale';
|
|
|
|
export default () => {
|
|
$('body').on('click', '.js-usage-consent-action', e => {
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation(); // overwrite rails listener
|
|
|
|
const { url, checkEnabled, pingEnabled } = e.target.dataset;
|
|
const data = {
|
|
application_setting: {
|
|
version_check_enabled: parseBoolean(checkEnabled),
|
|
usage_ping_enabled: parseBoolean(pingEnabled),
|
|
},
|
|
};
|
|
|
|
const hideConsentMessage = () => hideFlash(document.querySelector('.ping-consent-message'));
|
|
|
|
axios
|
|
.put(url, data)
|
|
.then(() => {
|
|
hideConsentMessage();
|
|
})
|
|
.catch(() => {
|
|
hideConsentMessage();
|
|
Flash(__('Something went wrong. Try again later.'));
|
|
});
|
|
});
|
|
};
|