import {svg} from '../../svg.ts'; import {htmlEscape} from 'escape-goat'; import {createElementFromHTML} from '../../utils/dom.ts'; import {fomanticQuery} from '../../modules/fomantic/base.ts'; const {i18n} = window.config; export function confirmModal({header = '', content = '', confirmButtonColor = 'primary'} = {}): Promise { return new Promise((resolve) => { const headerHtml = header ? `${htmlEscape(header)}` : ''; const modal = createElementFromHTML(` ${headerHtml} ${htmlEscape(content)} ${svg('octicon-x')} ${htmlEscape(i18n.modal_cancel)} ${svg('octicon-check')} ${htmlEscape(i18n.modal_confirm)} `); document.body.append(modal); const $modal = fomanticQuery(modal); $modal.modal({ onApprove() { resolve(true); }, onHidden() { $modal.remove(); resolve(false); }, }).modal('show'); }); }