|
| 1 | +import ExternalLink from 'sentry/components/links/externalLink'; |
| 2 | +import Placeholder from 'sentry/components/placeholder'; |
| 3 | +import DetailLayout from 'sentry/components/workflowEngine/layout/detail'; |
| 4 | +import Section from 'sentry/components/workflowEngine/ui/section'; |
| 5 | +import {t, tct, tn} from 'sentry/locale'; |
| 6 | +import type {Project} from 'sentry/types/project'; |
| 7 | +import type {Detector} from 'sentry/types/workflowEngine/detectors'; |
| 8 | +import {useDetailedProject} from 'sentry/utils/useDetailedProject'; |
| 9 | +import useOrganization from 'sentry/utils/useOrganization'; |
| 10 | +import {DetectorDetailsAssignee} from 'sentry/views/detectors/components/details/common/assignee'; |
| 11 | +import {DetectorDetailsAutomations} from 'sentry/views/detectors/components/details/common/automations'; |
| 12 | +import {DetectorExtraDetails} from 'sentry/views/detectors/components/details/common/extraDetails'; |
| 13 | +import {DetectorDetailsHeader} from 'sentry/views/detectors/components/details/common/header'; |
| 14 | +import {DetectorDetailsOngoingIssues} from 'sentry/views/detectors/components/details/common/ongoingIssues'; |
| 15 | + |
| 16 | +type ErrorDetectorDetailsProps = { |
| 17 | + detector: Detector; |
| 18 | + project: Project; |
| 19 | +}; |
| 20 | + |
| 21 | +const formatResolveAge = (resolveAge: number) => { |
| 22 | + if (!resolveAge) { |
| 23 | + return t('Auto-resolution disabled'); |
| 24 | + } |
| 25 | + |
| 26 | + if (resolveAge < 24 || resolveAge % 24 !== 0) { |
| 27 | + return tn( |
| 28 | + 'Auto-resolve after %s hour of inactivity', |
| 29 | + 'Auto-resolve after %s hours of inactivity', |
| 30 | + resolveAge |
| 31 | + ); |
| 32 | + } |
| 33 | + return tn( |
| 34 | + 'Auto-resolve after %s day of inactivity', |
| 35 | + 'Auto-resolve after %s days of inactivity', |
| 36 | + resolveAge / 24 |
| 37 | + ); |
| 38 | +}; |
| 39 | + |
| 40 | +function ResolveSection({project}: {project: Project}) { |
| 41 | + const organization = useOrganization(); |
| 42 | + const {data: detailedProject, isPending} = useDetailedProject({ |
| 43 | + orgSlug: organization.slug, |
| 44 | + projectSlug: project.slug, |
| 45 | + }); |
| 46 | + |
| 47 | + if (isPending || !detailedProject) { |
| 48 | + return ( |
| 49 | + <Section title={t('Resolve')}> |
| 50 | + <Placeholder height="1em" /> |
| 51 | + </Section> |
| 52 | + ); |
| 53 | + } |
| 54 | + |
| 55 | + const resolveAgeHours = detailedProject.resolveAge; |
| 56 | + |
| 57 | + return ( |
| 58 | + <Section title={t('Resolve')}> |
| 59 | + <p>{formatResolveAge(resolveAgeHours)}</p> |
| 60 | + </Section> |
| 61 | + ); |
| 62 | +} |
| 63 | + |
| 64 | +export function ErrorDetectorDetails({detector, project}: ErrorDetectorDetailsProps) { |
| 65 | + return ( |
| 66 | + <DetailLayout> |
| 67 | + <DetectorDetailsHeader detector={detector} project={project} /> |
| 68 | + <DetailLayout.Body> |
| 69 | + <DetailLayout.Main> |
| 70 | + <DetectorDetailsOngoingIssues /> |
| 71 | + <DetectorDetailsAutomations detector={detector} /> |
| 72 | + </DetailLayout.Main> |
| 73 | + <DetailLayout.Sidebar> |
| 74 | + <Section title={t('Detect')}> |
| 75 | + <p> |
| 76 | + {tct( |
| 77 | + 'All events have a fingerprint. Events with the same fingerprint are grouped together into an issue. To learn more about issue grouping, [link:read the docs].', |
| 78 | + { |
| 79 | + link: ( |
| 80 | + <ExternalLink href="https://docs.sentry.io/concepts/data-management/event-grouping/" /> |
| 81 | + ), |
| 82 | + } |
| 83 | + )} |
| 84 | + </p> |
| 85 | + </Section> |
| 86 | + <DetectorDetailsAssignee owner={detector.owner} /> |
| 87 | + <ResolveSection project={project} /> |
| 88 | + <DetectorExtraDetails> |
| 89 | + <DetectorExtraDetails.DateCreated detector={detector} /> |
| 90 | + <DetectorExtraDetails.CreatedBy detector={detector} /> |
| 91 | + <DetectorExtraDetails.LastModified detector={detector} /> |
| 92 | + <DetectorExtraDetails.Environment detector={detector} /> |
| 93 | + </DetectorExtraDetails> |
| 94 | + </DetailLayout.Sidebar> |
| 95 | + </DetailLayout.Body> |
| 96 | + </DetailLayout> |
| 97 | + ); |
| 98 | +} |
0 commit comments