From f55c022a4276e07720d09ff7a7f702af7166a877 Mon Sep 17 00:00:00 2001 From: George Gritsouk <989898+gggritso@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:29:18 -0500 Subject: [PATCH] Set widget viewer data before opening Just before rendering the viewer modal, populate the data context with the widget's data. --- static/app/views/dashboards/widgetCard/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/app/views/dashboards/widgetCard/index.tsx b/static/app/views/dashboards/widgetCard/index.tsx index cadb0535fe85b2..3dd33ba0056446 100644 --- a/static/app/views/dashboards/widgetCard/index.tsx +++ b/static/app/views/dashboards/widgetCard/index.tsx @@ -1,4 +1,4 @@ -import {useState} from 'react'; +import {useContext, useState} from 'react'; import styled from '@emotion/styled'; import type {LegendComponentOption} from 'echarts'; import type {Location} from 'history'; @@ -40,6 +40,7 @@ import type WidgetLegendSelectionState from '../widgetLegendSelectionState'; import {BigNumberWidget} from '../widgets/bigNumberWidget/bigNumberWidget'; import type {Meta} from '../widgets/common/types'; import {WidgetFrame} from '../widgets/common/widgetFrame'; +import {WidgetViewerContext} from '../widgetViewer/widgetViewerContext'; import {useDashboardsMEPContext} from './dashboardsMEPContext'; import WidgetCardChartContainer from './widgetCardChartContainer'; @@ -100,6 +101,7 @@ type Data = { function WidgetCard(props: Props) { const [data, setData] = useState(); + const {setData: setWidgetViewerData} = useContext(WidgetViewerContext); const onDataFetched = (newData: Data) => { if (props.onDataFetched && newData.tableResults) { @@ -174,6 +176,14 @@ function WidgetCard(props: Props) { const onFullScreenViewClick = () => { if (!isWidgetViewerPath(location.pathname)) { + setWidgetViewerData({ + pageLinks: data?.pageLinks, + seriesData: data?.timeseriesResults, + tableData: data?.tableResults, + seriesResultsType: data?.timeseriesResultsTypes, + totalIssuesCount: data?.totalIssuesCount, + }); + props.router.push({ pathname: `${location.pathname}${ location.pathname.endsWith('/') ? '' : '/'