From 6cc7025e37a3b0bfe37b4b1010fab456d91d5c83 Mon Sep 17 00:00:00 2001 From: Chintan Sudani <46838508+csudani7@users.noreply.github.com> Date: Wed, 25 Jan 2023 10:54:36 +0530 Subject: [PATCH] fix: Chart is not updating on change of variables (#2020) * fix: Chart is not updating onchange of variables * fix: Added useLocation hook for pathname * fix: Lint issues resolved * fix: Updated logic behind change of variables * fix: Suggested changes of variable Co-authored-by: Palash Gupta --- .../src/container/GridGraphLayout/Graph/index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/container/GridGraphLayout/Graph/index.tsx b/frontend/src/container/GridGraphLayout/Graph/index.tsx index 912b3d9c62..d88bfdc1ad 100644 --- a/frontend/src/container/GridGraphLayout/Graph/index.tsx +++ b/frontend/src/container/GridGraphLayout/Graph/index.tsx @@ -21,6 +21,7 @@ import { GlobalTime } from 'types/actions/globalTime'; import { ErrorResponse, SuccessResponse } from 'types/api'; import { Widgets } from 'types/api/dashboard/getAll'; import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange'; +import DashboardReducer from 'types/reducer/dashboards'; import { GlobalReducer } from 'types/reducer/globalTime'; import { LayoutProps } from '..'; @@ -49,13 +50,25 @@ function GridCardGraph({ AppState, GlobalReducer >((state) => state.globalTime); + const { dashboards } = useSelector( + (state) => state.dashboards, + ); + const [selectedDashboard] = dashboards; + const selectedData = selectedDashboard?.data; + const { variables } = selectedData; const response = useQuery< SuccessResponse | ErrorResponse >( [ `GetMetricsQueryRange-${widget.timePreferance}-${globalSelectedInterval}-${widget.id}`, - { widget, maxTime, minTime, globalSelectedInterval }, + { + widget, + maxTime, + minTime, + globalSelectedInterval, + variables, + }, ], () => GetMetricQueryRange({