Skip to content

Commit b2af83c

Browse files
authored
feat(aci): Rewire insights crons/uptime links to go to Monitors (#103129)
1 parent 06e868a commit b2af83c

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {parseAsBoolean, useQueryState} from 'nuqs';
2+
3+
import {Alert} from '@sentry/scraps/alert';
4+
import {Button} from '@sentry/scraps/button';
5+
6+
import {IconClose} from 'sentry/icons';
7+
import {t} from 'sentry/locale';
8+
9+
export function InsightsRedirectNotice({children}: {children: React.ReactNode}) {
10+
const [wasRedirectedFromInsights, setWasRedirectedFromInsights] = useQueryState(
11+
'insightsRedirect',
12+
parseAsBoolean.withOptions({history: 'replace'}).withDefault(false)
13+
);
14+
15+
if (!wasRedirectedFromInsights) {
16+
return null;
17+
}
18+
19+
return (
20+
<Alert
21+
type="info"
22+
trailingItems={
23+
<Button
24+
size="zero"
25+
borderless
26+
icon={<IconClose />}
27+
aria-label={t('Dismiss')}
28+
onClick={() => {
29+
setWasRedirectedFromInsights(false);
30+
}}
31+
/>
32+
}
33+
>
34+
{children}
35+
</Alert>
36+
);
37+
}

static/app/views/detectors/list/cron.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {HeaderCell} from 'sentry/views/detectors/components/detectorListTable';
1919
import {DetectorListActions} from 'sentry/views/detectors/list/common/detectorListActions';
2020
import {DetectorListContent} from 'sentry/views/detectors/list/common/detectorListContent';
2121
import {DetectorListHeader} from 'sentry/views/detectors/list/common/detectorListHeader';
22+
import {InsightsRedirectNotice} from 'sentry/views/detectors/list/common/insightsRedirectNotice';
2223
import {useDetectorListQuery} from 'sentry/views/detectors/list/common/useDetectorListQuery';
2324
import {
2425
MonitorViewContext,
@@ -155,6 +156,9 @@ export default function CronDetectorsList() {
155156
description={DESCRIPTION}
156157
docsUrl={DOCS_URL}
157158
>
159+
<InsightsRedirectNotice>
160+
{t('Cron monitors have been moved from Insights to Monitors.')}
161+
</InsightsRedirectNotice>
158162
<DetectorListHeader showTimeRangeSelector showTypeFilter={false} />
159163
<DetectorListContent
160164
{...detectorListQuery}

static/app/views/detectors/list/uptime.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {useDimensions} from 'sentry/utils/useDimensions';
1616
import {DetectorListActions} from 'sentry/views/detectors/list/common/detectorListActions';
1717
import {DetectorListContent} from 'sentry/views/detectors/list/common/detectorListContent';
1818
import {DetectorListHeader} from 'sentry/views/detectors/list/common/detectorListHeader';
19+
import {InsightsRedirectNotice} from 'sentry/views/detectors/list/common/insightsRedirectNotice';
1920
import {useDetectorListQuery} from 'sentry/views/detectors/list/common/useDetectorListQuery';
2021
import {
2122
MonitorViewContext,
@@ -109,6 +110,9 @@ export default function UptimeDetectorsList() {
109110
description={DESCRIPTION}
110111
docsUrl={DOCS_URL}
111112
>
113+
<InsightsRedirectNotice>
114+
{t('Uptime monitors have been moved from Insights to Monitors.')}
115+
</InsightsRedirectNotice>
112116
<DetectorListHeader showTimeRangeSelector showTypeFilter={false} />
113117
<DetectorListContent {...detectorListQuery} />
114118
</WorkflowEngineListLayout>

static/app/views/nav/secondary/sections/insights/insightsSecondaryNav.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {FeatureBadge} from 'sentry/components/core/badge/featureBadge';
66
import {t} from 'sentry/locale';
77
import useOrganization from 'sentry/utils/useOrganization';
88
import useProjects from 'sentry/utils/useProjects';
9+
import {useUser} from 'sentry/utils/useUser';
10+
import {makeMonitorBasePathname} from 'sentry/views/detectors/pathnames';
911
import {
1012
AGENTS_LANDING_SUB_PATH,
1113
AGENTS_SIDEBAR_LABEL,
@@ -33,6 +35,7 @@ import {SecondaryNav} from 'sentry/views/nav/secondary/secondary';
3335
import {PrimaryNavGroup} from 'sentry/views/nav/types';
3436

3537
export function InsightsSecondaryNav() {
38+
const user = useUser();
3639
const organization = useOrganization();
3740
const baseUrl = `/organizations/${organization.slug}/${DOMAIN_VIEW_BASE_URL}`;
3841

@@ -47,6 +50,9 @@ export function InsightsSecondaryNav() {
4750
? starredProjects.slice(0, 8)
4851
: nonStarredProjects.filter(project => project.isMember).slice(0, 8);
4952

53+
const shouldRedirectToMonitors =
54+
organization.features.includes('workflow-engine-ui') && !user?.isStaff;
55+
5056
return (
5157
<Fragment>
5258
<SecondaryNav.Header>
@@ -89,12 +95,23 @@ export function InsightsSecondaryNav() {
8995
</SecondaryNav.Item>
9096
</SecondaryNav.Section>
9197
<SecondaryNav.Section id="insights-monitors">
92-
<SecondaryNav.Item to={`${baseUrl}/crons/`} analyticsItemName="insights_crons">
98+
<SecondaryNav.Item
99+
to={
100+
shouldRedirectToMonitors
101+
? `${makeMonitorBasePathname(organization.slug)}crons/?insightsRedirect=true`
102+
: `${baseUrl}/crons/`
103+
}
104+
analyticsItemName="insights_crons"
105+
>
93106
{t('Crons')}
94107
</SecondaryNav.Item>
95108
<Feature features={['uptime']}>
96109
<SecondaryNav.Item
97-
to={`${baseUrl}/uptime/`}
110+
to={
111+
shouldRedirectToMonitors
112+
? `${makeMonitorBasePathname(organization.slug)}uptime/?insightsRedirect=true`
113+
: `${baseUrl}/uptime/`
114+
}
98115
analyticsItemName="insights_uptime"
99116
>
100117
{t('Uptime')}

0 commit comments

Comments
 (0)