From 1c98d4f55c0426f1e9c2d5229dd852cfabfed722 Mon Sep 17 00:00:00 2001 From: Palash Gupta Date: Wed, 21 Jun 2023 20:56:15 +0530 Subject: [PATCH] fix: editing condition is updated (#2952) * 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 * fix: edit condition is fixed * fix: isTraceOrLogsQueryBuilder condition for editing a panel * fix: error message is shown to the user --------- Co-authored-by: makeavish --- frontend/src/container/NewWidget/index.tsx | 26 ++++++++++++++++++- .../store/actions/dashboard/saveDashboard.ts | 9 ++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/frontend/src/container/NewWidget/index.tsx b/frontend/src/container/NewWidget/index.tsx index 3919f8fe12..17cb4ea884 100644 --- a/frontend/src/container/NewWidget/index.tsx +++ b/frontend/src/container/NewWidget/index.tsx @@ -163,7 +163,7 @@ function NewWidget({ selectedGraph, saveSettingOfPanel }: Props): JSX.Element { FeatureKeys.QUERY_BUILDER_PANELS, ); - const isSaveDisabled = useMemo( + const isNewTraceLogsAvailable = useMemo( () => isQueryBuilderActive && currentQuery.queryType === EQueryType.QUERY_BUILDER && @@ -177,6 +177,30 @@ function NewWidget({ selectedGraph, saveSettingOfPanel }: Props): JSX.Element { ], ); + const isSaveDisabled = useMemo(() => { + // new created dashboard + if (selectedWidget?.id === 'empty') { + return isNewTraceLogsAvailable; + } + + const isTraceOrLogsQueryBuilder = + currentQuery.builder.queryData.find( + (query) => + query.dataSource === DataSource.TRACES || + query.dataSource === DataSource.LOGS, + ) !== undefined; + + if (isTraceOrLogsQueryBuilder) { + return false; + } + + return isNewTraceLogsAvailable; + }, [ + currentQuery.builder.queryData, + selectedWidget?.id, + isNewTraceLogsAvailable, + ]); + return ( diff --git a/frontend/src/store/actions/dashboard/saveDashboard.ts b/frontend/src/store/actions/dashboard/saveDashboard.ts index ac7516ff6e..107fecee25 100644 --- a/frontend/src/store/actions/dashboard/saveDashboard.ts +++ b/frontend/src/store/actions/dashboard/saveDashboard.ts @@ -1,3 +1,4 @@ +import { notification } from 'antd'; import updateDashboardApi from 'api/dashboard/update'; import { AxiosError } from 'axios'; import { COMPOSITE_QUERY } from 'constants/queryBuilderQueryNames'; @@ -129,10 +130,16 @@ export const SaveDashboard = ({ }); history.push(generatePath(ROUTES.DASHBOARD, { dashboardId })); } else { + const error = 'Something went wrong'; + + notification.error({ + message: response.error || error, + }); + dispatch({ type: 'SAVE_SETTING_TO_PANEL_ERROR', payload: { - errorMessage: response.error || 'Something went wrong', + errorMessage: response.error || error, }, }); }