Skip to content

Commit 1c97c30

Browse files
committed
Replace useRouter calls for PickProjectToContinue component usages
1 parent 32bf9a6 commit 1c97c30

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

static/app/components/pickProjectToContinue.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {LocationDescriptor, LocationDescriptorObject} from 'history';
33

44
import {openModal} from 'sentry/actionCreators/modal';
55
import {ContextPickerModalContainer as ContextPickerModal} from 'sentry/components/contextPickerModal';
6-
import type {InjectedRouter} from 'sentry/types/legacyReactRouter';
6+
import {useNavigate} from 'sentry/utils/useNavigate';
77

88
type Project = {
99
id: string;
@@ -22,17 +22,16 @@ type Props = {
2222
*/
2323
noProjectRedirectPath: LocationDescriptor;
2424
projects: Project[];
25-
router: InjectedRouter;
2625
allowAllProjectsSelection?: boolean;
2726
};
2827

2928
export function PickProjectToContinue({
3029
noProjectRedirectPath,
3130
nextPath,
32-
router,
3331
projects,
3432
allowAllProjectsSelection = false,
3533
}: Props) {
34+
const navigate = useNavigate();
3635
const nextPathQuery = nextPath.query;
3736
let navigating = false;
3837
let path = `${nextPath.pathname}?project=`;
@@ -49,7 +48,7 @@ export function PickProjectToContinue({
4948

5049
// if the project in URL is missing, but this release belongs to only one project, redirect there
5150
if (projects.length === 1) {
52-
router.replace(path + projects[0]!.id);
51+
navigate(path + projects[0]!.id, {replace: true});
5352
return null;
5453
}
5554

@@ -62,7 +61,7 @@ export function PickProjectToContinue({
6261
nextPath={`${path}:project`}
6362
onFinish={to => {
6463
navigating = true;
65-
router.replace(to);
64+
navigate(to, {replace: true});
6665
modalProps.closeModal();
6766
}}
6867
projectSlugs={projects.map(p => p.slug)}
@@ -74,7 +73,7 @@ export function PickProjectToContinue({
7473
// we want this to be executed only if the user didn't select any project
7574
// (closed modal either via button, Esc, clicking outside, ...)
7675
if (!navigating) {
77-
router.push(noProjectRedirectPath);
76+
navigate(noProjectRedirectPath);
7877
}
7978
},
8079
}

static/app/views/performance/transactionSummary/pageLayout.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {PerformanceEventViewProvider} from 'sentry/utils/performance/contexts/pe
3434
import {normalizeUrl} from 'sentry/utils/url/normalizeUrl';
3535
import {useDatePageFilterProps} from 'sentry/utils/useDatePageFilterProps';
3636
import {useMaxPickableDays} from 'sentry/utils/useMaxPickableDays';
37-
import {useRouter} from 'sentry/utils/useRouter';
3837
import {useTransactionSummaryEAP} from 'sentry/views/performance/eap/useTransactionSummaryEAP';
3938
import {TransactionSummaryContext} from 'sentry/views/performance/transactionSummary/transactionSummaryContext';
4039
import {
@@ -98,7 +97,6 @@ export function PageLayout(props: Props) {
9897
}
9998

10099
const theme = useTheme();
101-
const router = useRouter();
102100
const transactionName = getTransactionName(location);
103101
const [error, setError] = useState<string | undefined>();
104102
const metricsCardinality = useMetricsCardinalityContext();
@@ -241,7 +239,6 @@ export function PageLayout(props: Props) {
241239
<PickProjectToContinue
242240
data-test-id="transaction-sumamry-project-picker-modal"
243241
projects={selectableProjects}
244-
router={router}
245242
nextPath={{
246243
pathname: generateTransactionSummaryRoute({organization}),
247244
query: {

static/app/views/releases/detail/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {useLocation} from 'sentry/utils/useLocation';
3434
import {useNavigate} from 'sentry/utils/useNavigate';
3535
import {useOrganization} from 'sentry/utils/useOrganization';
3636
import {useParams} from 'sentry/utils/useParams';
37-
import {useRouter} from 'sentry/utils/useRouter';
3837
import {formatVersion} from 'sentry/utils/versions/formatVersion';
3938
import type {ReleaseBounds} from 'sentry/views/releases/utils';
4039
import {getReleaseBounds, searchReleaseVersion} from 'sentry/views/releases/utils';
@@ -242,7 +241,6 @@ function ReleasesDetailContainer() {
242241
const params = useParams<{release: string}>();
243242
const location = useLocation();
244243
const navigate = useNavigate();
245-
const router = useRouter();
246244
const organization = useOrganization();
247245
const {release} = params;
248246

@@ -299,7 +297,6 @@ function ReleasesDetailContainer() {
299297
id: String(id),
300298
slug,
301299
}))}
302-
router={router}
303300
nextPath={{
304301
pathname: makeReleasesPathname({
305302
path: `/${encodeURIComponent(release)}/`,

0 commit comments

Comments
 (0)