-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(releases): Refactor to support deep-linked Issues Chart #89711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import type {ReactEchartsRef, SeriesDataUnit} from 'sentry/types/echarts'; | |
import type {Event} from 'sentry/types/event'; | ||
import type {Group} from 'sentry/types/group'; | ||
import type {EventsStats, MultiSeriesEventsStats} from 'sentry/types/organization'; | ||
import type EventView from 'sentry/utils/discover/eventView'; | ||
import {DiscoverDatasets} from 'sentry/utils/discover/types'; | ||
import {formatAbbreviatedNumber} from 'sentry/utils/formatters'; | ||
import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig'; | ||
|
@@ -48,7 +49,7 @@ import {Tab} from 'sentry/views/issueDetails/types'; | |
import {useGroupDetailsRoute} from 'sentry/views/issueDetails/useGroupDetailsRoute'; | ||
import {useReleaseBubbles} from 'sentry/views/releases/releaseBubbles/useReleaseBubbles'; | ||
|
||
const enum EventGraphSeries { | ||
enum EventGraphSeries { | ||
EVENT = 'event', | ||
USER = 'user', | ||
} | ||
|
@@ -64,6 +65,7 @@ interface EventGraphProps { | |
* chart). | ||
*/ | ||
disableZoomNavigation?: boolean; | ||
eventView?: EventView; | ||
ref?: React.Ref<ReactEchartsRef>; | ||
/** | ||
* Configures showing releases on the chart as bubbles or lines. This is used | ||
|
@@ -100,6 +102,7 @@ function createSeriesAndCount(stats: EventsStats) { | |
export function EventGraph({ | ||
group, | ||
event, | ||
eventView: eventViewProps, | ||
disableZoomNavigation = false, | ||
showReleasesAs, | ||
showSummary = true, | ||
|
@@ -131,7 +134,8 @@ export function EventGraph({ | |
ref: chartContainerRef, | ||
onResize, | ||
}); | ||
const eventView = useIssueDetailsEventView({group, isSmallContainer}); | ||
const eventViewHook = useIssueDetailsEventView({group, isSmallContainer}); | ||
const eventView = eventViewProps || eventViewHook; | ||
|
||
const { | ||
data: groupStats = {}, | ||
|
@@ -447,18 +451,22 @@ export function EventGraph({ | |
if (isLoadingStats || isPendingUniqueUsersCount) { | ||
return ( | ||
<GraphWrapper {...styleProps}> | ||
<SummaryContainer> | ||
<GraphButton | ||
isActive={visibleSeries === EventGraphSeries.EVENT} | ||
disabled | ||
label={t('Events')} | ||
/> | ||
<GraphButton | ||
isActive={visibleSeries === EventGraphSeries.USER} | ||
disabled | ||
label={t('Users')} | ||
/> | ||
</SummaryContainer> | ||
{showSummary ? ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes a bug in Release drawer where this is shown during loading state. |
||
<SummaryContainer> | ||
<GraphButton | ||
isActive={visibleSeries === EventGraphSeries.EVENT} | ||
disabled | ||
label={t('Events')} | ||
/> | ||
<GraphButton | ||
isActive={visibleSeries === EventGraphSeries.USER} | ||
disabled | ||
label={t('Users')} | ||
/> | ||
</SummaryContainer> | ||
) : ( | ||
<div /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could this be null or undefined instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Container is a |
||
)} | ||
<LoadingChartContainer ref={chartContainerRef}> | ||
<Placeholder height="96px" testId="event-graph-loading" /> | ||
</LoadingChartContainer> | ||
|
@@ -561,7 +569,11 @@ function GraphButton({ | |
label, | ||
count, | ||
...props | ||
}: {isActive: boolean; label: string; count?: string} & Partial<ButtonProps>) { | ||
}: { | ||
isActive: boolean; | ||
label: string; | ||
count?: string; | ||
} & Partial<ButtonProps>) { | ||
return ( | ||
<CalloutButton | ||
isActive={isActive} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import Placeholder from 'sentry/components/placeholder'; | ||
import {t} from 'sentry/locale'; | ||
import {useParams} from 'sentry/utils/useParams'; | ||
import type {LoadableChartWidgetProps} from 'sentry/views/insights/common/components/widgets/types'; | ||
import {EventGraph} from 'sentry/views/issueDetails/streamline/eventGraph'; | ||
import {useIssueDetailsEventView} from 'sentry/views/issueDetails/streamline/hooks/useIssueDetailsDiscoverQuery'; | ||
import {useGroup} from 'sentry/views/issueDetails/useGroup'; | ||
|
||
export default function EventGraphWidget({pageFilters}: LoadableChartWidgetProps) { | ||
const {groupId} = useParams(); | ||
|
||
const { | ||
data: groupData, | ||
isPending: loadingGroup, | ||
isError: isGroupError, | ||
} = useGroup({groupId: groupId!}); | ||
|
||
const eventView = useIssueDetailsEventView({ | ||
group: groupData!, | ||
isSmallContainer: true, | ||
pageFilters, | ||
}); | ||
|
||
if (loadingGroup) { | ||
return ( | ||
<Container> | ||
<Placeholder height="100%" /> | ||
</Container> | ||
); | ||
} | ||
|
||
if (isGroupError) { | ||
return ( | ||
<Container> | ||
<Placeholder height="100%" error={t('Error loading chart')} /> | ||
</Container> | ||
); | ||
} | ||
|
||
return ( | ||
<EventGraph | ||
event={undefined} | ||
eventView={eventView} | ||
group={groupData} | ||
showSummary={false} | ||
showReleasesAs="line" | ||
disableZoomNavigation | ||
/> | ||
); | ||
} | ||
|
||
const Container = styled('div')` | ||
height: 100%; | ||
`; | ||
|
||
export const EVENT_GRAPH_WIDGET_ID = 'event-graph-widget'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this lead to circular dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking... it could if we used ChartWidgetLoader to always load
EventGraph
, but we shouldn't need to. It'll only be the Insights widgets that we replace with WidgetLoader