| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { action } from '@storybook/addon-actions'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-02 20:05:32 -05:00
										 |  |  | import type { AttachmentDraftType } from '../../types/Attachment'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { Props } from './AttachmentList'; | 
					
						
							|  |  |  | import { AttachmentList } from './AttachmentList'; | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   AUDIO_MP3, | 
					
						
							|  |  |  |   IMAGE_GIF, | 
					
						
							|  |  |  |   IMAGE_JPEG, | 
					
						
							|  |  |  |   VIDEO_MP4, | 
					
						
							| 
									
										
										
										
											2021-08-09 16:06:21 -04:00
										 |  |  |   stringToMIMEType, | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | } from '../../types/MIME'; | 
					
						
							| 
									
										
										
										
											2021-09-17 20:30:08 -04:00
										 |  |  | import { setupI18n } from '../../util/setupI18n'; | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | import enMessages from '../../../_locales/en/messages.json'; | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  | import { fakeDraftAttachment } from '../../test-both/helpers/fakeAttachment'; | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | const i18n = setupI18n('en', enMessages); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |   title: 'Components/Conversation/AttachmentList', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-02 20:05:32 -05:00
										 |  |  | const createProps = ( | 
					
						
							|  |  |  |   overrideProps: Partial<Props<AttachmentDraftType>> = {} | 
					
						
							|  |  |  | ): Props<AttachmentDraftType> => ({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |   attachments: overrideProps.attachments || [], | 
					
						
							|  |  |  |   i18n, | 
					
						
							|  |  |  |   onAddAttachment: action('onAddAttachment'), | 
					
						
							|  |  |  |   onClickAttachment: action('onClickAttachment'), | 
					
						
							|  |  |  |   onClose: action('onClose'), | 
					
						
							|  |  |  |   onCloseAttachment: action('onCloseAttachment'), | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function OneFile(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     attachments: [ | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: IMAGE_JPEG, | 
					
						
							|  |  |  |         fileName: 'tina-rolf-269345-unsplash.jpg', | 
					
						
							|  |  |  |         url: '/fixtures/tina-rolf-269345-unsplash.jpg', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2021-12-14 18:53:15 -06:00
										 |  |  |   return <AttachmentList {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function MultipleVisualAttachments(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     attachments: [ | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: IMAGE_JPEG, | 
					
						
							|  |  |  |         fileName: 'tina-rolf-269345-unsplash.jpg', | 
					
						
							|  |  |  |         url: '/fixtures/tina-rolf-269345-unsplash.jpg', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: VIDEO_MP4, | 
					
						
							|  |  |  |         fileName: 'pixabay-Soap-Bubble-7141.mp4', | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |         url: '/fixtures/kitten-4-112-112.jpg', | 
					
						
							|  |  |  |         screenshotPath: '/fixtures/kitten-4-112-112.jpg', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: IMAGE_GIF, | 
					
						
							|  |  |  |         fileName: 'giphy-GVNv0UpeYm17e', | 
					
						
							|  |  |  |         url: '/fixtures/giphy-GVNvOUpeYmI7e.gif', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <AttachmentList {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function MultipleWithNonVisualTypes(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     attachments: [ | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: IMAGE_JPEG, | 
					
						
							|  |  |  |         fileName: 'tina-rolf-269345-unsplash.jpg', | 
					
						
							|  |  |  |         url: '/fixtures/tina-rolf-269345-unsplash.jpg', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2021-08-09 16:06:21 -04:00
										 |  |  |         contentType: stringToMIMEType('text/plain'), | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         fileName: 'lorem-ipsum.txt', | 
					
						
							|  |  |  |         url: '/fixtures/lorem-ipsum.txt', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: AUDIO_MP3, | 
					
						
							|  |  |  |         fileName: 'incompetech-com-Agnus-Dei-X.mp3', | 
					
						
							|  |  |  |         url: '/fixtures/incompetech-com-Agnus-Dei-X.mp3', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: VIDEO_MP4, | 
					
						
							|  |  |  |         fileName: 'pixabay-Soap-Bubble-7141.mp4', | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |         url: '/fixtures/kitten-4-112-112.jpg', | 
					
						
							|  |  |  |         screenshotPath: '/fixtures/kitten-4-112-112.jpg', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2021-11-15 13:54:33 -08:00
										 |  |  |       fakeDraftAttachment({ | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |         contentType: IMAGE_GIF, | 
					
						
							|  |  |  |         fileName: 'giphy-GVNv0UpeYm17e', | 
					
						
							|  |  |  |         url: '/fixtures/giphy-GVNvOUpeYmI7e.gif', | 
					
						
							| 
									
										
										
										
											2021-10-05 15:10:08 -07:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <AttachmentList {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | MultipleWithNonVisualTypes.story = { | 
					
						
							|  |  |  |   name: 'Multiple with Non-Visual Types', | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function EmptyList(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-20 14:50:43 -07:00
										 |  |  |   const props = createProps(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <AttachmentList {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |