Skip to content

Commit 12b7cc8

Browse files
authored
ref(stats): Remove deprecated router props from issue stats (#97605)
Removes the deprecated router props from the team issue stats page
1 parent 42fffe5 commit 12b7cc8

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

static/app/routes.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,6 @@ function buildRoutes(): RouteObject[] {
867867
component: make(
868868
() => import('sentry/views/organizationStats/teamInsights/issues')
869869
),
870-
deprecatedRouteProps: true,
871870
},
872871
{
873872
path: 'health/',

static/app/views/organizationStats/teamInsights/issues.spec.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {TeamFixture} from 'sentry-fixture/team';
44
import {TeamIssuesBreakdownFixture} from 'sentry-fixture/teamIssuesBreakdown';
55
import {TeamResolutionTimeFixture} from 'sentry-fixture/teamResolutionTime';
66

7-
import {initializeOrg} from 'sentry-test/initializeOrg';
87
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
98

109
import ProjectsStore from 'sentry/stores/projectsStore';
@@ -56,7 +55,6 @@ describe('TeamStatsIssues', () => {
5655
projects: [],
5756
isMember: false,
5857
});
59-
const {routerProps, router} = initializeOrg();
6058

6159
beforeEach(() => {
6260
TeamStore.reset();
@@ -146,7 +144,7 @@ describe('TeamStatsIssues', () => {
146144

147145
TeamStore.loadInitialData(teams, false, null);
148146

149-
return render(<TeamStatsIssues {...routerProps} />, {organization});
147+
return render(<TeamStatsIssues />, {organization});
150148
}
151149

152150
it('defaults to first team', async () => {
@@ -157,50 +155,54 @@ describe('TeamStatsIssues', () => {
157155
});
158156

159157
it('allows team switching as non-owner', async () => {
160-
createWrapper({isOrgOwner: false});
158+
MockApiClient.addMockResponse({
159+
url: `/teams/org-slug/${team1.slug}/issues/old/`,
160+
body: [],
161+
});
162+
MockApiClient.addMockResponse({
163+
url: `/teams/org-slug/${team1.slug}/unresolved-issue-age/`,
164+
body: [],
165+
});
166+
const {router} = createWrapper({isOrgOwner: false});
161167

162168
expect(screen.getByText('#backend')).toBeInTheDocument();
163169
await userEvent.type(screen.getByText('#backend'), '{mouseDown}');
164170
expect(screen.getByText('#frontend')).toBeInTheDocument();
165171
// Teams user is not a member of are hidden
166172
expect(screen.queryByText('#internal')).not.toBeInTheDocument();
167173
await userEvent.click(screen.getByText('#frontend'));
168-
expect(router.push).toHaveBeenCalledWith(
169-
expect.objectContaining({query: {team: team1.id}})
170-
);
174+
expect(router.location).toEqual(expect.objectContaining({query: {team: team1.id}}));
171175
expect(localStorage.setItem).toHaveBeenCalledWith(
172176
'teamInsightsSelectedTeamId:org-slug',
173177
team1.id
174178
);
175179
});
176180

177181
it('allows team switching as owner', async () => {
178-
createWrapper();
182+
const {router} = createWrapper();
179183

180184
expect(screen.getByText('#backend')).toBeInTheDocument();
181185
await userEvent.type(screen.getByText('#backend'), '{mouseDown}');
182186
expect(screen.getByText('#frontend')).toBeInTheDocument();
183187
// Org owners can see all teams including ones they are not members of
184188
expect(screen.getByText('#internal')).toBeInTheDocument();
185189
await userEvent.click(screen.getByText('#internal'));
186-
expect(router.push).toHaveBeenCalledWith(
187-
expect.objectContaining({query: {team: team3.id}})
188-
);
190+
expect(router.location).toEqual(expect.objectContaining({query: {team: team3.id}}));
189191
expect(localStorage.setItem).toHaveBeenCalledWith(
190192
'teamInsightsSelectedTeamId:org-slug',
191193
team3.id
192194
);
193195
});
194196

195197
it('can filter by environment', async () => {
196-
createWrapper();
198+
const {router} = createWrapper();
197199

198200
// For some reason the "Environment:" is rendered via css :before
199201
expect(screen.getByText('All')).toBeInTheDocument();
200202
await userEvent.type(screen.getByText('All'), '{mouseDown}');
201203
expect(screen.getByText(env1)).toBeInTheDocument();
202204
await userEvent.click(screen.getByText(env1));
203-
expect(router.push).toHaveBeenCalledWith(
205+
expect(router.location).toEqual(
204206
expect.objectContaining({query: {environment: 'prod'}})
205207
);
206208
});

static/app/views/organizationStats/teamInsights/issues.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import LoadingIndicator from 'sentry/components/loadingIndicator';
77
import NoProjectMessage from 'sentry/components/noProjectMessage';
88
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
99
import {t} from 'sentry/locale';
10-
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
1110
import type {TeamWithProjects} from 'sentry/types/project';
1211
import localStorage from 'sentry/utils/localStorage';
1312
import useRouteAnalyticsEventNames from 'sentry/utils/routeAnalytics/useRouteAnalyticsEventNames';
13+
import {useLocation} from 'sentry/utils/useLocation';
1414
import useOrganization from 'sentry/utils/useOrganization';
15+
import useRouter from 'sentry/utils/useRouter';
1516
import {useUserTeams} from 'sentry/utils/useUserTeams';
1617
import {usePrefersStackedNav} from 'sentry/views/nav/usePrefersStackedNav';
1718
import Header from 'sentry/views/organizationStats/header';
@@ -24,10 +25,10 @@ import TeamResolutionTime from './teamResolutionTime';
2425
import {TeamUnresolvedIssues} from './teamUnresolvedIssues';
2526
import {dataDatetime} from './utils';
2627

27-
type Props = RouteComponentProps;
28-
29-
function TeamStatsIssues({location, router}: Props) {
28+
function TeamStatsIssues() {
3029
const organization = useOrganization();
30+
const location = useLocation();
31+
const router = useRouter();
3132
const {teams, isLoading, isError} = useUserTeams();
3233
const prefersStackedNav = usePrefersStackedNav();
3334

@@ -37,7 +38,7 @@ function TeamStatsIssues({location, router}: Props) {
3738
const localStorageKey = `teamInsightsSelectedTeamId:${organization.slug}`;
3839

3940
let localTeamId: string | null | undefined =
40-
query.team ?? localStorage.getItem(localStorageKey);
41+
(query.team as string | undefined) ?? localStorage.getItem(localStorageKey);
4142
if (localTeamId && !teams.some(team => team.id === localTeamId)) {
4243
localTeamId = null;
4344
}
@@ -46,7 +47,7 @@ function TeamStatsIssues({location, router}: Props) {
4647
| TeamWithProjects
4748
| undefined;
4849
const projects = currentTeam?.projects ?? [];
49-
const environment = query.environment;
50+
const environment = query.environment as string | undefined;
5051

5152
const {period, start, end, utc} = dataDatetime(query);
5253

0 commit comments

Comments
 (0)