From 90aa4bc5925b5eabfb3096187d61999115f50146 Mon Sep 17 00:00:00 2001 From: Ernest Iliiasov Date: Fri, 21 Mar 2025 20:07:45 -0600 Subject: [PATCH] fix: Show threshold chart when creating alerts for unsaved search --- packages/app/src/DBSearchPageAlertModal.tsx | 60 +++++++++++-------- .../app/src/components/AlertPreviewChart.tsx | 24 +++++--- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/packages/app/src/DBSearchPageAlertModal.tsx b/packages/app/src/DBSearchPageAlertModal.tsx index 8df2ef45f6..4faac045c3 100644 --- a/packages/app/src/DBSearchPageAlertModal.tsx +++ b/packages/app/src/DBSearchPageAlertModal.tsx @@ -9,7 +9,8 @@ import { AlertIntervalSchema, AlertSource, AlertThresholdType, - SavedSearch, + SearchCondition, + SearchConditionLanguage, zAlertChannel, } from '@hyperdx/common-utils/dist/types'; import { TextInput } from '@mantine/core'; @@ -58,23 +59,29 @@ const CHANNEL_ICONS = { }; const AlertForm = ({ - savedSearch, + sourceId, + where, + whereLanguage, defaultValues, loading, deleteLoading, + hasSavedSearch, onDelete, onSubmit, onClose, }: { - savedSearch?: SavedSearch; + sourceId?: string | null; + where?: SearchCondition | null; + whereLanguage?: SearchConditionLanguage | null; defaultValues?: null | Alert; loading?: boolean; deleteLoading?: boolean; + hasSavedSearch?: boolean; onDelete: (id: string) => void; onSubmit: (data: Alert) => void; onClose: () => void; }) => { - const { data: source } = useSource({ id: savedSearch?.source }); + const { data: source } = useSource({ id: sourceId }); const databaseName = source?.from.databaseName; const tableName = source?.from.tableName; @@ -159,24 +166,24 @@ const AlertForm = ({ - {savedSearch && ( - - - }> - Threshold chart - - - - - - - )} + + + }> + Threshold chart + + + + + +
@@ -199,9 +206,9 @@ const AlertForm = ({ @@ -390,8 +397,11 @@ export const DBSearchPageAlertModal = ({ { - const { data: source } = useSource({ id: savedSearch?.source }); + const { data: source } = useSource({ id: sourceId }); - if (!savedSearch || !source) { + if (!sourceId || !source) { return null; } return (