1- import type { RouteComponentProps } from 'sentry/types/legacyReactRouter' ;
1+ import type { PlainRoute } from 'sentry/types/legacyReactRouter' ;
22import type { Organization } from 'sentry/types/organization' ;
33import { normalizeUrl } from 'sentry/utils/url/normalizeUrl' ;
44import { useOrganization } from 'sentry/utils/useOrganization' ;
55import { useParams } from 'sentry/utils/useParams' ;
6- import { useRouter } from 'sentry/utils/useRouter ' ;
6+ import { useRoutes } from 'sentry/utils/useRoutes ' ;
77import { Tab , TabPaths } from 'sentry/views/issueDetails/types' ;
88
9- type RouteProps = RouteComponentProps < { groupId : string ; eventId ?: string } > ;
10-
11- function getCurrentTab ( { router} : { router : RouteProps [ 'router' ] } ) {
12- const currentRoute = router . routes [ router . routes . length - 1 ] ;
9+ function getCurrentTab ( {
10+ routes,
11+ params,
12+ } : {
13+ params : Record < string , string | undefined > ;
14+ routes : PlainRoute [ ] ;
15+ } ) {
16+ const currentRoute = routes [ routes . length - 1 ] ;
1317
1418 // If we're in the tag details page ("/distributions/:tagKey/")
15- if ( router . params . tagKey ) {
19+ if ( params . tagKey ) {
1620 return Tab . DISTRIBUTIONS ;
1721 }
1822 return (
@@ -24,21 +28,23 @@ function getCurrentRouteInfo({
2428 groupId,
2529 eventId,
2630 organization,
27- router,
31+ routes,
32+ params,
2833} : {
2934 eventId : string | undefined ;
3035 groupId : string ;
3136 organization : Organization ;
32- router : RouteProps [ 'router' ] ;
37+ params : Record < string , string | undefined > ;
38+ routes : PlainRoute [ ] ;
3339} ) : {
3440 baseUrl : string ;
3541 currentTab : Tab ;
3642} {
37- const currentTab = getCurrentTab ( { router } ) ;
43+ const currentTab = getCurrentTab ( { routes , params } ) ;
3844
3945 const baseUrl = normalizeUrl (
4046 `/organizations/${ organization . slug } /issues/${ groupId } /${
41- router . params . eventId && eventId ? `events/${ eventId } /` : ''
47+ params . eventId && eventId ? `events/${ eventId } /` : ''
4248 } `
4349 ) ;
4450
@@ -50,12 +56,17 @@ export function useGroupDetailsRoute(): {
5056 currentTab : Tab ;
5157} {
5258 const organization = useOrganization ( ) ;
53- const params = useParams < { groupId : string ; eventId ?: string } > ( ) ;
54- const router = useRouter ( ) ;
59+ const params = useParams < {
60+ groupId : string ;
61+ eventId ?: string ;
62+ tagKey ?: string ;
63+ } > ( ) ;
64+ const routes = useRoutes ( ) ;
5565 return getCurrentRouteInfo ( {
5666 groupId : params . groupId ,
5767 eventId : params . eventId ,
5868 organization,
59- router,
69+ routes,
70+ params,
6071 } ) ;
6172}
0 commit comments