mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-06 07:38:42 +00:00
Keep `swagger` and `external-render-helper` as a standalone entries for external render. - Move `devtest.ts` to `modules/` as init functions - Make external renders correctly load its helper JS and Gitea's current theme - Make external render iframe inherit Gitea's iframe's background color to avoid flicker - Add e2e tests for external render and OpenAPI iframe --------- Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
21 lines
773 B
TypeScript
21 lines
773 B
TypeScript
import {showInfoToast, showWarningToast, showErrorToast} from './toast.ts';
|
|
import type {Toast} from './toast.ts';
|
|
import {registerGlobalInitFunc} from './observer.ts';
|
|
|
|
type LevelMap = Record<string, (message: string) => Toast | null>;
|
|
|
|
export function initDevtest() {
|
|
registerGlobalInitFunc('initDevtestPage', () => {
|
|
const els = document.querySelectorAll('.toast-test-button');
|
|
if (!els.length) return;
|
|
const levelMap: LevelMap = {info: showInfoToast, warning: showWarningToast, error: showErrorToast};
|
|
for (const el of els) {
|
|
el.addEventListener('click', () => {
|
|
const level = el.getAttribute('data-toast-level')!;
|
|
const message = el.getAttribute('data-toast-message')!;
|
|
levelMap[level](message);
|
|
});
|
|
}
|
|
});
|
|
}
|