mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 03:39:02 +08:00
fix: block alert creation if query_range API fails (#5441)
This commit is contained in:
parent
42f7905b3b
commit
46e6c34e51
@ -48,6 +48,7 @@ export interface ChartPreviewProps {
|
|||||||
userQueryKey?: string;
|
userQueryKey?: string;
|
||||||
allowSelectedIntervalForStepGen?: boolean;
|
allowSelectedIntervalForStepGen?: boolean;
|
||||||
yAxisUnit: string;
|
yAxisUnit: string;
|
||||||
|
setQueryStatus?: (status: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||||
@ -62,6 +63,7 @@ function ChartPreview({
|
|||||||
allowSelectedIntervalForStepGen = false,
|
allowSelectedIntervalForStepGen = false,
|
||||||
alertDef,
|
alertDef,
|
||||||
yAxisUnit,
|
yAxisUnit,
|
||||||
|
setQueryStatus,
|
||||||
}: ChartPreviewProps): JSX.Element | null {
|
}: ChartPreviewProps): JSX.Element | null {
|
||||||
const { t } = useTranslation('alerts');
|
const { t } = useTranslation('alerts');
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -149,10 +151,10 @@ function ChartPreview({
|
|||||||
|
|
||||||
useEffect((): void => {
|
useEffect((): void => {
|
||||||
const { startTime, endTime } = getTimeRange(queryResponse);
|
const { startTime, endTime } = getTimeRange(queryResponse);
|
||||||
|
if (setQueryStatus) setQueryStatus(queryResponse.status);
|
||||||
setMinTimeScale(startTime);
|
setMinTimeScale(startTime);
|
||||||
setMaxTimeScale(endTime);
|
setMaxTimeScale(endTime);
|
||||||
}, [maxTime, minTime, globalSelectedInterval, queryResponse]);
|
}, [maxTime, minTime, globalSelectedInterval, queryResponse, setQueryStatus]);
|
||||||
|
|
||||||
if (queryResponse.data && graphType === PANEL_TYPES.BAR) {
|
if (queryResponse.data && graphType === PANEL_TYPES.BAR) {
|
||||||
const sortedSeriesData = getSortedSeriesData(
|
const sortedSeriesData = getSortedSeriesData(
|
||||||
@ -284,6 +286,7 @@ ChartPreview.defaultProps = {
|
|||||||
userQueryKey: '',
|
userQueryKey: '',
|
||||||
allowSelectedIntervalForStepGen: false,
|
allowSelectedIntervalForStepGen: false,
|
||||||
alertDef: undefined,
|
alertDef: undefined,
|
||||||
|
setQueryStatus: (): void => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ChartPreview;
|
export default ChartPreview;
|
||||||
|
@ -101,6 +101,7 @@ function FormAlertRules({
|
|||||||
const isNewRule = ruleId === 0;
|
const isNewRule = ruleId === 0;
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [queryStatus, setQueryStatus] = useState<string>('');
|
||||||
|
|
||||||
// alertDef holds the form values to be posted
|
// alertDef holds the form values to be posted
|
||||||
const [alertDef, setAlertDef] = useState<AlertDef>(initialValue);
|
const [alertDef, setAlertDef] = useState<AlertDef>(initialValue);
|
||||||
@ -523,6 +524,7 @@ function FormAlertRules({
|
|||||||
alertDef={alertDef}
|
alertDef={alertDef}
|
||||||
yAxisUnit={yAxisUnit || ''}
|
yAxisUnit={yAxisUnit || ''}
|
||||||
graphType={panelType || PANEL_TYPES.TIME_SERIES}
|
graphType={panelType || PANEL_TYPES.TIME_SERIES}
|
||||||
|
setQueryStatus={setQueryStatus}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -540,6 +542,7 @@ function FormAlertRules({
|
|||||||
selectedInterval={globalSelectedInterval}
|
selectedInterval={globalSelectedInterval}
|
||||||
yAxisUnit={yAxisUnit || ''}
|
yAxisUnit={yAxisUnit || ''}
|
||||||
graphType={panelType || PANEL_TYPES.TIME_SERIES}
|
graphType={panelType || PANEL_TYPES.TIME_SERIES}
|
||||||
|
setQueryStatus={setQueryStatus}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -665,7 +668,8 @@ function FormAlertRules({
|
|||||||
disabled={
|
disabled={
|
||||||
isAlertNameMissing ||
|
isAlertNameMissing ||
|
||||||
isAlertAvailableToSave ||
|
isAlertAvailableToSave ||
|
||||||
!isChannelConfigurationValid
|
!isChannelConfigurationValid ||
|
||||||
|
queryStatus === 'error'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isNewRule ? t('button_createrule') : t('button_savechanges')}
|
{isNewRule ? t('button_createrule') : t('button_savechanges')}
|
||||||
@ -674,7 +678,11 @@ function FormAlertRules({
|
|||||||
|
|
||||||
<ActionButton
|
<ActionButton
|
||||||
loading={loading || false}
|
loading={loading || false}
|
||||||
disabled={isAlertNameMissing || !isChannelConfigurationValid}
|
disabled={
|
||||||
|
isAlertNameMissing ||
|
||||||
|
!isChannelConfigurationValid ||
|
||||||
|
queryStatus === 'error'
|
||||||
|
}
|
||||||
type="default"
|
type="default"
|
||||||
onClick={onTestRuleHandler}
|
onClick={onTestRuleHandler}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user