2023-06-19 03:46:50 -04:00
|
|
|
import $ from 'jquery';
|
|
|
|
import {svg} from '../../svg.js';
|
|
|
|
import {htmlEscape} from 'escape-goat';
|
|
|
|
|
|
|
|
const {i18n} = window.config;
|
|
|
|
|
2023-09-18 18:05:31 -04:00
|
|
|
export async function confirmModal(opts = {content: '', buttonColor: 'primary'}) {
|
2023-06-19 03:46:50 -04:00
|
|
|
return new Promise((resolve) => {
|
|
|
|
const $modal = $(`
|
|
|
|
<div class="ui g-modal-confirm modal">
|
|
|
|
<div class="content">${htmlEscape(opts.content)}</div>
|
|
|
|
<div class="actions">
|
2023-09-18 18:05:31 -04:00
|
|
|
<button class="ui cancel button">${svg('octicon-x')} ${i18n.modal_cancel}</button>
|
|
|
|
<button class="ui ${opts.buttonColor || 'primary'} ok button">${svg('octicon-check')} ${i18n.modal_confirm}</button>
|
2023-06-19 03:46:50 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`);
|
|
|
|
|
|
|
|
$modal.appendTo(document.body);
|
|
|
|
$modal.modal({
|
|
|
|
onApprove() {
|
|
|
|
resolve(true);
|
|
|
|
},
|
|
|
|
onHidden() {
|
|
|
|
$modal.remove();
|
|
|
|
resolve(false);
|
|
|
|
},
|
|
|
|
}).modal('show');
|
|
|
|
});
|
|
|
|
}
|