From 7e6e93a11921513730d1cd013248fb3f2db3181b Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Tue, 14 Sep 2021 15:16:49 +0300 Subject: [PATCH] fix type guard --- .../src/explore/components/DatasourcePanel/types.ts | 4 ++-- .../controls/DndColumnSelectControl/DndFilterSelect.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/explore/components/DatasourcePanel/types.ts b/superset-frontend/src/explore/components/DatasourcePanel/types.ts index e2c6dc4000985..315eba93473bf 100644 --- a/superset-frontend/src/explore/components/DatasourcePanel/types.ts +++ b/superset-frontend/src/explore/components/DatasourcePanel/types.ts @@ -32,6 +32,6 @@ export function isDatasourcePanelDndItem( return item?.value && item?.type; } -export function isDndItemValue(item: any): item is DndItemValue { - return item?.value && item?.type; +export function isSavedMetric(item: any): item is Metric { + return item?.metric_name; } diff --git a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx index 7e2a49c9d6c5a..bb59b17b0c5a0 100644 --- a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx +++ b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx @@ -45,7 +45,7 @@ import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetr import { DatasourcePanelDndItem, DndItemValue, - isDndItemValue, + isSavedMetric, } from 'src/explore/components/DatasourcePanel/types'; import { DndItemType } from 'src/explore/components/DndItemType'; import { ControlComponentProps } from 'src/explore/components/Control'; @@ -351,7 +351,7 @@ export const DndFilterSelect = (props: DndFilterSelectProps) => { }, [togglePopover]); const adhocFilter = useMemo(() => { - if (isDndItemValue(droppedItem) && droppedItem?.metric_name) { + if (isSavedMetric(droppedItem)) { return new AdhocFilter({ expressionType: EXPRESSION_TYPES.SQL, clause: CLAUSES.HAVING,