From 4779300dea38d9d7175c5b2adf1366f9edd9b257 Mon Sep 17 00:00:00 2001 From: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> Date: Wed, 19 Mar 2025 11:58:20 +0530 Subject: [PATCH] fix: fixed list panel getting no-data in full view and edit panel (#7320) * fix: fixed list panel getting no-data in full view and edit panel * fix: added cloneDeep for updatedQuery --------- Co-authored-by: Srikanth Chekuri --- .../GridCard/FullView/index.tsx | 1 + frontend/src/container/NewWidget/index.tsx | 33 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx b/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx index ad97b3feac..c9ab985f7f 100644 --- a/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx +++ b/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx @@ -95,6 +95,7 @@ function FullView({ graphType: PANEL_TYPES.LIST, selectedTime: widget?.timePreferance || 'GLOBAL_TIME', globalSelectedInterval: globalSelectedTime, + variables: getDashboardVariables(selectedDashboard?.data.variables), tableParams: { pagination: { offset: 0, diff --git a/frontend/src/container/NewWidget/index.tsx b/frontend/src/container/NewWidget/index.tsx index 5d85eb3652..bcae2868bd 100644 --- a/frontend/src/container/NewWidget/index.tsx +++ b/frontend/src/container/NewWidget/index.tsx @@ -24,7 +24,7 @@ import { useSafeNavigate } from 'hooks/useSafeNavigate'; import useUrlQuery from 'hooks/useUrlQuery'; import { getDashboardVariables } from 'lib/dashbaordVariables/getDashboardVariables'; import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults'; -import { defaultTo, isEmpty, isUndefined } from 'lodash-es'; +import { cloneDeep, defaultTo, isEmpty, isUndefined } from 'lodash-es'; import { Check, X } from 'lucide-react'; import { DashboardWidgetPageParams } from 'pages/DashboardWidget'; import { useAppContext } from 'providers/App/App'; @@ -315,7 +315,25 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element { // request data should be handled by the parent and the child components should consume the same // this has been moved here from the left container const [requestData, setRequestData] = useState(() => { - if (selectedWidget && selectedGraph !== PANEL_TYPES.LIST) { + const updatedQuery = cloneDeep(stagedQuery || initialQueriesMap.metrics); + updatedQuery.builder.queryData[0].pageSize = 10; + + if (selectedWidget) { + if (selectedGraph === PANEL_TYPES.LIST) { + return { + query: updatedQuery, + graphType: PANEL_TYPES.LIST, + selectedTime: selectedTime.enum || 'GLOBAL_TIME', + globalSelectedInterval, + variables: getDashboardVariables(selectedDashboard?.data.variables), + tableParams: { + pagination: { + offset: 0, + limit: updatedQuery.builder.queryData[0].limit || 0, + }, + }, + }; + } return { selectedTime: selectedWidget?.timePreferance, graphType: getGraphType(selectedGraph || selectedWidget.panelTypes), @@ -327,8 +345,6 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element { variables: getDashboardVariables(selectedDashboard?.data.variables), }; } - const updatedQuery = { ...(stagedQuery || initialQueriesMap.metrics) }; - updatedQuery.builder.queryData[0].pageSize = 10; // If stagedQuery exists, don't re-run the query (e.g. when clicking on Add to Dashboard from logs and traces explorer) if (!stagedQuery) { @@ -336,15 +352,10 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element { } return { query: updatedQuery, - graphType: PANEL_TYPES.LIST, + graphType: selectedGraph, selectedTime: selectedTime.enum || 'GLOBAL_TIME', globalSelectedInterval, - tableParams: { - pagination: { - offset: 0, - limit: updatedQuery.builder.queryData[0].limit || 0, - }, - }, + variables: getDashboardVariables(selectedDashboard?.data.variables), }; });