From a6237d8640f6b74201eb0febe3c2d209f069635f Mon Sep 17 00:00:00 2001 From: Palash Gupta Date: Wed, 21 Jun 2023 19:56:57 +0530 Subject: [PATCH] fix: save rules/dashboard is now enabled for metrics irrespective of feature flag disabled (#2946) * fix: save rules/dashboard is now enabled for metrics irrespective of feature flag disabled * chore: check is updated for alerts * chore: alert condition is updated * chore: condition for alert is updated --- .../src/container/FormAlertRules/index.tsx | 4 +-- frontend/src/container/NewWidget/index.tsx | 28 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/frontend/src/container/FormAlertRules/index.tsx b/frontend/src/container/FormAlertRules/index.tsx index e903945fea..9db261afd0 100644 --- a/frontend/src/container/FormAlertRules/index.tsx +++ b/frontend/src/container/FormAlertRules/index.tsx @@ -380,8 +380,8 @@ function FormAlertRules({ const isAlertAvialableToSave = isAlertAvialable && - isNewRule && - currentQuery.queryType === EQueryType.QUERY_BUILDER; + currentQuery.queryType === EQueryType.QUERY_BUILDER && + alertType !== AlertTypes.METRICS_BASED_ALERT; return ( <> diff --git a/frontend/src/container/NewWidget/index.tsx b/frontend/src/container/NewWidget/index.tsx index 2352f506c5..3919f8fe12 100644 --- a/frontend/src/container/NewWidget/index.tsx +++ b/frontend/src/container/NewWidget/index.tsx @@ -20,6 +20,8 @@ import { import { AppState } from 'store/reducers'; import AppActions from 'types/actions'; import { FLUSH_DASHBOARD } from 'types/actions/dashboard'; +import { EQueryType } from 'types/common/dashboard'; +import { DataSource } from 'types/common/queryBuilder'; import AppReducer from 'types/reducer/app'; import DashboardReducer from 'types/reducer/dashboards'; @@ -161,15 +163,29 @@ function NewWidget({ selectedGraph, saveSettingOfPanel }: Props): JSX.Element { FeatureKeys.QUERY_BUILDER_PANELS, ); + const isSaveDisabled = useMemo( + () => + isQueryBuilderActive && + currentQuery.queryType === EQueryType.QUERY_BUILDER && + currentQuery.builder.queryData.find( + (query) => query.dataSource !== DataSource.METRICS, + ) !== undefined, + [ + currentQuery.builder.queryData, + currentQuery.queryType, + isQueryBuilderActive, + ], + ); + return ( - {isQueryBuilderActive && ( + {isSaveDisabled && ( )}