import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { gettext } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import UploadListItem from './upload-list-item'; import ForbidUploadListItem from './forbid-upload-list-item'; const propTypes = { uploadBitrate: PropTypes.number.isRequired, totalProgress: PropTypes.number.isRequired, retryFileList: PropTypes.array.isRequired, uploadFileList: PropTypes.array.isRequired, forbidUploadFileList: PropTypes.array.isRequired, onCloseUploadDialog: PropTypes.func.isRequired, onCancelAllUploading: PropTypes.func.isRequired, onUploadCancel: PropTypes.func.isRequired, onUploadRetry: PropTypes.func.isRequired, onUploadRetryAll: PropTypes.func.isRequired, allFilesUploaded: PropTypes.bool.isRequired, }; class UploadProgressDialog extends React.Component { constructor(props) { super(props); this.state = { isMinimized: false }; } onCancelAllUploading = () => { this.props.onCancelAllUploading(); } onMinimizeUpload = (e) => { e.nativeEvent.stopImmediatePropagation(); this.setState({isMinimized: !this.state.isMinimized}); } onCloseUpload = (e) => { e.nativeEvent.stopImmediatePropagation(); this.props.onCloseUploadDialog(); } render() { let uploadBitrate = Utils.formatBitRate(this.props.uploadBitrate); let uploadedMessage = gettext('File Upload'); let uploadingMessage = gettext('File Uploading...') + ' ' + this.props.totalProgress + '% (' + uploadBitrate + ')'; let uploadingOptions = (); let uploadedOptions = ( ); let { totalProgress, allFilesUploaded, retryFileList } = this.props; return (
{totalProgress === 100 ? uploadedMessage : uploadingMessage}
{totalProgress === 100 || allFilesUploaded ? uploadedOptions : uploadingOptions}
{retryFileList.length > 0 ? {gettext('Retry All')} : {gettext('Retry All')} } {!allFilesUploaded ? {gettext('Cancel All')} : {gettext('Cancel All')} }
{ this.props.forbidUploadFileList.map((file, index) => { return (); }) } { this.props.uploadFileList.map((resumableFile, index) => { return ( ); }) }
{gettext('name')} {gettext('size')} {gettext('progress')} {gettext('state')}
); } } UploadProgressDialog.propTypes = propTypes; export default UploadProgressDialog;