Skip to content

Commit adeeb0a

Browse files
authored
fix(releases): Fix chart zooming instead of Releases List Drawer (#91935)
Change the chart zoom behavior in the Releases List Drawer to update the start/end values of the drawer instead of the main view.
1 parent f72653e commit adeeb0a

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

static/app/views/insights/common/components/insightsTimeSeriesWidget.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ export function InsightsTimeSeriesWidget(props: InsightsTimeSeriesWidgetProps) {
132132
}
133133

134134
const enableReleaseBubblesProps = organization.features.includes('release-bubbles-ui')
135-
? ({releases, showReleaseAs: props.showReleaseAs || 'bubble'} as const)
135+
? ({
136+
releases,
137+
showReleaseAs: props.showReleaseAs || 'bubble',
138+
onZoom: props.onZoom,
139+
} as const)
136140
: {};
137141

138142
return (

static/app/views/insights/common/components/widgets/types.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {PageFilters} from 'sentry/types/core';
2+
import type {EChartDataZoomHandler} from 'sentry/types/echarts';
23

34
/**
45
* These props are common across components that are required to dynamically
@@ -23,6 +24,13 @@ export interface LoadableChartWidgetProps {
2324
*/
2425
loaderSource?: 'releases-drawer';
2526

27+
/**
28+
* Callback that returns an updated ECharts zoom selection. If omitted, the
29+
* default behavior is to update the URL with updated `start` and `end` query
30+
* parameters.
31+
*/
32+
onZoom?: EChartDataZoomHandler;
33+
2634
/**
2735
* PageFilters-like object that will override the main PageFilters e.g. in
2836
* Releases Drawer, we have a smaller timeframe to show a smaller amount of

static/app/views/releases/drawer/releasesDrawerList.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@ import {
1717
} from 'sentry/components/events/eventDrawer';
1818
import {t, tn} from 'sentry/locale';
1919
import type {PageFilters} from 'sentry/types/core';
20-
import type {ReactEchartsRef, SeriesDataUnit} from 'sentry/types/echarts';
20+
import type {
21+
EChartDataZoomHandler,
22+
ReactEchartsRef,
23+
SeriesDataUnit,
24+
} from 'sentry/types/echarts';
25+
import {getUtcDateString} from 'sentry/utils/dates';
26+
import {useLocation} from 'sentry/utils/useLocation';
27+
import {useNavigate} from 'sentry/utils/useNavigate';
2128
import {useReleaseStats} from 'sentry/utils/useReleaseStats';
2229
import {formatVersion} from 'sentry/utils/versions/formatVersion';
2330
import {EVENT_GRAPH_WIDGET_ID} from 'sentry/views/issueDetails/streamline/eventGraphWidget';
31+
import {ReleasesDrawerFields} from 'sentry/views/releases/drawer/utils';
2432

2533
import {ReleaseDrawerTable} from './releasesDrawerTable';
2634

@@ -83,7 +91,9 @@ const unhighlightMarkLines = createMarkLineUpdater({});
8391
* Allows users to view releases of a specific timebucket.
8492
*/
8593
export function ReleasesDrawerList({chart, pageFilters}: ReleasesDrawerListProps) {
94+
const navigate = useNavigate();
8695
const {releases} = useReleaseStats(pageFilters);
96+
const location = useLocation();
8797
const chartRef = useRef<ReactEchartsRef | null>(null);
8898
const chartHeight = chart === EVENT_GRAPH_WIDGET_ID ? '160px' : '220px';
8999

@@ -118,6 +128,34 @@ export function ReleasesDrawerList({chart, pageFilters}: ReleasesDrawerListProps
118128
},
119129
];
120130

131+
const handleDataZoom = useCallback<EChartDataZoomHandler>(
132+
evt => {
133+
let {startValue, endValue} = (evt as any).batch[0] as {
134+
endValue: number | null;
135+
startValue: number | null;
136+
};
137+
138+
// if `rangeStart` and `rangeEnd` are null, then we are going back
139+
if (startValue && endValue) {
140+
// round off the bounds to the minute
141+
startValue = Math.floor(startValue / 60_000) * 60_000;
142+
endValue = Math.ceil(endValue / 60_000) * 60_000;
143+
144+
// ensure the bounds has 1 minute resolution
145+
startValue = Math.min(startValue, endValue - 60_000);
146+
147+
navigate({
148+
query: {
149+
...location.query,
150+
[ReleasesDrawerFields.START]: getUtcDateString(startValue),
151+
[ReleasesDrawerFields.END]: getUtcDateString(endValue),
152+
},
153+
});
154+
}
155+
},
156+
[navigate, location.query]
157+
);
158+
121159
return (
122160
<EventDrawerContainer>
123161
<EventDrawerHeader>
@@ -135,6 +173,7 @@ export function ReleasesDrawerList({chart, pageFilters}: ReleasesDrawerListProps
135173
pageFilters={pageFilters}
136174
showReleaseAs="line"
137175
loaderSource="releases-drawer"
176+
onZoom={handleDataZoom}
138177
/>
139178
</div>
140179
) : null}

0 commit comments

Comments
 (0)