@@ -23,18 +23,22 @@ import type {
2323 OrganizationIntegration ,
2424 PluginWithProjectList ,
2525} from 'sentry/types/integrations' ;
26- import type { RouteComponentProps } from 'sentry/types/legacyReactRouter' ;
2726import type { Organization } from 'sentry/types/organization' ;
2827import { isActiveSuperuser } from 'sentry/utils/isActiveSuperuser' ;
2928import { singleLineRenderer } from 'sentry/utils/marked/marked' ;
3029import type { ApiQueryKey } from 'sentry/utils/queryClient' ;
3130import { setApiQueryData , useApiQuery , useQueryClient } from 'sentry/utils/queryClient' ;
31+ import { decodeScalar } from 'sentry/utils/queryString' ;
3232import useRouteAnalyticsEventNames from 'sentry/utils/routeAnalytics/useRouteAnalyticsEventNames' ;
3333import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams' ;
3434import normalizeUrl from 'sentry/utils/url/normalizeUrl' ;
3535import useApi from 'sentry/utils/useApi' ;
36+ import { useLocation } from 'sentry/utils/useLocation' ;
37+ import { useNavigate } from 'sentry/utils/useNavigate' ;
3638import useOrganization from 'sentry/utils/useOrganization' ;
39+ import { useParams } from 'sentry/utils/useParams' ;
3740import useProjects from 'sentry/utils/useProjects' ;
41+ import { useRoutes } from 'sentry/utils/useRoutes' ;
3842import BreadcrumbTitle from 'sentry/views/settings/components/settingsBreadcrumb/breadcrumbTitle' ;
3943import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader' ;
4044
@@ -48,11 +52,6 @@ import IntegrationMainSettings from './integrationMainSettings';
4852import IntegrationRepos from './integrationRepos' ;
4953import { IntegrationServerlessFunctions } from './integrationServerlessFunctions' ;
5054
51- type Props = RouteComponentProps < {
52- integrationId : string ;
53- providerKey : string ;
54- } > ;
55-
5655const TABS = [
5756 'repos' ,
5857 'codeMappings' ,
@@ -73,12 +72,19 @@ const makePluginQuery = (organization: Organization): ApiQueryKey => {
7372 return [ `/organizations/${ organization . slug } /plugins/configs/` ] ;
7473} ;
7574
76- function ConfigureIntegration ( { params, router, routes, location} : Props ) {
75+ function ConfigureIntegration ( ) {
76+ const routes = useRoutes ( ) ;
77+ const location = useLocation ( ) ;
78+ const navigate = useNavigate ( ) ;
7779 const api = useApi ( ) ;
7880 const queryClient = useQueryClient ( ) ;
7981 const organization = useOrganization ( ) ;
80- const tab : Tab = TABS . includes ( location . query . tab ) ? location . query . tab : 'repos' ;
81- const { integrationId, providerKey} = params ;
82+ const tabParam = decodeScalar ( location . query . tab ) as Tab | undefined ;
83+ const tab : Tab = tabParam && TABS . includes ( tabParam ) ? tabParam : 'repos' ;
84+ const { integrationId, providerKey} = useParams < {
85+ integrationId : string ;
86+ providerKey : string ;
87+ } > ( ) ;
8288 const {
8389 data : config = { providers : [ ] } ,
8490 isPending : isLoadingConfig ,
@@ -133,13 +139,13 @@ function ConfigureIntegration({params, router, routes, location}: Props) {
133139 ! organization . access . includes ( 'org:integrations' ) &&
134140 ! isActiveSuperuser ( )
135141 ) {
136- router . push (
142+ navigate (
137143 normalizeUrl ( {
138144 pathname : `/settings/${ organization . slug } /integrations/${ providerKey } /` ,
139145 } )
140146 ) ;
141147 }
142- } , [ router , organization , providerKey ] ) ;
148+ } , [ navigate , organization , providerKey ] ) ;
143149
144150 if ( isLoadingConfig || isLoadingIntegration || isLoadingPlugins ) {
145151 return < LoadingIndicator /> ;
@@ -156,7 +162,7 @@ function ConfigureIntegration({params, router, routes, location}: Props) {
156162 const onTabChange = ( value : Tab ) => {
157163 // XXX: Omit the cursor to prevent paginating the next tab's queries.
158164 const { cursor : _ , ...query } = location . query ;
159- router . push ( {
165+ navigate ( {
160166 pathname : location . pathname ,
161167 query : { ...query , tab : value } ,
162168 } ) ;
0 commit comments