(item: NotificationCreate)
| 23 | type ToastOptions = ToastManagerAddOptions<Record<string, unknown>>; |
| 24 | |
| 25 | export 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. |
no test coverage detected