Make PR form use toast to show error message (#29545)

![image](b7a14ed6-db89-4f21-a590-66cd33307233)
This commit is contained in:
wxiaoguang 2024-03-02 23:05:07 +08:00 committed by GitHub
parent cc27b50bdf
commit 27deea7330
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 35 additions and 30 deletions

View file

@ -21,13 +21,12 @@ const levels = {
};
// See https://github.com/apvarun/toastify-js#api for options
function showToast(message, level, {gravity, position, duration, ...other} = {}) {
function showToast(message, level, {gravity, position, duration, useHtmlBody, ...other} = {}) {
const {icon, background, duration: levelDuration} = levels[level ?? 'info'];
const toast = Toastify({
text: `
<div class='toast-icon'>${svg(icon)}</div>
<div class='toast-body'>${htmlEscape(message)}</div>
<div class='toast-body'>${useHtmlBody ? message : htmlEscape(message)}</div>
<button class='toast-close'>${svg('octicon-x')}</button>
`,
escapeMarkup: false,