Skip to content

Commit

Permalink
ref(js): Make profilingBreadcrumbs compatible with react-router 6 (#7…
Browse files Browse the repository at this point in the history
…6420)

Helps with react-router 6 upgrade. We can clean this up later in
react-router 6
  • Loading branch information
evanpurkhiser committed Aug 26, 2024
1 parent 7d17c33 commit f3e2d9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions static/app/components/globalSelectionLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ function GlobalSelectionLink(props: Props) {
const query =
typeof to === 'object' && to.query ? {...globalQuery, ...to.query} : globalQuery;

if (typeof to === 'object' && to.query && Object.keys(to.query).length === 0) {
delete to.query;
}

if (location) {
const toWithGlobalQuery: LocationDescriptor = !hasGlobalQuery
? {}
: typeof to === 'string'
? {pathname: to, query}
: {...to, query};

if (toWithGlobalQuery.query && Object.keys(toWithGlobalQuery.query).length === 0) {
delete toWithGlobalQuery.query;
}

const routerProps = hasGlobalQuery
? {...props, to: toWithGlobalQuery}
: {...props, to};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Breadcrumb', function () {
expect(screen.getByText('Profiling')).toBeInTheDocument();
expect(screen.getByRole('link', {name: 'Profiling'})).toHaveAttribute(
'href',
`/organizations/${organization.slug}/profiling/?`
`/organizations/${organization.slug}/profiling/`
);
expect(screen.getByText('foo')).toBeInTheDocument();
});
Expand Down

0 comments on commit f3e2d9b

Please sign in to comment.