sections.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import beautify from 'js-beautify';
  2. import {CodeSnippet} from 'sentry/components/codeSnippet';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import {t} from 'sentry/locale';
  5. import type {HydratedA11yFrame} from 'sentry/utils/replays/hydrateA11yFrame';
  6. import type {KeyValueTuple} from 'sentry/views/replays/detail/accessibility/details/components';
  7. import {
  8. keyValueTableOrNotFound,
  9. SectionItem,
  10. } from 'sentry/views/replays/detail/accessibility/details/components';
  11. export type SectionProps = {
  12. item: HydratedA11yFrame;
  13. };
  14. export function ElementSection({item}: SectionProps) {
  15. return (
  16. <SectionItem title={t('DOM Element')}>
  17. <CodeSnippet language="html" hideCopyButton>
  18. {beautify.html(item.element.element, {indent_size: 2})}
  19. </CodeSnippet>
  20. </SectionItem>
  21. );
  22. }
  23. export function GeneralSection({item}: SectionProps) {
  24. const data: KeyValueTuple[] = [
  25. {
  26. key: t('Impact'),
  27. value: item.impact,
  28. type: item.impact === 'critical' ? 'warning' : undefined,
  29. },
  30. {key: t('Type'), value: item.id},
  31. {
  32. key: t('Help'),
  33. value: <ExternalLink href={item.help_url}>{item.description}</ExternalLink>,
  34. },
  35. {key: t('Path'), value: item.element.target.join(' ')},
  36. ];
  37. return (
  38. <SectionItem title={t('General')}>
  39. {keyValueTableOrNotFound(data, t('Missing details'))}
  40. </SectionItem>
  41. );
  42. }