From 092d164d55dd4784036f47f11cb28d7811b2a27f Mon Sep 17 00:00:00 2001 From: Rajat Dabade Date: Wed, 1 Nov 2023 22:47:27 +0530 Subject: [PATCH] refactor: global time range downdown for alert edit page (#3751) * refactor: global time range downdown for alert edit page * refactor: respect global time range for alerts * refactor: some ui fixes * refactor: added global time range in alert new page * fix: custom time selection in alert * fix: the run query works * refactor: remove the routes pipeline --------- Co-authored-by: Srikanth Chekuri Co-authored-by: Ankit Nayan --- .../container/FormAlertRules/BasicInfo.tsx | 2 ++ .../FormAlertRules/ChartPreview/index.tsx | 8 ++++++ .../container/FormAlertRules/RuleOptions.tsx | 6 +++++ .../src/container/FormAlertRules/index.tsx | 25 ++++++------------- .../BuilderUnitsFilter/BuilderUnits.tsx | 2 ++ .../TopNav/DateTimeSelection/config.ts | 3 --- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/frontend/src/container/FormAlertRules/BasicInfo.tsx b/frontend/src/container/FormAlertRules/BasicInfo.tsx index 595e6facd6..3d96e7fb79 100644 --- a/frontend/src/container/FormAlertRules/BasicInfo.tsx +++ b/frontend/src/container/FormAlertRules/BasicInfo.tsx @@ -2,6 +2,7 @@ import { Form, Select } from 'antd'; import { useTranslation } from 'react-i18next'; import { AlertDef, Labels } from 'types/api/alerts/def'; import { requireErrorMessage } from 'utils/form/requireErrorMessage'; +import { popupContainer } from 'utils/selectPopupContainer'; import ChannelSelect from './ChannelSelect'; import LabelSelect from './labels'; @@ -36,6 +37,7 @@ function BasicInfo({ alertDef, setAlertDef }: BasicInfoProps): JSX.Element { name={['labels', 'severity']} > { const s = (value as string) || 'critical'; diff --git a/frontend/src/container/FormAlertRules/ChartPreview/index.tsx b/frontend/src/container/FormAlertRules/ChartPreview/index.tsx index c00b78b449..9fdc30d835 100644 --- a/frontend/src/container/FormAlertRules/ChartPreview/index.tsx +++ b/frontend/src/container/FormAlertRules/ChartPreview/index.tsx @@ -9,9 +9,12 @@ import { useGetQueryRange } from 'hooks/queryBuilder/useGetQueryRange'; import getChartData from 'lib/getChartData'; import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; +import { useSelector } from 'react-redux'; +import { AppState } from 'store/reducers'; import { AlertDef } from 'types/api/alerts/def'; import { Query } from 'types/api/queryBuilder/queryBuilderData'; import { EQueryType } from 'types/common/dashboard'; +import { GlobalReducer } from 'types/reducer/globalTime'; import { ChartContainer, FailedMessageContainer } from './styles'; import { covertIntoDataFormats } from './utils'; @@ -41,6 +44,9 @@ function ChartPreview({ }: ChartPreviewProps): JSX.Element | null { const { t } = useTranslation('alerts'); const threshold = alertDef?.condition.target || 0; + const { minTime, maxTime } = useSelector( + (state) => state.globalTime, + ); const thresholdValue = covertIntoDataFormats({ value: threshold, @@ -100,6 +106,8 @@ function ChartPreview({ 'chartPreview', userQueryKey || JSON.stringify(query), selectedInterval, + minTime, + maxTime, ], retry: false, enabled: canQuery, diff --git a/frontend/src/container/FormAlertRules/RuleOptions.tsx b/frontend/src/container/FormAlertRules/RuleOptions.tsx index 8ece1562fe..1456268bd2 100644 --- a/frontend/src/container/FormAlertRules/RuleOptions.tsx +++ b/frontend/src/container/FormAlertRules/RuleOptions.tsx @@ -20,6 +20,7 @@ import { defaultMatchType, } from 'types/api/alerts/def'; import { EQueryType } from 'types/common/dashboard'; +import { popupContainer } from 'utils/selectPopupContainer'; import { FormContainer, InlineSelect, StepHeading } from './styles'; @@ -45,6 +46,7 @@ function RuleOptions({ const renderCompareOps = (): JSX.Element => ( ( ( (