@@ -19,24 +19,21 @@ import DataSection from '../dataSection';
1919import ImageVisualization from './imageVisualization' ;
2020import Modal , { modalCss } from './modal' ;
2121
22+ type Screenshot = Omit < EventAttachment , 'event_id' > ;
23+
2224type Props = {
2325 event : Event ;
2426 organization : Organization ;
2527 projectSlug : Project [ 'slug' ] ;
26- attachments : EventAttachment [ ] ;
27- onDelete : ( attachmentId : EventAttachment [ 'id' ] ) => void ;
28+ screenshot : Screenshot ;
29+ onDelete : ( attachmentId : Screenshot [ 'id' ] ) => void ;
2830} ;
2931
30- function Screenshot ( { event, attachments , organization , projectSlug, onDelete} : Props ) {
32+ function Screenshot ( { event, organization , screenshot , projectSlug, onDelete} : Props ) {
3133 const orgSlug = organization . slug ;
3234
33- function hasScreenshot ( attachment : EventAttachment ) {
34- const { mimetype} = attachment ;
35- return mimetype === 'image/jpeg' || mimetype === 'image/png' ;
36- }
37-
3835 function handleOpenVisualizationModal (
39- eventAttachment : EventAttachment ,
36+ eventAttachment : Screenshot ,
4037 downloadUrl : string
4138 ) {
4239 openModal (
@@ -55,7 +52,7 @@ function Screenshot({event, attachments, organization, projectSlug, onDelete}: P
5552 ) ;
5653 }
5754
58- function renderContent ( screenshotAttachment : EventAttachment ) {
55+ function renderContent ( screenshotAttachment : Screenshot ) {
5956 const downloadUrl = `/api/0/projects/${ organization . slug } /${ projectSlug } /events/${ event . id } /attachments/${ screenshotAttachment . id } /` ;
6057
6158 return (
@@ -118,22 +115,20 @@ function Screenshot({event, attachments, organization, projectSlug, onDelete}: P
118115 }
119116
120117 return (
121- < Role role = { organization . attachmentsRole } >
118+ < Role organization = { organization } role = { organization . attachmentsRole } >
122119 { ( { hasRole} ) => {
123- const screenshotAttachment = attachments . find ( hasScreenshot ) ;
124-
125- if ( ! hasRole || ! screenshotAttachment ) {
120+ if ( ! hasRole ) {
126121 return null ;
127122 }
128123
129124 return (
130125 < DataSection
131- title = { t ( 'Screenshots ' ) }
126+ title = { t ( 'Screenshot ' ) }
132127 description = { t (
133- 'Screenshots help identify what the user saw when the event happened'
128+ 'Screenshot help identify what the user saw when the event happened'
134129 ) }
135130 >
136- < StyledPanel > { renderContent ( screenshotAttachment ) } </ StyledPanel >
131+ < StyledPanel > { renderContent ( screenshot ) } </ StyledPanel >
137132 </ DataSection >
138133 ) ;
139134 } }
0 commit comments