Skip to content

Commit 9535988

Browse files
gggritsoharshithadurai
authored andcommitted
fix(dashboards): Fix re-use of widget data in Widget Viewer modal (#80861)
Just before rendering the viewer modal, populate the data context with the widget's data Closes #80525
1 parent ef1ceae commit 9535988

File tree

1 file changed

+11
-1
lines changed
  • static/app/views/dashboards/widgetCard

1 file changed

+11
-1
lines changed

static/app/views/dashboards/widgetCard/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useState} from 'react';
1+
import {useContext, useState} from 'react';
22
import styled from '@emotion/styled';
33
import type {LegendComponentOption} from 'echarts';
44
import type {Location} from 'history';
@@ -40,6 +40,7 @@ import type WidgetLegendSelectionState from '../widgetLegendSelectionState';
4040
import {BigNumberWidget} from '../widgets/bigNumberWidget/bigNumberWidget';
4141
import type {Meta} from '../widgets/common/types';
4242
import {WidgetFrame} from '../widgets/common/widgetFrame';
43+
import {WidgetViewerContext} from '../widgetViewer/widgetViewerContext';
4344

4445
import {useDashboardsMEPContext} from './dashboardsMEPContext';
4546
import WidgetCardChartContainer from './widgetCardChartContainer';
@@ -100,6 +101,7 @@ type Data = {
100101

101102
function WidgetCard(props: Props) {
102103
const [data, setData] = useState<Data>();
104+
const {setData: setWidgetViewerData} = useContext(WidgetViewerContext);
103105

104106
const onDataFetched = (newData: Data) => {
105107
if (props.onDataFetched && newData.tableResults) {
@@ -174,6 +176,14 @@ function WidgetCard(props: Props) {
174176

175177
const onFullScreenViewClick = () => {
176178
if (!isWidgetViewerPath(location.pathname)) {
179+
setWidgetViewerData({
180+
pageLinks: data?.pageLinks,
181+
seriesData: data?.timeseriesResults,
182+
tableData: data?.tableResults,
183+
seriesResultsType: data?.timeseriesResultsTypes,
184+
totalIssuesCount: data?.totalIssuesCount,
185+
});
186+
177187
props.router.push({
178188
pathname: `${location.pathname}${
179189
location.pathname.endsWith('/') ? '' : '/'

0 commit comments

Comments
 (0)