1
0
Fork 0
forked from forgejo/forgejo

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

![image](b7a14ed6-db89-4f21-a590-66cd33307233)

(cherry picked from commit 27deea7330f83ddb37c918afbb4159053d8847cb)
This commit is contained in:
wxiaoguang 2024-03-02 23:05:07 +08:00 committed by Earl Warren
parent d509031e84
commit 221a28436a
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
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,