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
This commit is contained in:
Palash Gupta 2023-06-21 19:56:57 +05:30 committed by GitHub
parent 3f4cd130ed
commit a6237d8640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 10 deletions

View File

@ -380,8 +380,8 @@ function FormAlertRules({
const isAlertAvialableToSave = const isAlertAvialableToSave =
isAlertAvialable && isAlertAvialable &&
isNewRule && currentQuery.queryType === EQueryType.QUERY_BUILDER &&
currentQuery.queryType === EQueryType.QUERY_BUILDER; alertType !== AlertTypes.METRICS_BASED_ALERT;
return ( return (
<> <>

View File

@ -20,6 +20,8 @@ import {
import { AppState } from 'store/reducers'; import { AppState } from 'store/reducers';
import AppActions from 'types/actions'; import AppActions from 'types/actions';
import { FLUSH_DASHBOARD } from 'types/actions/dashboard'; 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 AppReducer from 'types/reducer/app';
import DashboardReducer from 'types/reducer/dashboards'; import DashboardReducer from 'types/reducer/dashboards';
@ -161,15 +163,29 @@ function NewWidget({ selectedGraph, saveSettingOfPanel }: Props): JSX.Element {
FeatureKeys.QUERY_BUILDER_PANELS, 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 ( return (
<Container> <Container>
<ButtonContainer> <ButtonContainer>
{isQueryBuilderActive && ( {isSaveDisabled && (
<Tooltip title={MESSAGE.PANEL}> <Tooltip title={MESSAGE.PANEL}>
<Button <Button
icon={<LockFilled />} icon={<LockFilled />}
type="primary" type="primary"
disabled={isQueryBuilderActive} disabled={isSaveDisabled}
onClick={onSaveDashboard} onClick={onSaveDashboard}
> >
Save Save
@ -177,12 +193,8 @@ function NewWidget({ selectedGraph, saveSettingOfPanel }: Props): JSX.Element {
</Tooltip> </Tooltip>
)} )}
{!isQueryBuilderActive && ( {!isSaveDisabled && (
<Button <Button type="primary" disabled={isSaveDisabled} onClick={onSaveDashboard}>
type="primary"
disabled={isQueryBuilderActive}
onClick={onSaveDashboard}
>
Save Save
</Button> </Button>
)} )}