/** * @flow * @file Content Explorer Preview dialog * @author Box */ import React from 'react'; import Modal from 'react-modal'; import { injectIntl } from 'react-intl'; import cloneDeep from 'lodash/cloneDeep'; import messages from '../common/messages'; import ContentPreview from '../content-preview'; import { TYPE_FILE, CLASS_MODAL_CONTENT_FULL_BLEED, CLASS_MODAL_OVERLAY, CLASS_MODAL } from '../../constants'; type Props = { apiHost: string, appElement: HTMLElement, appHost: string, cache: APICache, canDownload: boolean, contentPreviewProps: ContentPreviewProps, currentCollection: Collection, isOpen: boolean, isTouch: boolean, item: BoxItem, onCancel: Function, onDownload: Function, onPreview: Function, parentElement: HTMLElement, requestInterceptor?: Function, responseInterceptor?: Function, sharedLink?: string, sharedLinkPassword?: string, staticHost: string, token: Token, } & InjectIntlProvidedProps; const PreviewDialog = ({ item, isOpen, parentElement, appElement, token, cache, currentCollection, canDownload, onCancel, onPreview, onDownload, apiHost, appHost, staticHost, sharedLink, sharedLinkPassword, contentPreviewProps, requestInterceptor, responseInterceptor, intl, }: Props) => { const { items }: Collection = currentCollection; const onLoad = (data: any): void => { onPreview(cloneDeep(data)); }; if (!item || !items) { return null; } const files: BoxItem[] = items.filter(({ type }) => type === TYPE_FILE); return ( parentElement} portalClassName={`${CLASS_MODAL} be-modal-preview`} className={CLASS_MODAL_CONTENT_FULL_BLEED} overlayClassName={CLASS_MODAL_OVERLAY} contentLabel={intl.formatMessage(messages.preview)} onRequestClose={onCancel} appElement={appElement} > ); }; export default injectIntl(PreviewDialog);