Skip to content

Commit c349789

Browse files
authored
feat(releases): Use routing for Releases Drawer (#88562)
This allows the Releases drawer to be deeplinked (including charts). This splits `<ReleasesDrawer>` into `useReleasesDrawer()` hook which opens drawer and renders `<ReleasesDrawerList>` or `<ReleasesDrawerDetails>`.
1 parent 3100913 commit c349789

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+580
-421
lines changed

static/app/components/globalDrawer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface DrawerOptions {
7070
/**
7171
* If true (default), closes the drawer when the location changes
7272
*/
73-
shouldCloseOnLocationChange?: (newPathname: Location) => boolean;
73+
shouldCloseOnLocationChange?: (nextLocation: Location) => boolean;
7474
//
7575
// Custom framer motion transition for the drawer
7676
//

static/app/utils/analytics/releasesAnalyticsEvents.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {ReleaseComparisonChartType} from 'sentry/types/release';
33
export type ReleasesEventParameters = {
44
'releases.bubbles_legend': {selected: boolean};
55
'releases.change_chart_type': {chartType: ReleaseComparisonChartType};
6+
'releases.drawer_opened': {organization: string; release?: boolean};
67
'releases.drawer_view_full_details': {project_id: string};
78
'releases.quickstart_copied': {project_id: string};
89
'releases.quickstart_create_integration.success': {
@@ -19,6 +20,7 @@ export const releasesEventMap: Record<ReleasesEventKey, string | null> = {
1920
'releases.bubbles_legend': 'Releases: Toggle Legend for Bubble',
2021
'releases.change_chart_type': 'Releases: Change Chart Type',
2122
'releases.drawer_view_full_details': 'Releases: Drawer View Full Details',
23+
'releases.drawer_opened': 'Releases: Drawer Opened',
2224
'releases.quickstart_viewed': 'Releases: Quickstart Viewed',
2325
'releases.quickstart_copied': 'Releases: Quickstart Copied',
2426
'releases.quickstart_create_integration.success':

static/app/utils/dates.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import ConfigStore from 'sentry/stores/configStore';
44

55
import type {TableDataRow} from './discover/discoverQuery';
66

7-
// TODO(billy): Move to TimeRangeSelector specific utils
87
export const DEFAULT_DAY_START_TIME = '00:00:00';
98
export const DEFAULT_DAY_END_TIME = '23:59:59';
109
const DATE_FORMAT_NO_TIMEZONE = 'YYYY/MM/DD HH:mm:ss';

static/app/utils/useReleaseStats.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ interface UseReleaseStatsParams {
2727
*/
2828
export function useReleaseStats(
2929
{datetime, environments, projects, maxPages = 10}: UseReleaseStatsParams,
30-
queryOptions: {staleTime: number} = {staleTime: Infinity}
30+
queryOptions: {enabled?: boolean; staleTime?: number} = {
31+
staleTime: Infinity,
32+
enabled: true,
33+
}
3134
) {
3235
const organization = useOrganization();
3336

static/app/views/dashboards/widgets/timeSeriesWidget/timeSeriesWidgetVisualization.tsx

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {useCallback, useRef} from 'react';
2-
import {useNavigate} from 'react-router-dom';
32
import {useTheme} from '@emotion/react';
43
import styled from '@emotion/styled';
54
import {mergeRefs} from '@react-aria/utils';
@@ -31,6 +30,8 @@ import {defined} from 'sentry/utils';
3130
import {uniq} from 'sentry/utils/array/uniq';
3231
import type {AggregationOutputType} from 'sentry/utils/discover/fields';
3332
import {type Range, RangeMap} from 'sentry/utils/number/rangeMap';
33+
import {useLocation} from 'sentry/utils/useLocation';
34+
import {useNavigate} from 'sentry/utils/useNavigate';
3435
import useOrganization from 'sentry/utils/useOrganization';
3536
import usePageFilters from 'sentry/utils/usePageFilters';
3637
import {useWidgetSyncContext} from 'sentry/views/dashboards/contexts/widgetSyncContext';
@@ -45,7 +46,10 @@ import type {
4546
} from 'sentry/views/dashboards/widgets/common/types';
4647
import type {LoadableChartWidgetProps} from 'sentry/views/insights/common/components/widgets/types';
4748
import {useReleaseBubbles} from 'sentry/views/releases/releaseBubbles/useReleaseBubbles';
48-
import {makeReleasesPathname} from 'sentry/views/releases/utils/pathnames';
49+
import {
50+
makeReleaseDrawerPathname,
51+
makeReleasesPathname,
52+
} from 'sentry/views/releases/utils/pathnames';
4953

5054
import {formatTooltipValue} from './formatters/formatTooltipValue';
5155
import {formatXAxisTimestamp} from './formatters/formatXAxisTimestamp';
@@ -63,12 +67,6 @@ export interface TimeSeriesWidgetVisualizationProps
6367
* An array of `Plottable` objects. This can be any object that implements the `Plottable` interface.
6468
*/
6569
plottables: Plottable[];
66-
/**
67-
/**
68-
* Disables navigating to release details when clicked
69-
* TODO(billy): temporary until we implement route based nav
70-
*/
71-
disableReleaseNavigation?: boolean;
7270
/**
7371
* A mapping of time series field name to boolean. If the value is `false`, the series is hidden from view
7472
*/
@@ -129,6 +127,7 @@ export function TimeSeriesWidgetVisualization(props: TimeSeriesWidgetVisualizati
129127
const theme = useTheme();
130128
const organization = useOrganization();
131129
const navigate = useNavigate();
130+
const location = useLocation();
132131
const hasReleaseBubbles =
133132
organization.features.includes('release-bubbles-ui') &&
134133
props.showReleaseAs === 'bubble';
@@ -146,22 +145,7 @@ export function TimeSeriesWidgetVisualization(props: TimeSeriesWidgetVisualizati
146145
releaseBubbleXAxis,
147146
releaseBubbleGrid,
148147
} = useReleaseBubbles({
149-
chartRenderer: ({start: trimStart, end: trimEnd, ref: chartRendererRef}) => {
150-
return (
151-
<DrawerWidgetWrapper>
152-
<TimeSeriesWidgetVisualization
153-
{...props}
154-
ref={chartRendererRef}
155-
disableReleaseNavigation
156-
onZoom={() => {}}
157-
plottables={props.plottables.map(plottable =>
158-
plottable.constrain(trimStart, trimEnd)
159-
)}
160-
showReleaseAs="line"
161-
/>
162-
</DrawerWidgetWrapper>
163-
);
164-
},
148+
chartId: props.id,
165149
minTime: earliestTimeStamp ? new Date(earliestTimeStamp).getTime() : undefined,
166150
maxTime: latestTimeStamp ? new Date(latestTimeStamp).getTime() : undefined,
167151
releases: hasReleaseBubbles
@@ -176,7 +160,8 @@ export function TimeSeriesWidgetVisualization(props: TimeSeriesWidgetVisualizati
176160
theme,
177161
props.releases,
178162
function onReleaseClick(release: Release) {
179-
if (props.disableReleaseNavigation) {
163+
if (organization.features.includes('release-bubbles-ui')) {
164+
navigate(makeReleaseDrawerPathname({location, release: release.version}));
180165
return;
181166
}
182167
navigate(
@@ -717,8 +702,4 @@ const LoadingMask = styled(TransparentLoadingMask)`
717702
background: ${p => p.theme.background};
718703
`;
719704

720-
const DrawerWidgetWrapper = styled('div')`
721-
height: 220px;
722-
`;
723-
724705
TimeSeriesWidgetVisualization.LoadingPlaceholder = LoadingPanel;

static/app/views/insights/browser/resources/components/charts/resourceLandingPageCharts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import styled from '@emotion/styled';
22

33
import {space} from 'sentry/styles/space';
4-
import {ResourceLandingDurationChartWidget} from 'sentry/views/insights/common/components/widgets/resourceLandingDurationChartWidget';
5-
import {ResourceLandingThroughputChartWidget} from 'sentry/views/insights/common/components/widgets/resourceLandingThroughputChartWidget';
4+
import ResourceLandingDurationChartWidget from 'sentry/views/insights/common/components/widgets/resourceLandingDurationChartWidget';
5+
import ResourceLandingThroughputChartWidget from 'sentry/views/insights/common/components/widgets/resourceLandingThroughputChartWidget';
66

77
export function ResourceLandingPageCharts() {
88
return (

static/app/views/insights/browser/resources/components/charts/resourceSummaryCharts.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {Fragment} from 'react';
22

33
import * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
4-
import {ResourceSummaryAverageSizeChartWidget} from 'sentry/views/insights/common/components/widgets/resourceSummaryAverageSizeChartWidget';
5-
import {ResourceSummaryDurationChartWidget} from 'sentry/views/insights/common/components/widgets/resourceSummaryDurationChartWidget';
6-
import {ResourceSummaryThroughputChartWidget} from 'sentry/views/insights/common/components/widgets/resourceSummaryThroughputChartWidget';
4+
import ResourceSummaryAverageSizeChartWidget from 'sentry/views/insights/common/components/widgets/resourceSummaryAverageSizeChartWidget';
5+
import ResourceSummaryDurationChartWidget from 'sentry/views/insights/common/components/widgets/resourceSummaryDurationChartWidget';
6+
import ResourceSummaryThroughputChartWidget from 'sentry/views/insights/common/components/widgets/resourceSummaryThroughputChartWidget';
77

88
function ResourceSummaryCharts() {
99
return (

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {openInsightChartModal} from 'sentry/actionCreators/modal';
66
import {Button} from 'sentry/components/core/button';
77
import {IconExpand} from 'sentry/icons';
88
import {t} from 'sentry/locale';
9+
import type {PageFilters} from 'sentry/types/core';
910
import useOrganization from 'sentry/utils/useOrganization';
1011
import usePageFilters from 'sentry/utils/usePageFilters';
1112
import {useReleaseStats} from 'sentry/utils/useReleaseStats';
@@ -47,8 +48,10 @@ export interface InsightsTimeSeriesWidgetProps
4748
interactiveTitle?: () => React.ReactNode;
4849
legendSelection?: LegendSelection | undefined;
4950
onLegendSelectionChange?: ((selection: LegendSelection) => void) | undefined;
51+
pageFilters?: PageFilters;
5052
samples?: Samples;
5153
showLegend?: TimeSeriesWidgetVisualizationProps['showLegend'];
54+
showReleaseAs?: 'line' | 'bubble';
5255
stacked?: boolean;
5356
}
5457

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function CrashFreeSessionsChartWidget(props: LoadableChartWidgetP
2828
interactiveTitle={() => (
2929
<ChartSelectionTitle title={CHART_TITLES.CrashFreeSessionsChartWidget} />
3030
)}
31-
height={SESSION_HEALTH_CHART_HEIGHT}
31+
height={props.height || SESSION_HEALTH_CHART_HEIGHT}
3232
description={tct(
3333
'The percent of sessions terminating without a crash. See [link:session status]. The 5 most adopted releases are shown.',
3434
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function ReleaseSessionCountChartwidget(props: LoadableChartWidge
2525
interactiveTitle={() => (
2626
<ChartSelectionTitle title={CHART_TITLES.ReleaseSessionCountChartWidget} />
2727
)}
28-
height={SESSION_HEALTH_CHART_HEIGHT}
28+
height={props.height || SESSION_HEALTH_CHART_HEIGHT}
2929
description={t(
3030
'The total number of sessions per release. The 5 most recent releases are shown.'
3131
)}

0 commit comments

Comments
 (0)