Skip to content

Commit 0c24041

Browse files
authored
chore(nav): Convert more links to new route structure (#87235)
- Some links to /projects/new - Link on metric alert details page - Some stats links
1 parent c702322 commit 0c24041

File tree

7 files changed

+64
-14
lines changed

7 files changed

+64
-14
lines changed

static/app/components/modals/suggestProjectModal.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {space} from 'sentry/styles/space';
2323
import type {Organization} from 'sentry/types/organization';
2424
import {trackAnalytics} from 'sentry/utils/analytics';
2525
import withApi from 'sentry/utils/withApi';
26+
import {makeProjectsPathname} from 'sentry/views/projects/pathname';
2627

2728
type Props = ModalRenderProps & {
2829
api: Client;
@@ -108,7 +109,11 @@ function SuggestProjectModal(props: Props) {
108109
category: 'mobile',
109110
});
110111

111-
const newProjectLink = `/organizations/${organization.slug}/projects/new/?${paramString}`;
112+
const newProjectLink =
113+
makeProjectsPathname({
114+
path: '/new/',
115+
orgSlug: organization.slug,
116+
}) + `?${paramString}`;
112117

113118
return (
114119
<Fragment>

static/app/views/alerts/utils/index.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {getUtcDateString} from 'sentry/utils/dates';
99
import {axisLabelFormatter, tooltipFormatter} from 'sentry/utils/discover/charts';
1010
import {aggregateOutputType} from 'sentry/utils/discover/fields';
1111
import {formatMetricUsingUnit} from 'sentry/utils/number/formatMetricUsingUnit';
12+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
1213
import {
1314
Dataset,
1415
Datasource,
@@ -166,12 +167,15 @@ export function shouldScaleAlertChart(aggregate: string) {
166167
}
167168

168169
export function alertDetailsLink(organization: Organization, incident: Incident) {
169-
return `/organizations/${organization.slug}/alerts/rules/details/${
170-
incident.alertRule.status === AlertRuleStatus.SNAPSHOT &&
171-
incident.alertRule.originalAlertRuleId
172-
? incident.alertRule.originalAlertRuleId
173-
: incident.alertRule.id
174-
}/`;
170+
return makeAlertsPathname({
171+
path: `/rules/details/${
172+
incident.alertRule.status === AlertRuleStatus.SNAPSHOT &&
173+
incident.alertRule.originalAlertRuleId
174+
? incident.alertRule.originalAlertRuleId
175+
: incident.alertRule.id
176+
}/`,
177+
organization,
178+
});
175179
}
176180

177181
/**

static/app/views/organizationStats/header.tsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionT
44
import {TabList} from 'sentry/components/tabs';
55
import {t} from 'sentry/locale';
66
import type {Organization} from 'sentry/types/organization';
7-
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
7+
import {makeStatsPathname} from 'sentry/views/organizationStats/pathname';
88

99
type Props = {
1010
activeTab: 'stats' | 'issues' | 'health';
@@ -34,19 +34,28 @@ function StatsHeader({organization, activeTab}: Props) {
3434
<TabList hideBorder>
3535
<TabList.Item
3636
key="stats"
37-
to={normalizeUrl(`/organizations/${organization.slug}/stats/`)}
37+
to={makeStatsPathname({
38+
path: '/',
39+
organization,
40+
})}
3841
>
3942
{t('Usage')}
4043
</TabList.Item>
4144
<TabList.Item
4245
key="issues"
43-
to={normalizeUrl(`/organizations/${organization.slug}/stats/issues/`)}
46+
to={makeStatsPathname({
47+
path: '/issues/',
48+
organization,
49+
})}
4450
>
4551
{t('Issues')}
4652
</TabList.Item>
4753
<TabList.Item
4854
key="health"
49-
to={normalizeUrl(`/organizations/${organization.slug}/stats/health/`)}
55+
to={makeStatsPathname({
56+
path: '/health/',
57+
organization,
58+
})}
5059
>
5160
{t('Health')}
5261
</TabList.Item>

static/app/views/organizationStats/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import withOrganization from 'sentry/utils/withOrganization';
3636
import withPageFilters from 'sentry/utils/withPageFilters';
3737
import HeaderTabs from 'sentry/views/organizationStats/header';
3838
import {getPerformanceBaseUrl} from 'sentry/views/performance/utils';
39+
import {makeProjectsPathname} from 'sentry/views/projects/pathname';
3940

4041
import type {ChartDataTransform} from './usageChart';
4142
import {CHART_OPTIONS_DATACATEGORY} from './usageChart';
@@ -193,7 +194,10 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {
193194
},
194195
projectDetail: {
195196
...nextLocation,
196-
pathname: `/organizations/${organization.slug}/projects/${project.slug}/`,
197+
pathname: makeProjectsPathname({
198+
path: `/${project.slug}/`,
199+
orgSlug: organization.slug,
200+
}),
197201
},
198202
issueList: {
199203
...nextLocation,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {prefersStackedNav} from 'sentry/components/nav/prefersStackedNav';
2+
import type {Organization} from 'sentry/types/organization';
3+
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
4+
5+
const LEGACY_STATS_BASE_PATHNAME = 'stats';
6+
const STATS_BASE_PATHNAME = 'settings/stats';
7+
8+
export function makeStatsPathname({
9+
path,
10+
organization,
11+
}: {
12+
organization: Organization;
13+
path: '/' | `/${string}/`;
14+
}) {
15+
return normalizeUrl(
16+
prefersStackedNav()
17+
? `/organizations/${organization.slug}/${STATS_BASE_PATHNAME}${path}`
18+
: `/organizations/${organization.slug}/${LEGACY_STATS_BASE_PATHNAME}${path}`
19+
);
20+
}

static/app/views/projectsDashboard/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {useTeamsById} from 'sentry/utils/useTeamsById';
3737
import {useUser} from 'sentry/utils/useUser';
3838
import {useUserTeams} from 'sentry/utils/useUserTeams';
3939
import TeamFilter from 'sentry/views/alerts/list/rules/teamFilter';
40+
import {makeProjectsPathname} from 'sentry/views/projects/pathname';
4041

4142
import ProjectCard from './projectCard';
4243
import Resources from './resources';
@@ -205,7 +206,10 @@ function Dashboard() {
205206
? undefined
206207
: t('You do not have permission to create projects')
207208
}
208-
to={`/organizations/${organization.slug}/projects/new/`}
209+
to={makeProjectsPathname({
210+
path: '/new/',
211+
orgSlug: organization.slug,
212+
})}
209213
icon={<IconAdd isCircled />}
210214
data-test-id="create-project"
211215
>

static/app/views/settings/organizationProjects/createProjectButton.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {IconAdd} from 'sentry/icons';
33
import {t} from 'sentry/locale';
44
import {useCanCreateProject} from 'sentry/utils/useCanCreateProject';
55
import useOrganization from 'sentry/utils/useOrganization';
6+
import {makeProjectsPathname} from 'sentry/views/projects/pathname';
67

78
export default function CreateProjectButton() {
89
const organization = useOrganization();
@@ -18,7 +19,10 @@ export default function CreateProjectButton() {
1819
? undefined
1920
: t('You do not have permission to create projects')
2021
}
21-
to={`/organizations/${organization.slug}/projects/new/`}
22+
to={makeProjectsPathname({
23+
path: '/new/',
24+
orgSlug: organization.slug,
25+
})}
2226
icon={<IconAdd isCircled />}
2327
>
2428
{t('Create Project')}

0 commit comments

Comments
 (0)