Skip to content

Commit bea35d7

Browse files
ref(js): Convert discover eventsV2 Breadcrumbs to a FC (#34629)
1 parent 1a9ea7f commit bea35d7

File tree

1 file changed

+29
-44
lines changed

1 file changed

+29
-44
lines changed
Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {Component} from 'react';
21
import {Location} from 'history';
32

43
import Breadcrumbs, {Crumb} from 'sentry/components/breadcrumbs';
@@ -8,59 +7,45 @@ import {Event} from 'sentry/types/event';
87
import EventView from 'sentry/utils/discover/eventView';
98
import {getDiscoverLandingUrl} from 'sentry/utils/discover/urls';
109

11-
type DefaultProps = {
12-
event: Event | undefined;
13-
};
14-
15-
type Props = DefaultProps & {
10+
type Props = {
1611
eventView: EventView;
1712
location: Location;
1813
organization: Organization;
14+
event?: Event;
1915
};
2016

21-
class DiscoverBreadcrumb extends Component<Props> {
22-
static defaultProps: DefaultProps = {
23-
event: undefined,
24-
};
25-
26-
getCrumbs() {
27-
const crumbs: Crumb[] = [];
28-
const {eventView, event, organization, location} = this.props;
29-
const discoverTarget = organization.features.includes('discover-query')
30-
? {
31-
pathname: getDiscoverLandingUrl(organization),
32-
query: {
33-
...location.query,
34-
...eventView.generateBlankQueryStringObject(),
35-
...eventView.getPageFiltersQuery(),
36-
},
37-
}
38-
: null;
39-
17+
function DiscoverBreadcrumb({eventView, event, organization, location}: Props) {
18+
const crumbs: Crumb[] = [];
19+
const discoverTarget = organization.features.includes('discover-query')
20+
? {
21+
pathname: getDiscoverLandingUrl(organization),
22+
query: {
23+
...location.query,
24+
...eventView.generateBlankQueryStringObject(),
25+
...eventView.getPageFiltersQuery(),
26+
},
27+
}
28+
: null;
29+
30+
crumbs.push({
31+
to: discoverTarget,
32+
label: t('Discover'),
33+
});
34+
35+
if (eventView && eventView.isValid()) {
4036
crumbs.push({
41-
to: discoverTarget,
42-
label: t('Discover'),
37+
to: eventView.getResultsViewUrlTarget(organization.slug),
38+
label: eventView.name || '',
4339
});
44-
45-
if (eventView && eventView.isValid()) {
46-
crumbs.push({
47-
to: eventView.getResultsViewUrlTarget(organization.slug),
48-
label: eventView.name || '',
49-
});
50-
}
51-
52-
if (event) {
53-
crumbs.push({
54-
label: t('Event Detail'),
55-
});
56-
}
57-
58-
return crumbs;
5940
}
6041

61-
render() {
62-
return <Breadcrumbs crumbs={this.getCrumbs()} />;
42+
if (event) {
43+
crumbs.push({
44+
label: t('Event Detail'),
45+
});
6346
}
47+
48+
return <Breadcrumbs crumbs={crumbs} />;
6449
}
6550

6651
export default DiscoverBreadcrumb;

0 commit comments

Comments
 (0)