diff --git a/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx b/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx index 94b231c76a6a..d432f6716025 100644 --- a/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx +++ b/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx @@ -15,7 +15,7 @@ export const imageMimeTypes = [ 'image/avif', ]; -const logFileMimeTypes = [ +export const logFileMimeTypes = [ 'text/css', 'text/csv', 'text/html', @@ -23,7 +23,7 @@ const logFileMimeTypes = [ 'text/plain', ]; -const jsonMimeTypes = [ +export const jsonMimeTypes = [ 'application/json', 'application/ld+json', 'text/json', @@ -50,7 +50,7 @@ export const getImageAttachmentRenderer = ( return undefined; }; -const nonPreviewableExtensions = ['.prosperodmp', '.prosperomemdmp']; +export const nonPreviewableExtensions = ['.prosperodmp', '.prosperomemdmp']; export const getInlineAttachmentRenderer = ( attachment: IssueAttachment diff --git a/static/app/views/issueDetails/groupEventAttachments/inlineEventAttachment.tsx b/static/app/views/issueDetails/groupEventAttachments/inlineEventAttachment.tsx index 6f32486e7ca7..d5ce9b28db4e 100644 --- a/static/app/views/issueDetails/groupEventAttachments/inlineEventAttachment.tsx +++ b/static/app/views/issueDetails/groupEventAttachments/inlineEventAttachment.tsx @@ -1,6 +1,18 @@ import styled from '@emotion/styled'; -import {getInlineAttachmentRenderer} from 'sentry/components/events/attachmentViewers/previewAttachmentTypes'; +import {ImageViewer} from 'sentry/components/events/attachmentViewers/imageViewer'; +import {JsonViewer} from 'sentry/components/events/attachmentViewers/jsonViewer'; +import {LogFileViewer} from 'sentry/components/events/attachmentViewers/logFileViewer'; +import { + hasInlineAttachmentRenderer, + imageMimeTypes, + jsonMimeTypes, + logFileMimeTypes, + nonPreviewableExtensions, + webmMimeTypes, +} from 'sentry/components/events/attachmentViewers/previewAttachmentTypes'; +import {RRWebJsonViewer} from 'sentry/components/events/attachmentViewers/rrwebJsonViewer'; +import {VideoViewer} from 'sentry/components/events/attachmentViewers/videoViewer'; import {PanelItem} from 'sentry/components/panels/panelItem'; import type {Event} from 'sentry/types/event'; import type {IssueAttachment} from 'sentry/types/group'; @@ -12,21 +24,57 @@ interface InlineAttachmentsProps { projectSlug: string; } +interface AttachmentViewerProps { + attachment: IssueAttachment; + eventId: string; + orgSlug: string; + projectSlug: string; +} + +function AttachmentViewer({ + attachment, + orgSlug, + projectSlug, + eventId, +}: AttachmentViewerProps) { + const commonProps = {attachment, orgSlug, projectSlug, eventId}; + + if (nonPreviewableExtensions.some(ext => attachment.name.endsWith(ext))) { + return null; + } + + if (imageMimeTypes.includes(attachment.mimetype)) { + return ; + } + if (webmMimeTypes.includes(attachment.mimetype)) { + return ; + } + if (logFileMimeTypes.includes(attachment.mimetype)) { + return ; + } + if (jsonMimeTypes.includes(attachment.mimetype)) { + if (attachment.name === 'rrweb.json' || attachment.name.startsWith('rrweb-')) { + return ; + } + return ; + } + return null; +} + export function InlineEventAttachment({ attachment, projectSlug, eventId, }: InlineAttachmentsProps) { const organization = useOrganization(); - const AttachmentComponent = getInlineAttachmentRenderer(attachment); - if (!AttachmentComponent) { + if (!hasInlineAttachmentRenderer(attachment)) { return null; } return ( -