Skip to content

Commit b97eee2

Browse files
authored
ref(settings): Refactor settings/$project/replay to not rely on deprecatedRouteProps (#96701)
1 parent 8e4e5ee commit b97eee2

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

static/app/routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ function buildRoutes(): RouteObject[] {
680680
path: 'replays/',
681681
name: t('Replays'),
682682
component: make(() => import('sentry/views/settings/project/projectReplays')),
683-
deprecatedRouteProps: true,
683+
deprecatedRouteProps: true, // Should be false except for ProjectContext passed via `outletContext`
684684
},
685685
{
686686
path: 'toolbar/',

static/app/views/settings/project/projectReplays.spec.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,37 @@ import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
66
import ProjectReplays from 'sentry/views/settings/project/projectReplays';
77

88
describe('ProjectReplays', function () {
9-
const {routerProps, organization, project} = initializeOrg();
10-
const url = `/projects/${organization.slug}/${project.slug}/`;
9+
const {organization, project} = initializeOrg();
10+
const initialRouterConfig = {
11+
location: {
12+
pathname: `/settings/projects/${project.slug}/replays/`,
13+
},
14+
route: '/settings/projects/:projectId/replays/',
15+
};
16+
const getProjectEndpoint = `/projects/${organization.slug}/${project.slug}/`;
1117

1218
beforeEach(function () {
1319
MockApiClient.clearMockResponses();
1420
MockApiClient.addMockResponse({
15-
url,
21+
url: getProjectEndpoint,
1622
method: 'GET',
1723
body: ProjectFixture(),
1824
});
1925
MockApiClient.addMockResponse({
20-
url: `${url}keys/`,
26+
url: `${getProjectEndpoint}keys/`,
2127
method: 'GET',
2228
body: [],
2329
});
2430
});
2531

2632
it('can toggle rage click issue creation', async function () {
27-
render(
28-
<ProjectReplays {...routerProps} organization={organization} project={project} />
29-
);
33+
render(<ProjectReplays project={project} />, {
34+
initialRouterConfig,
35+
organization,
36+
});
3037

3138
const mock = MockApiClient.addMockResponse({
32-
url,
39+
url: getProjectEndpoint,
3340
method: 'PUT',
3441
});
3542

@@ -38,7 +45,7 @@ describe('ProjectReplays', function () {
3845
);
3946

4047
expect(mock).toHaveBeenCalledWith(
41-
url,
48+
getProjectEndpoint,
4249
expect.objectContaining({
4350
method: 'PUT',
4451
data: {

static/app/views/settings/project/projectReplays.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import ReplayBulkDeleteAuditLog from 'sentry/components/replays/bulkDelete/repla
1212
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
1313
import {t, tct} from 'sentry/locale';
1414
import ProjectsStore from 'sentry/stores/projectsStore';
15-
import {space} from 'sentry/styles/space';
16-
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
17-
import type {Organization} from 'sentry/types/organization';
1815
import type {Project} from 'sentry/types/project';
1916
import useUrlParams from 'sentry/utils/url/useUrlParams';
17+
import useOrganization from 'sentry/utils/useOrganization';
18+
import {useParams} from 'sentry/utils/useParams';
2019
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
2120
import {ProjectPermissionAlert} from 'sentry/views/settings/project/projectPermissionAlert';
2221

@@ -25,19 +24,14 @@ const ReplaySettingsAlert = HookOrDefault({
2524
defaultComponent: null,
2625
});
2726

28-
type RouteParams = {
29-
projectId: string;
30-
};
31-
type Props = RouteComponentProps<RouteParams> & {
32-
organization: Organization;
33-
project: Project;
34-
};
27+
interface Props {
28+
project: Project; // Passed in by the parent route
29+
}
30+
31+
export default function ProjectReplaySettings({project}: Props) {
32+
const organization = useOrganization();
33+
const {projectId} = useParams();
3534

36-
export default function ProjectReplaySettings({
37-
organization,
38-
project,
39-
params: {projectId},
40-
}: Props) {
4135
const hasWriteAccess = hasEveryAccess(['project:write'], {organization, project});
4236
const hasAdminAccess = hasEveryAccess(['project:admin'], {organization, project});
4337
const hasAccess = hasWriteAccess || hasAdminAccess;
@@ -141,5 +135,5 @@ export default function ProjectReplaySettings({
141135
}
142136

143137
const TabsWithGap = styled(Tabs)`
144-
gap: ${space(2)};
138+
gap: ${p => p.theme.space.xl};
145139
`;

0 commit comments

Comments
 (0)