occurrenceSummary.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Flex} from 'sentry/components/container/flex';
  4. import {DowntimeDuration} from 'sentry/components/events/interfaces/uptime/uptimeDataSection';
  5. import {t} from 'sentry/locale';
  6. import {space} from 'sentry/styles/space';
  7. import type {Group} from 'sentry/types/group';
  8. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  9. interface OccurrenceSummaryProps {
  10. group: Group;
  11. className?: string;
  12. }
  13. /**
  14. * This component summarizes the occurance of an issue when the event unit we display below is NOT
  15. * the occurence. For example, we display 'check-ins' in uptime issues, but the occrurence is a
  16. * status change from success to failure.
  17. */
  18. export function OccurrenceSummary({group, className}: OccurrenceSummaryProps) {
  19. const issueTypeConfig = getConfigForIssueType(group, group.project);
  20. if (!issueTypeConfig.header.occurrenceSummary.enabled) {
  21. return null;
  22. }
  23. const items: React.ReactNode[] = [];
  24. if (issueTypeConfig.header.occurrenceSummary.duration) {
  25. items.push(
  26. <Flex column>
  27. <ItemTitle>{t('Duration')}</ItemTitle>
  28. <ItemValue>
  29. <DowntimeDuration group={group} />
  30. </ItemValue>
  31. </Flex>
  32. );
  33. }
  34. // TODO(Leander): Add last successful check-in when the data is available
  35. // TODO(Leander): Add Incident ID when the data is available
  36. return items.length > 0 ? (
  37. <Flex align="center" gap={space(4)} className={className}>
  38. {items.map((item, i) => (
  39. <Fragment key={i}>{item}</Fragment>
  40. ))}
  41. </Flex>
  42. ) : null;
  43. }
  44. const ItemTitle = styled('div')`
  45. font-size: ${p => p.theme.fontSizeSmall};
  46. color: ${p => p.theme.gray300};
  47. font-weight: ${p => p.theme.fontWeightBold};
  48. `;
  49. const ItemValue = styled('div')`
  50. font-size: ${p => p.theme.fontSizeLarge};
  51. font-weight: ${p => p.theme.fontWeightNormal};
  52. `;