MCPcopy Create free account
hub / github.com/bytebase/bytebase / mapNotificationToToast

Function mapNotificationToToast

frontend/src/react/lib/toast.ts:25–54  ·  view source on GitHub ↗
(item: NotificationCreate)

Source from the content-addressed store, hash-verified

23type ToastOptions = ToastManagerAddOptions<Record<string, unknown>>;
24
25export function mapNotificationToToast(item: NotificationCreate): ToastOptions {
26 const type = STYLE_TO_TYPE[item.style];
27 const priority: "low" | "high" = item.style === "CRITICAL" ? "high" : "low";
28 const timeout = item.manualHide
29 ? 0
30 : item.style === "CRITICAL"
31 ? CRITICAL_NOTIFICATION_DURATION_MS
32 : NOTIFICATION_DURATION_MS;
33
34 const actionProps =
35 item.link && item.linkTitle
36 ? {
37 "aria-label": item.linkTitle,
38 onClick: () => {
39 window.open(item.link, "_blank", "noopener,noreferrer");
40 },
41 children: item.linkTitle,
42 }
43 : undefined;
44
45 return {
46 title: item.title,
47 description:
48 typeof item.description === "string" ? item.description : undefined,
49 type,
50 priority,
51 timeout,
52 actionProps,
53 };
54}
55
56// Filter mirrors the previous Vue NotificationContext: only the "bytebase"
57// module renders; other modules (e.g. agent) own their own UI surface.

Callers 2

toast.test.tsFile · 0.90
pushReactNotificationFunction · 0.85

Calls 1

openMethod · 0.80

Tested by

no test coverage detected