mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 21:26:02 +08:00
fix: avoid double API call on the adding new panel type (#3246)
This commit is contained in:
parent
54738432af
commit
fafa6f9960
@ -62,6 +62,10 @@ function GridCardGraph({
|
|||||||
allowEdit,
|
allowEdit,
|
||||||
isQueryEnabled,
|
isQueryEnabled,
|
||||||
}: GridCardGraphProps): JSX.Element {
|
}: GridCardGraphProps): JSX.Element {
|
||||||
|
const { isAddWidget } = useSelector<AppState, DashboardReducer>(
|
||||||
|
(state) => state.dashboards,
|
||||||
|
);
|
||||||
|
|
||||||
const { ref: graphRef, inView: isGraphVisible } = useInView({
|
const { ref: graphRef, inView: isGraphVisible } = useInView({
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
triggerOnce: true,
|
triggerOnce: true,
|
||||||
@ -116,7 +120,7 @@ function GridCardGraph({
|
|||||||
variables,
|
variables,
|
||||||
],
|
],
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
enabled: isGraphVisible && !isEmptyWidget && isQueryEnabled,
|
enabled: isGraphVisible && !isEmptyWidget && isQueryEnabled && !isAddWidget,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
setErrorMessage(error.message);
|
setErrorMessage(error.message);
|
||||||
|
@ -8,6 +8,7 @@ import { useSelector } from 'react-redux';
|
|||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import { Widgets } from 'types/api/dashboard/getAll';
|
import { Widgets } from 'types/api/dashboard/getAll';
|
||||||
import AppReducer from 'types/reducer/app';
|
import AppReducer from 'types/reducer/app';
|
||||||
|
import DashboardReducer from 'types/reducer/dashboards';
|
||||||
|
|
||||||
import { LayoutProps, State } from '.';
|
import { LayoutProps, State } from '.';
|
||||||
import {
|
import {
|
||||||
@ -28,6 +29,9 @@ function GraphLayout({
|
|||||||
widgets,
|
widgets,
|
||||||
setLayout,
|
setLayout,
|
||||||
}: GraphLayoutProps): JSX.Element {
|
}: GraphLayoutProps): JSX.Element {
|
||||||
|
const { isAddWidget } = useSelector<AppState, DashboardReducer>(
|
||||||
|
(state) => state.dashboards,
|
||||||
|
);
|
||||||
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||||
const isDarkMode = useIsDarkMode();
|
const isDarkMode = useIsDarkMode();
|
||||||
|
|
||||||
@ -53,7 +57,7 @@ function GraphLayout({
|
|||||||
{addPanelPermission && (
|
{addPanelPermission && (
|
||||||
<Button
|
<Button
|
||||||
loading={addPanelLoading}
|
loading={addPanelLoading}
|
||||||
disabled={addPanelLoading}
|
disabled={addPanelLoading || isAddWidget}
|
||||||
onClick={onAddPanelHandler}
|
onClick={onAddPanelHandler}
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user