Skip to content

Commit 6c93986

Browse files
authored
feat(nav): Update alert links from explore/insights/crons (#85254)
1 parent d4edc94 commit 6c93986

File tree

11 files changed

+58
-17
lines changed

11 files changed

+58
-17
lines changed

Diff for: static/app/views/explore/components/chartContextMenu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function ChartContextMenu({
4242
query,
4343
pageFilters: pageFilters.selection,
4444
aggregate: yAxis,
45-
orgSlug: organization.slug,
45+
organization,
4646
dataset: Dataset.EVENTS_ANALYTICS_PLATFORM,
4747
interval,
4848
}),

Diff for: static/app/views/explore/toolbar/toolbarSaveAs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function ToolbarSaveAs() {
4646
query,
4747
pageFilters: pageFilters.selection,
4848
aggregate: yAxis,
49-
orgSlug: organization.slug,
49+
organization,
5050
dataset: Dataset.EVENTS_ANALYTICS_PLATFORM,
5151
interval,
5252
}),

Diff for: static/app/views/insights/common/utils/getAlertsUrl.spec.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {OrganizationFixture} from 'sentry-fixture/organization';
12
import {PageFiltersFixture} from 'sentry-fixture/pageFilters';
23

34
import {initializeOrg} from 'sentry-test/initializeOrg';
@@ -16,7 +17,7 @@ describe('getAlertsUrl', function () {
1617
project,
1718
aggregate,
1819
query,
19-
orgSlug,
20+
organization: OrganizationFixture({slug: orgSlug}),
2021
pageFilters,
2122
});
2223
expect(url).toBe(
@@ -31,7 +32,7 @@ describe('getAlertsUrl', function () {
3132
project,
3233
aggregate,
3334
query,
34-
orgSlug,
35+
organization: OrganizationFixture({slug: orgSlug}),
3536
pageFilters,
3637
dataset: Dataset.EVENTS_ANALYTICS_PLATFORM,
3738
});

Diff for: static/app/views/insights/common/utils/getAlertsUrl.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import * as qs from 'query-string';
22

33
import type {PageFilters} from 'sentry/types/core';
4+
import type {Organization} from 'sentry/types/organization';
45
import type {Project} from 'sentry/types/project';
5-
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
6+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
67
import {Dataset} from 'sentry/views/alerts/rules/metric/types';
78

89
export function getAlertsUrl({
910
project,
1011
query,
1112
aggregate,
12-
orgSlug,
13+
organization,
1314
pageFilters,
1415
name,
1516
interval,
1617
dataset = Dataset.GENERIC_METRICS,
1718
}: {
1819
aggregate: string;
19-
orgSlug: string;
20+
organization: Organization;
2021
pageFilters: PageFilters;
2122
dataset?: Dataset;
2223
interval?: string;
@@ -38,8 +39,12 @@ export function getAlertsUrl({
3839
name,
3940
interval: supportedInterval,
4041
};
41-
return normalizeUrl(
42-
`/organizations/${orgSlug}/alerts/new/metric/?${qs.stringify(queryParams)}`
42+
43+
return (
44+
makeAlertsPathname({
45+
path: `/new/metric/`,
46+
organization,
47+
}) + `?${qs.stringify(queryParams)}`
4348
);
4449
}
4550

Diff for: static/app/views/insights/uptime/components/overviewTimeline/overviewRow.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import getDuration from 'sentry/utils/duration/getDuration';
1616
import {useLocation} from 'sentry/utils/useLocation';
1717
import useOrganization from 'sentry/utils/useOrganization';
1818
import useProjectFromSlug from 'sentry/utils/useProjectFromSlug';
19+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
1920
import type {UptimeRule} from 'sentry/views/alerts/rules/uptime/types';
2021

2122
import {checkStatusPrecedent, statusToText, tickStyle} from '../../timelineConfig';
@@ -51,7 +52,10 @@ export function OverviewRow({uptimeRule, timeWindowConfig, singleRuleView}: Prop
5152
<DetailsArea>
5253
<DetailsLink
5354
to={{
54-
pathname: `/organizations/${organization.slug}/alerts/rules/uptime/${uptimeRule.projectSlug}/${uptimeRule.id}/details/`,
55+
pathname: makeAlertsPathname({
56+
path: `/rules/uptime/${uptimeRule.projectSlug}/${uptimeRule.id}/details/`,
57+
organization,
58+
}),
5559
query,
5660
}}
5761
>

Diff for: static/app/views/insights/uptime/views/overview.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyti
2626
import {useLocation} from 'sentry/utils/useLocation';
2727
import {useNavigate} from 'sentry/utils/useNavigate';
2828
import useOrganization from 'sentry/utils/useOrganization';
29+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
2930
import type {UptimeRule} from 'sentry/views/alerts/rules/uptime/types';
3031
import {ModulePageProviders} from 'sentry/views/insights/common/components/modulePageProviders';
3132
import {BackendHeader} from 'sentry/views/insights/pages/backend/backendPageHeader';
@@ -108,7 +109,10 @@ export default function UptimeOverview() {
108109
}
109110
size="sm"
110111
priority="primary"
111-
to={`/organizations/${organization.slug}/alerts/new/uptime/`}
112+
to={makeAlertsPathname({
113+
path: `/new/uptime/`,
114+
organization,
115+
})}
112116
icon={<IconAdd isCircled />}
113117
>
114118
{t('Add Uptime Monitor')}
@@ -157,7 +161,10 @@ export default function UptimeOverview() {
157161
<LinkButton
158162
size="sm"
159163
priority="primary"
160-
to={`/organizations/${organization.slug}/alerts/new/uptime/`}
164+
to={makeAlertsPathname({
165+
path: `/new/uptime/`,
166+
organization,
167+
})}
161168
icon={<IconAdd isCircled />}
162169
>
163170
{t('Add Uptime Monitor')}

Diff for: static/app/views/monitors/components/monitorForm.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import commonTheme from 'sentry/utils/theme';
3030
import useOrganization from 'sentry/utils/useOrganization';
3131
import usePageFilters from 'sentry/utils/usePageFilters';
3232
import useProjects from 'sentry/utils/useProjects';
33+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
3334
import {getScheduleIntervals} from 'sentry/views/monitors/utils';
3435
import {crontabAsText} from 'sentry/views/monitors/utils/crontabAsText';
3536

@@ -494,7 +495,10 @@ function MonitorForm({
494495
{monitor?.config.alert_rule_id && (
495496
<AlertLink
496497
priority="muted"
497-
to={`/organizations/${organization.slug}/alerts/rules/${monitor.project.slug}/${monitor.config.alert_rule_id}/`}
498+
to={makeAlertsPathname({
499+
path: `/rules/${monitor.project.slug}/${monitor.config.alert_rule_id}/`,
500+
organization,
501+
})}
498502
withoutMarginBottom
499503
>
500504
{t('Customize this monitors notification configuration in Alerts')}

Diff for: static/app/views/monitors/components/monitorHeader.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {Breadcrumbs} from 'sentry/components/breadcrumbs';
22
import IdBadge from 'sentry/components/idBadge';
33
import * as Layout from 'sentry/components/layouts/thirds';
44
import {t} from 'sentry/locale';
5+
import useOrganization from 'sentry/utils/useOrganization';
6+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
57

68
import type {Monitor} from '../types';
79

@@ -18,11 +20,15 @@ interface Props {
1820
}
1921

2022
export function MonitorHeader({monitor, orgSlug, onUpdate, linkToAlerts}: Props) {
23+
const organization = useOrganization();
2124
const crumbs = [
2225
{
2326
label: linkToAlerts ? t('Alerts') : t('Crons'),
2427
to: linkToAlerts
25-
? `/organizations/${orgSlug}/alerts/rules/`
28+
? makeAlertsPathname({
29+
path: `/rules/`,
30+
organization,
31+
})
2632
: `/organizations/${orgSlug}/crons/`,
2733
preservePageFilters: true,
2834
},

Diff for: static/app/views/monitors/components/monitorHeaderActions.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import {t} from 'sentry/locale';
88
import {browserHistory} from 'sentry/utils/browserHistory';
99
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
1010
import useApi from 'sentry/utils/useApi';
11+
import useOrganization from 'sentry/utils/useOrganization';
1112
import usePageFilters from 'sentry/utils/usePageFilters';
13+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
1214

1315
import type {Monitor} from '../types';
1416

@@ -26,6 +28,7 @@ type Props = {
2628

2729
function MonitorHeaderActions({monitor, orgSlug, onUpdate, linkToAlerts}: Props) {
2830
const api = useApi();
31+
const organization = useOrganization();
2932
const {selection} = usePageFilters();
3033

3134
const endpointOptions = {
@@ -81,7 +84,10 @@ function MonitorHeaderActions({monitor, orgSlug, onUpdate, linkToAlerts}: Props)
8184
icon={<IconEdit />}
8285
to={{
8386
pathname: linkToAlerts
84-
? `/organizations/${orgSlug}/alerts/crons-rules/${monitor.project.slug}/${monitor.slug}/`
87+
? makeAlertsPathname({
88+
path: `/crons-rules/${monitor.project.slug}/${monitor.slug}/`,
89+
organization,
90+
})
8591
: `/organizations/${orgSlug}/crons/${monitor.project.slug}/${monitor.slug}/edit/`,
8692
// TODO(davidenwang): Right now we have to pass the environment
8793
// through the URL so that when we save the monitor and are

Diff for: static/app/views/monitors/components/newMonitorButton.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {LinkButtonProps} from 'sentry/components/button';
22
import {LinkButton} from 'sentry/components/button';
33
import useOrganization from 'sentry/utils/useOrganization';
44
import usePageFilters from 'sentry/utils/usePageFilters';
5+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
56

67
interface Props extends Omit<LinkButtonProps, 'to' | 'external'> {
78
/**
@@ -18,7 +19,10 @@ export function NewMonitorButton({linkToAlerts, ...props}: Props) {
1819
<LinkButton
1920
to={{
2021
pathname: linkToAlerts
21-
? `/organizations/${organization.slug}/alerts/new/crons/`
22+
? makeAlertsPathname({
23+
path: `/new/crons/`,
24+
organization,
25+
})
2226
: `/organizations/${organization.slug}/crons/create/`,
2327
query: linkToAlerts ? undefined : {project: selection.projects},
2428
}}

Diff for: static/app/views/monitors/components/overviewTimeline/overviewRow.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {space} from 'sentry/styles/space';
2020
import type {ObjectStatus} from 'sentry/types/core';
2121
import {useLocation} from 'sentry/utils/useLocation';
2222
import useOrganization from 'sentry/utils/useOrganization';
23+
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
2324
import type {Monitor} from 'sentry/views/monitors/types';
2425
import {scheduleAsText} from 'sentry/views/monitors/utils/scheduleAsText';
2526

@@ -80,7 +81,10 @@ export function OverviewRow({
8081

8182
const to = linkToAlerts
8283
? {
83-
pathname: `/organizations/${organization.slug}/alerts/rules/crons/${monitor.project.slug}/${monitor.slug}/details/`,
84+
pathname: makeAlertsPathname({
85+
path: `/rules/crons/${monitor.project.slug}/${monitor.slug}/details/`,
86+
organization,
87+
}),
8488
query,
8589
}
8690
: {

0 commit comments

Comments
 (0)