+
+
+ {alert ? `${getAlertDisplayName(alert)} - Alerts` : 'Alerts'} -{' '}
+ {brandName}
+
+
+ {isLoading && (
+
+
+
+
+
+
+
+ )}
+ {!isLoading && (isError || !alert) && (
+
+
+ Back to alerts
+
+ }
+ />
+
+ )}
+ {!isLoading && alert &&
}
+
+ );
+}
+
+AlertDetailPage.getLayout = withAppNav;
diff --git a/packages/app/src/AlertsPage.tsx b/packages/app/src/AlertsPage.tsx
index 1d1345c0f3..78d67e6a11 100644
--- a/packages/app/src/AlertsPage.tsx
+++ b/packages/app/src/AlertsPage.tsx
@@ -12,6 +12,7 @@ import {
Alert,
Anchor,
Badge,
+ Button,
Collapse,
Container,
Flex,
@@ -51,7 +52,7 @@ import type { AlertsPageItem } from './types';
import styles from '@styles/AlertsPage.module.scss';
-function getAlertDisplayName(alert: AlertsPageItem): string {
+export function getAlertDisplayName(alert: AlertsPageItem): string {
if (alert.source === AlertSource.TILE && alert.dashboard) {
const tile = alert.dashboard.tiles.find(t => t.id === alert.tileId);
const tileName = tile?.config.name || 'Tile';
@@ -63,6 +64,17 @@ function getAlertDisplayName(alert: AlertsPageItem): string {
return '';
}
+/** URL of the saved search / dashboard tile the alert is watching. */
+export function getAlertSourceUrl(alert: AlertsPageItem): string {
+ if (alert.source === AlertSource.TILE && alert.dashboard) {
+ return `/dashboards/${alert.dashboardId}?highlightedTileId=${alert.tileId}`;
+ }
+ if (alert.source === AlertSource.SAVED_SEARCH && alert.savedSearch) {
+ return `/search/${alert.savedSearchId}`;
+ }
+ return '';
+}
+
function getAlertTags(alert: AlertsPageItem): string[] {
return alert.dashboard?.tags ?? alert.savedSearch?.tags ?? [];
}
@@ -72,7 +84,7 @@ function getAlertCreatorLabel(alert: AlertsPageItem): string | undefined {
return alert.createdBy.name || alert.createdBy.email;
}
-function AlertNote({ note }: { note: string }) {
+export function AlertNote({ note }: { note: string }) {
const [opened, { toggle }] = useDisclosure(false);
return (
@@ -147,15 +159,7 @@ function AlertDetails({ alert }: { alert: AlertsPageItem }) {
return '–';
}, [alert]);
- const alertUrl = React.useMemo(() => {
- if (alert.source === AlertSource.TILE && alert.dashboard) {
- return `/dashboards/${alert.dashboardId}?highlightedTileId=${alert.tileId}`;
- }
- if (alert.source === AlertSource.SAVED_SEARCH && alert.savedSearch) {
- return `/search/${alert.savedSearchId}`;
- }
- return '';
- }, [alert]);
+ const alertUrl = React.useMemo(() => getAlertSourceUrl(alert), [alert]);
const alertIcon = (() => {
switch (alert.source) {
@@ -268,6 +272,15 @@ function AlertDetails({ alert }: { alert: AlertsPageItem }) {