Skip to content

Commit

Permalink
fix type guard
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Sep 14, 2021
1 parent 76e4a7c commit 7e6e93a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7e6e93a

Please sign in to comment.