From 9614d12247e9dc4a5254883782eddf46d921e823 Mon Sep 17 00:00:00 2001 From: sylenien Date: Tue, 23 Aug 2022 17:31:41 +0200 Subject: [PATCH] fix(ui): prevent crashing when webhooks are loading --- .../Dashboard/components/Alerts/AlertForm/Condition.tsx | 2 +- .../Dashboard/components/Alerts/AlertListItem.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/Dashboard/components/Alerts/AlertForm/Condition.tsx b/frontend/app/components/Dashboard/components/Alerts/AlertForm/Condition.tsx index f30cfd7d9..dcb24d6e4 100644 --- a/frontend/app/components/Dashboard/components/Alerts/AlertForm/Condition.tsx +++ b/frontend/app/components/Dashboard/components/Alerts/AlertForm/Condition.tsx @@ -75,7 +75,7 @@ function Condition({ placeholder="Select Condition" options={conditions} name="operator" - defaultValue={instance.query.operator} + value={conditions.find(c => c.value === instance.query.operator)} onChange={({ value }) => writeQueryOption(null, { name: 'operator', value: value.value }) } diff --git a/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx b/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx index 3c9254a7d..1aaf422d7 100644 --- a/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx +++ b/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx @@ -17,6 +17,10 @@ const getThreshold = (threshold: number) => { }; const getNotifyChannel = (alert: Record, webhooks: Array) => { + // @ts-ignore god damn you immutable + if (webhooks.size === 0) { + return 'OpenReplay'; + } const getSlackChannels = () => { return ( ' (' + @@ -57,6 +61,10 @@ interface Props extends RouteComponentProps { function AlertListItem(props: Props) { const { alert, siteId, history, init, demo, webhooks } = props; + if (!alert) { + return null; + } + const onItemClick = () => { if (demo) return; const path = withSiteId(alertEdit(alert.alertId), siteId);