Skip to content

Commit 86e3fc4

Browse files
committed
Remove browserHistory usages from some gsApp/gsAdmin views
1 parent 151080e commit 86e3fc4

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

static/gsAdmin/views/instanceLevelOAuth/components/confirmClientDeleteModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {Button} from '@sentry/scraps/button';
55

66
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
77
import type {ModalRenderProps} from 'sentry/actionCreators/modal';
8-
import {browserHistory} from 'sentry/utils/browserHistory';
98
import {handleXhrErrorResponse} from 'sentry/utils/handleXhrErrorResponse';
109
import type {RequestError} from 'sentry/utils/requestError/requestError';
1110
import {useApi} from 'sentry/utils/useApi';
11+
import {useNavigate} from 'sentry/utils/useNavigate';
1212

1313
type Props = ModalRenderProps & {
1414
clientID: string | null;
@@ -17,14 +17,15 @@ type Props = ModalRenderProps & {
1717

1818
export function ConfirmClientDeleteModal({Body, Header, clientID, name}: Props) {
1919
const api = useApi();
20+
const navigate = useNavigate();
2021

2122
const deleteClientAndCloseModal = async () => {
2223
try {
2324
await api.requestPromise(`/_admin/instance-level-oauth/${clientID}/`, {
2425
method: 'DELETE',
2526
});
2627
addSuccessMessage(`Client "${name}" deleted successfully`);
27-
browserHistory.push('/_admin/instance-level-oauth/');
28+
navigate('/_admin/instance-level-oauth/');
2829
} catch (err) {
2930
const message = 'Unable to load client data';
3031
handleXhrErrorResponse(message, err as RequestError);

static/gsAdmin/views/relocationCreate.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {OverlayTrigger} from '@sentry/scraps/overlayTrigger';
99
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
1010
import {Client} from 'sentry/api';
1111
import {ConfigStore} from 'sentry/stores/configStore';
12-
import {browserHistory} from 'sentry/utils/browserHistory';
1312
import {useApi} from 'sentry/utils/useApi';
13+
import {useNavigate} from 'sentry/utils/useNavigate';
1414

1515
import {PageHeader} from 'admin/components/pageHeader';
1616

@@ -20,6 +20,7 @@ const PROMO_CODE_ERROR_MSG =
2020
'That promotional code has already been claimed, does not have enough remaining uses, is no longer valid, or never existed.';
2121

2222
function RelocationForm() {
23+
const navigate = useNavigate();
2324
// Use our own api client to initialize, since we need to be careful with the headers when using multipart/form-data
2425
const api = useApi({
2526
api: new Client({headers: {Accept: 'application/json; charset=utf-8'}}),
@@ -67,7 +68,7 @@ function RelocationForm() {
6768
});
6869

6970
addSuccessMessage('The relocation job has started!');
70-
browserHistory.push(`/_admin/relocations/${region.name}/${response.uuid}/`);
71+
navigate(`/_admin/relocations/${region.name}/${response.uuid}/`);
7172
} catch (error: any) {
7273
if (error.responseJSON) {
7374
addErrorMessage(error.responseJSON.detail);

static/gsApp/components/productTrial/productTrialAlert.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import {IconClose} from 'sentry/icons/iconClose';
1010
import {t} from 'sentry/locale';
1111
import {DataCategory} from 'sentry/types/core';
1212
import type {Organization} from 'sentry/types/organization';
13-
import {browserHistory} from 'sentry/utils/browserHistory';
1413
import {getDaysSinceDate} from 'sentry/utils/getDaysSinceDate';
1514
import {normalizeUrl} from 'sentry/utils/url/normalizeUrl';
15+
import {useNavigate} from 'sentry/utils/useNavigate';
1616

1717
import {sendUpgradeRequest} from 'getsentry/actionCreators/upsell';
1818
import AddEventsCTA, {type EventType} from 'getsentry/components/addEventsCTA';
@@ -50,6 +50,7 @@ interface ProductTrialAlertProps {
5050

5151
export function ProductTrialAlert(props: ProductTrialAlertProps) {
5252
const {trial, subscription, organization, onDismiss, product, api} = props;
53+
const navigate = useNavigate();
5354
const [isStartingTrial, setIsStartingTrial] = useState(false);
5455
const [isUpgradeSent, setIsUpgradeSent] = useState(false);
5556

@@ -166,7 +167,7 @@ export function ProductTrialAlert(props: ProductTrialAlertProps) {
166167
<Button
167168
priority="primary"
168169
onClick={() => {
169-
browserHistory.push(normalizeUrl(`/checkout/${organization.slug}/`));
170+
navigate(normalizeUrl(`/checkout/${organization.slug}/`));
170171
}}
171172
>
172173
{t('Update Plan')}
@@ -209,7 +210,7 @@ export function ProductTrialAlert(props: ProductTrialAlertProps) {
209210
<Button
210211
priority="primary"
211212
onClick={() => {
212-
browserHistory.push(normalizeUrl(`/checkout/${organization.slug}/`));
213+
navigate(normalizeUrl(`/checkout/${organization.slug}/`));
213214
}}
214215
>
215216
{t('Update Plan')}

static/gsApp/components/upsellProvider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {Client} from 'sentry/api';
77
import {Confirm} from 'sentry/components/confirm';
88
import {t, tct} from 'sentry/locale';
99
import type {Organization} from 'sentry/types/organization';
10-
import {browserHistory} from 'sentry/utils/browserHistory';
1110
import {normalizeUrl} from 'sentry/utils/url/normalizeUrl';
11+
import {useNavigate} from 'sentry/utils/useNavigate';
1212
import {withApi} from 'sentry/utils/withApi';
1313
import {withOrganization} from 'sentry/utils/withOrganization';
1414

@@ -87,6 +87,7 @@ function UpsellProvider({
8787
showConfirmation,
8888
children,
8989
}: Props) {
90+
const navigate = useNavigate();
9091
// if the org or subscription isn't loaded yet, don't render anything
9192
if (!organization || !subscription) {
9293
return null;
@@ -215,7 +216,7 @@ function UpsellProvider({
215216
const baseUrl = subscription.canSelfServe
216217
? `/checkout/${organization.slug}/`
217218
: `/settings/${organization.slug}/billing/overview/`;
218-
browserHistory.push(`${normalizeUrl(baseUrl)}?referrer=upsell-${source}`);
219+
navigate(`${normalizeUrl(baseUrl)}?referrer=upsell-${source}`);
219220
}
220221
} else {
221222
if (triggerMemberRequests) {

static/gsApp/views/cancelSubscription.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {PanelHeader} from 'sentry/components/panels/panelHeader';
1818
import {SentryDocumentTitle} from 'sentry/components/sentryDocumentTitle';
1919
import {t, tct} from 'sentry/locale';
2020
import {getApiUrl} from 'sentry/utils/api/getApiUrl';
21-
import {browserHistory} from 'sentry/utils/browserHistory';
2221
import {useApiQuery} from 'sentry/utils/queryClient';
2322
import {normalizeUrl} from 'sentry/utils/url/normalizeUrl';
2423
import {useApi} from 'sentry/utils/useApi';
@@ -273,9 +272,7 @@ function CancelSubscriptionForm() {
273272
</Button>
274273
<Button
275274
onClick={() => {
276-
browserHistory.push(
277-
normalizeUrl(`/settings/${organization.slug}/billing/`)
278-
);
275+
navigate(normalizeUrl(`/settings/${organization.slug}/billing/`));
279276
}}
280277
>
281278
{t('Never Mind')}

0 commit comments

Comments
 (0)