debian-mirror-gitlab/app/assets/javascripts/init_confirm_danger.js
2022-01-26 12:08:38 +05:30

40 lines
919 B
JavaScript

import Vue from 'vue';
import { parseBoolean } from './lib/utils/common_utils';
import ConfirmDanger from './vue_shared/components/confirm_danger/confirm_danger.vue';
export default () => {
const el = document.querySelector('.js-confirm-danger');
if (!el) return null;
const {
removeFormId = null,
phrase,
buttonText,
buttonClass = '',
buttonTestid = null,
confirmDangerMessage,
disabled = false,
} = el.dataset;
return new Vue({
el,
provide: {
confirmDangerMessage,
},
render: (createElement) =>
createElement(ConfirmDanger, {
props: {
phrase,
buttonText,
buttonClass,
buttonTestid,
disabled: parseBoolean(disabled),
},
on: {
confirm: () => {
if (removeFormId) document.getElementById(removeFormId)?.submit();
},
},
}),
});
};