eventMetadata.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import styled from '@emotion/styled';
  2. import {SectionHeading} from 'sentry/components/charts/styles';
  3. import DateTime from 'sentry/components/dateTime';
  4. import FileSize from 'sentry/components/fileSize';
  5. import ProjectBadge from 'sentry/components/idBadge/projectBadge';
  6. import ExternalLink from 'sentry/components/links/externalLink';
  7. import {t} from 'sentry/locale';
  8. import space from 'sentry/styles/space';
  9. import {OrganizationSummary} from 'sentry/types';
  10. import {Event} from 'sentry/types/event';
  11. import getDynamicText from 'sentry/utils/getDynamicText';
  12. import Projects from 'sentry/utils/projects';
  13. type Props = {
  14. event: Event;
  15. organization: OrganizationSummary;
  16. projectId: string;
  17. };
  18. /**
  19. * Render metadata about the event and provide a link to the JSON blob.
  20. * Used in the sidebar of performance event details and discover2 event details.
  21. */
  22. function EventMetadata({event, organization, projectId}: Props) {
  23. const eventJsonUrl = `/api/0/projects/${organization.slug}/${projectId}/events/${event.eventID}/json/`;
  24. return (
  25. <MetaDataID>
  26. <SectionHeading>{t('Event ID')}</SectionHeading>
  27. <MetadataContainer data-test-id="event-id">{event.eventID}</MetadataContainer>
  28. <MetadataContainer>
  29. <DateTime
  30. date={getDynamicText({
  31. value: event.dateCreated || (event.endTimestamp || 0) * 1000,
  32. fixed: 'Dummy timestamp',
  33. })}
  34. />
  35. </MetadataContainer>
  36. <Projects orgId={organization.slug} slugs={[projectId]}>
  37. {({projects}) => {
  38. const project = projects.find(p => p.slug === projectId);
  39. return (
  40. <StyledProjectBadge
  41. project={project ? project : {slug: projectId}}
  42. avatarSize={16}
  43. />
  44. );
  45. }}
  46. </Projects>
  47. <MetadataJSON href={eventJsonUrl} className="json-link">
  48. {t('Preview JSON')} (<FileSize bytes={event.size} />)
  49. </MetadataJSON>
  50. </MetaDataID>
  51. );
  52. }
  53. const MetaDataID = styled('div')`
  54. margin-bottom: ${space(4)};
  55. `;
  56. const MetadataContainer = styled('div')`
  57. display: flex;
  58. justify-content: space-between;
  59. font-size: ${p => p.theme.fontSizeMedium};
  60. `;
  61. const MetadataJSON = styled(ExternalLink)`
  62. font-size: ${p => p.theme.fontSizeMedium};
  63. `;
  64. const StyledProjectBadge = styled(ProjectBadge)`
  65. margin-bottom: ${space(2)};
  66. `;
  67. export default EventMetadata;