inlineEventAttachment.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import styled from '@emotion/styled';
  2. import {getInlineAttachmentRenderer} from 'sentry/components/events/attachmentViewers/previewAttachmentTypes';
  3. import type {Event} from 'sentry/types/event';
  4. import type {IssueAttachment} from 'sentry/types/group';
  5. import useOrganization from 'sentry/utils/useOrganization';
  6. interface InlineAttachmentsProps {
  7. attachment: IssueAttachment;
  8. eventId: Event['id'];
  9. projectSlug: string;
  10. }
  11. export function InlineEventAttachment({
  12. attachment,
  13. projectSlug,
  14. eventId,
  15. }: InlineAttachmentsProps) {
  16. const organization = useOrganization();
  17. const AttachmentComponent = getInlineAttachmentRenderer(attachment);
  18. if (!AttachmentComponent) {
  19. return null;
  20. }
  21. return (
  22. <AttachmentPreviewWrapper>
  23. <AttachmentComponent
  24. orgSlug={organization.slug}
  25. projectSlug={projectSlug}
  26. eventId={eventId}
  27. attachment={attachment}
  28. />
  29. </AttachmentPreviewWrapper>
  30. );
  31. }
  32. const AttachmentPreviewWrapper = styled('div')`
  33. grid-column: auto / span 3;
  34. border: none;
  35. padding: 0;
  36. `;