Skip to content

Commit e5dba45

Browse files
committed
feat(detectors): Add detector type to breadcrumbs
1 parent a5b7783 commit e5dba45

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

static/app/views/detectors/components/details/common/header.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import {
99
EditDetectorAction,
1010
} from 'sentry/views/detectors/components/details/common/actions';
1111
import {MonitorFeedbackButton} from 'sentry/views/detectors/components/monitorFeedbackButton';
12-
import {makeMonitorBasePathname} from 'sentry/views/detectors/pathnames';
12+
import {
13+
makeMonitorBasePathname,
14+
makeMonitorTypePathname,
15+
} from 'sentry/views/detectors/pathnames';
16+
import {getDetectorTypeLabel} from 'sentry/views/detectors/utils/detectorTypeConfig';
1317

1418
type DetectorDetailsHeaderProps = {
1519
detector: Detector;
@@ -28,6 +32,10 @@ export function DetectorDetailsHeader({detector, project}: DetectorDetailsHeader
2832
label: t('Monitors'),
2933
to: makeMonitorBasePathname(organization.slug),
3034
},
35+
{
36+
label: getDetectorTypeLabel(detector.type),
37+
to: makeMonitorTypePathname(organization.slug, detector.type),
38+
},
3139
{label: detector.name},
3240
]}
3341
/>

static/app/views/detectors/components/forms/common/breadcrumbs.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import useOrganization from 'sentry/utils/useOrganization';
55
import {
66
makeMonitorBasePathname,
77
makeMonitorDetailsPathname,
8+
makeMonitorTypePathname,
89
} from 'sentry/views/detectors/pathnames';
910
import {getDetectorTypeLabel} from 'sentry/views/detectors/utils/detectorTypeConfig';
1011

@@ -17,6 +18,10 @@ export function NewDetectorBreadcrumbs({detectorType}: {detectorType: DetectorTy
1718
label: t('Monitors'),
1819
to: makeMonitorBasePathname(organization.slug),
1920
},
21+
{
22+
label: getDetectorTypeLabel(detectorType),
23+
to: makeMonitorTypePathname(organization.slug, detectorType),
24+
},
2025
{
2126
label: t('New %s Monitor', getDetectorTypeLabel(detectorType)),
2227
},
@@ -34,6 +39,10 @@ export function EditDetectorBreadcrumbs({detector}: {detector: Detector}) {
3439
label: t('Monitors'),
3540
to: makeMonitorBasePathname(organization.slug),
3641
},
42+
{
43+
label: getDetectorTypeLabel(detector.type),
44+
to: makeMonitorTypePathname(organization.slug, detector.type),
45+
},
3746
{
3847
label: detector.name,
3948
to: makeMonitorDetailsPathname(organization.slug, detector.id),

static/app/views/detectors/pathnames.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
import type {DetectorType} from 'sentry/types/workflowEngine/detectors';
12
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
23

4+
const DETECTOR_TYPE_PATH_MAP: Partial<Record<DetectorType, string>> = {
5+
monitor_check_in_failure: 'crons',
6+
uptime_domain_failure: 'uptime',
7+
metric_issue: 'metrics',
8+
error: 'errors',
9+
};
10+
311
export const makeMonitorBasePathname = (orgSlug: string) => {
412
return normalizeUrl(`/organizations/${orgSlug}/monitors/`);
513
};
614

15+
export const makeMonitorTypePathname = (orgSlug: string, detectorType: DetectorType) => {
16+
const typePath = DETECTOR_TYPE_PATH_MAP[detectorType];
17+
if (!typePath) {
18+
return makeMonitorBasePathname(orgSlug);
19+
}
20+
return normalizeUrl(`${makeMonitorBasePathname(orgSlug)}${typePath}/`);
21+
};
22+
723
export const makeMonitorDetailsPathname = (orgSlug: string, monitorId: string) => {
824
return normalizeUrl(`${makeMonitorBasePathname(orgSlug)}${monitorId}/`);
925
};

0 commit comments

Comments
 (0)