bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx

692 lines
22 KiB
React
Raw Normal View History

2017-04-29 02:42:32 +08:00
import React, { Component } from 'react';
2017-09-08 02:18:14 +08:00
import PropTypes from 'prop-types';
2017-09-29 22:03:08 +08:00
import { defineMessages, injectIntl, intlShape } from 'react-intl';
import Dropzone from 'react-dropzone';
2017-05-04 00:36:16 +08:00
import update from 'immutability-helper';
import cx from 'classnames';
2017-11-22 22:47:27 +08:00
import _ from 'lodash';
import logger from '/imports/startup/client/logger';
import browser from 'browser-detect';
import { notify } from '/imports/ui/services/notification';
2017-05-04 04:51:17 +08:00
import ModalFullscreen from '/imports/ui/components/modal/fullscreen/component';
import { withModalMounter } from '/imports/ui/components/modal/service';
2017-04-29 02:42:32 +08:00
import Icon from '/imports/ui/components/icon/component';
import Button from '/imports/ui/components/button/component';
2017-05-04 00:36:16 +08:00
import Checkbox from '/imports/ui/components/checkbox/component';
2018-01-08 14:17:18 +08:00
import { styles } from './styles.scss';
2017-04-29 02:42:32 +08:00
2017-09-08 02:18:14 +08:00
const propTypes = {
intl: intlShape.isRequired,
2017-09-08 02:18:14 +08:00
defaultFileName: PropTypes.string.isRequired,
fileSizeMin: PropTypes.number.isRequired,
fileSizeMax: PropTypes.number.isRequired,
handleSave: PropTypes.func.isRequired,
dispatchTogglePresentationDownloadable: PropTypes.func.isRequired,
2019-03-08 03:53:01 +08:00
fileValidMimeTypes: PropTypes.arrayOf(PropTypes.object).isRequired,
2017-09-08 02:18:14 +08:00
presentations: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string.isRequired,
filename: PropTypes.string.isRequired,
isCurrent: PropTypes.bool.isRequired,
conversion: PropTypes.object,
upload: PropTypes.object,
})).isRequired,
};
const defaultProps = {
};
2017-04-29 02:42:32 +08:00
const intlMessages = defineMessages({
2017-12-05 00:10:37 +08:00
current: {
id: 'app.presentationUploder.currentBadge',
},
2017-04-29 02:42:32 +08:00
title: {
id: 'app.presentationUploder.title',
2017-11-02 00:13:18 +08:00
description: 'title of the modal',
2017-04-29 02:42:32 +08:00
},
message: {
id: 'app.presentationUploder.message',
2017-11-02 00:13:18 +08:00
description: 'message warning the types of files accepted',
2017-04-29 02:42:32 +08:00
},
confirmLabel: {
id: 'app.presentationUploder.confirmLabel',
2017-11-02 00:13:18 +08:00
description: 'used in the button that start the upload of the new presentation',
2017-04-29 02:42:32 +08:00
},
confirmDesc: {
id: 'app.presentationUploder.confirmDesc',
2017-11-02 00:13:18 +08:00
description: 'description of the confirm',
2017-04-29 02:42:32 +08:00
},
dismissLabel: {
id: 'app.presentationUploder.dismissLabel',
2017-11-02 00:13:18 +08:00
description: 'used in the button that close modal',
2017-04-29 02:42:32 +08:00
},
dismissDesc: {
id: 'app.presentationUploder.dismissDesc',
2017-11-02 00:13:18 +08:00
description: 'description of the dismiss',
2017-04-29 02:42:32 +08:00
},
dropzoneLabel: {
id: 'app.presentationUploder.dropzoneLabel',
2017-11-02 00:13:18 +08:00
description: 'message warning where drop files for upload',
2017-04-29 02:42:32 +08:00
},
dropzoneImagesLabel: {
id: 'app.presentationUploder.dropzoneImagesLabel',
description: 'message warning where drop images for upload',
},
2017-04-29 02:42:32 +08:00
browseFilesLabel: {
id: 'app.presentationUploder.browseFilesLabel',
2017-11-02 00:13:18 +08:00
description: 'message use on the file browser',
2017-04-29 02:42:32 +08:00
},
browseImagesLabel: {
id: 'app.presentationUploder.browseImagesLabel',
description: 'message use on the image browser',
},
2017-05-06 04:17:38 +08:00
fileToUpload: {
id: 'app.presentationUploder.fileToUpload',
2017-11-02 00:13:18 +08:00
description: 'message used in the file selected for upload',
2017-05-06 04:17:38 +08:00
},
genericError: {
id: 'app.presentationUploder.genericError',
description: 'generic error while uploading/converting',
},
rejectedError: {
id: 'app.presentationUploder.rejectedError',
description: 'some files rejected, please check the file mime types',
},
2017-09-08 02:18:14 +08:00
uploadProcess: {
id: 'app.presentationUploder.upload.progress',
2017-11-02 00:13:18 +08:00
description: 'message that indicates the percentage of the upload',
2017-09-08 02:18:14 +08:00
},
413: {
id: 'app.presentationUploder.upload.413',
2017-11-02 00:13:18 +08:00
description: 'error that file exceed the size limit',
2017-05-06 04:17:38 +08:00
},
conversionProcessingSlides: {
id: 'app.presentationUploder.conversion.conversionProcessingSlides',
2017-11-02 00:13:18 +08:00
description: 'indicates how many slides were converted',
2017-05-06 04:17:38 +08:00
},
genericConversionStatus: {
id: 'app.presentationUploder.conversion.genericConversionStatus',
2017-11-02 00:13:18 +08:00
description: 'indicates that file is being converted',
2017-05-06 04:17:38 +08:00
},
TIMEOUT: {
id: 'app.presentationUploder.conversion.timeout',
},
2017-05-06 04:17:38 +08:00
GENERATING_THUMBNAIL: {
id: 'app.presentationUploder.conversion.generatingThumbnail',
description: 'indicatess that it is generating thumbnails',
2017-05-06 04:17:38 +08:00
},
2017-09-27 03:45:33 +08:00
GENERATING_SVGIMAGES: {
id: 'app.presentationUploder.conversion.generatingSvg',
2017-11-02 00:13:18 +08:00
description: 'warns that it is generating svg images',
2017-09-27 03:45:33 +08:00
},
2017-05-06 04:17:38 +08:00
GENERATED_SLIDE: {
id: 'app.presentationUploder.conversion.generatedSlides',
2017-11-02 00:13:18 +08:00
description: 'warns that were slides generated',
2017-05-06 04:17:38 +08:00
},
2017-11-28 20:26:00 +08:00
PAGE_COUNT_EXCEEDED: {
id: 'app.presentationUploder.conversion.pageCountExceeded',
description: 'warns the user that the conversion failed because of the page count',
},
2019-02-21 06:44:44 +08:00
isDownloadable: {
id: 'app.presentationUploder.isDownloadableLabel',
description: 'presentation is available for downloading by all viewers',
2019-02-21 06:44:44 +08:00
},
isNotDownloadable: {
id: 'app.presentationUploder.isNotDownloadableLabel',
description: 'presentation is not available for downloading the viewers',
2019-02-21 06:44:44 +08:00
},
removePresentation: {
id: 'app.presentationUploder.removePresentationLabel',
description: 'select to delete this presentation',
},
setAsCurrentPresentation: {
id: 'app.presentationUploder.setAsCurrentPresentation',
description: 'set this presentation to be the current one',
},
2019-05-15 00:51:13 +08:00
status: {
id: 'app.presentationUploder.tableHeading.status',
description: 'aria label status table heading',
},
options: {
id: 'app.presentationUploder.tableHeading.options',
description: 'aria label for options table heading',
},
filename: {
id: 'app.presentationUploder.tableHeading.filename',
description: 'aria label for file name table heading',
},
2017-04-29 02:42:32 +08:00
});
const BROWSER_RESULTS = browser();
const isMobileBrowser = (BROWSER_RESULTS ? BROWSER_RESULTS.mobile : false)
|| (BROWSER_RESULTS && BROWSER_RESULTS.os
? BROWSER_RESULTS.os.includes('Android') // mobile flag doesn't always work
: false);
2017-05-06 04:17:38 +08:00
class PresentationUploader extends Component {
2017-04-29 02:42:32 +08:00
constructor(props) {
super(props);
const currentPres = props.presentations.find(p => p.isCurrent);
2017-04-29 02:42:32 +08:00
this.state = {
presentations: props.presentations,
oldCurrentId: currentPres ? currentPres.id : -1,
2017-05-06 04:17:38 +08:00
preventClosing: false,
disableActions: false,
2017-04-29 02:42:32 +08:00
};
this.handleConfirm = this.handleConfirm.bind(this);
this.handleDismiss = this.handleDismiss.bind(this);
this.handleFiledrop = this.handleFiledrop.bind(this);
this.handleCurrentChange = this.handleCurrentChange.bind(this);
this.handleRemove = this.handleRemove.bind(this);
this.toggleDownloadable = this.toggleDownloadable.bind(this);
2017-09-27 03:45:33 +08:00
this.updateFileKey = this.updateFileKey.bind(this);
this.deepMergeUpdateFileKey = this.deepMergeUpdateFileKey.bind(this);
this.releaseActionsOnPresentationError = this.releaseActionsOnPresentationError.bind(this);
}
componentDidUpdate() {
this.releaseActionsOnPresentationError();
}
releaseActionsOnPresentationError() {
const {
presentations,
disableActions,
} = this.state;
presentations.forEach((presentation) => {
if (!presentation.conversion.done && presentation.conversion.error) {
if (disableActions) {
this.setState({
disableActions: false,
});
}
}
});
2017-04-29 02:42:32 +08:00
}
2017-09-27 03:45:33 +08:00
updateFileKey(id, key, value, operation = '$set') {
this.setState(({ presentations }) => {
2017-11-22 22:47:27 +08:00
const fileIndex = presentations.findIndex(f => f.id === id);
2017-09-27 03:45:33 +08:00
return fileIndex === -1 ? false : {
presentations: update(presentations, {
2017-11-22 22:47:27 +08:00
[fileIndex]: {
2018-12-06 01:42:31 +08:00
$apply: file => update(file, {
[key]: {
[operation]: value,
},
}),
2017-09-27 03:45:33 +08:00
},
}),
};
});
}
deepMergeUpdateFileKey(id, key, value) {
const applyValue = toUpdate => update(toUpdate, { $merge: value });
this.updateFileKey(id, key, applyValue, '$apply');
}
isDefault(presentation) {
const { defaultFileName } = this.props;
return presentation.filename === defaultFileName
&& !presentation.id.includes(defaultFileName);
}
2017-04-29 02:42:32 +08:00
handleConfirm() {
const { mountModal, intl, handleSave } = this.props;
const { presentations, oldCurrentId } = this.state;
const presentationsToSave = presentations
.filter(p => !p.upload.error && !p.conversion.error);
2017-05-04 00:36:16 +08:00
2017-05-06 04:17:38 +08:00
this.setState({
disableActions: true,
preventClosing: true,
presentations: presentationsToSave,
2017-05-06 04:17:38 +08:00
});
2017-05-04 00:36:16 +08:00
return handleSave(presentationsToSave)
.then(() => {
const hasError = presentations.some(p => p.upload.error || p.conversion.error);
if (!hasError) {
this.setState({
disableActions: false,
preventClosing: false,
});
mountModal(null);
return;
}
// if there's error we don't want to close the modal
this.setState({
disableActions: false,
preventClosing: true,
}, () => {
// if the selected current has error we revert back to the old one
const newCurrent = presentations.find(p => p.isCurrent);
if (newCurrent.upload.error || newCurrent.conversion.error) {
this.handleCurrentChange(oldCurrentId);
}
});
})
2017-09-27 03:45:33 +08:00
.catch((error) => {
notify(intl.formatMessage(intlMessages.genericError), 'error');
logger.error({ logCode: 'presentationuploader_component_save_error' }, error);
2017-09-27 03:45:33 +08:00
this.setState({
disableActions: false,
preventClosing: true,
});
});
2017-04-29 02:42:32 +08:00
}
handleDismiss() {
const { mountModal } = this.props;
return new Promise((resolve) => {
mountModal(null);
2017-05-06 04:17:38 +08:00
this.setState({
preventClosing: false,
disableActions: false,
}, resolve);
});
2017-04-29 02:42:32 +08:00
}
handleFiledrop(files, files2) {
const { fileValidMimeTypes, intl } = this.props;
2019-03-08 03:53:01 +08:00
const mimeTypes = fileValidMimeTypes.map(fileValid => fileValid.mime);
const [accepted, rejected] = _.partition(files
2019-03-08 03:53:01 +08:00
.concat(files2), f => mimeTypes.includes(f.type));
const presentationsToUpload = accepted.map((file) => {
2017-11-22 22:47:27 +08:00
const id = _.uniqueId(file.name);
return {
file,
isDownloadable: false, // by default new presentations are set not to be downloadable
2017-11-22 22:47:27 +08:00
id,
filename: file.name,
isCurrent: false,
conversion: { done: false, error: false },
upload: { done: false, error: false, progress: 0 },
onProgress: (event) => {
if (!event.lengthComputable) {
this.deepMergeUpdateFileKey(id, 'upload', {
progress: 100,
done: true,
});
return;
}
this.deepMergeUpdateFileKey(id, 'upload', {
progress: (event.loaded / event.total) * 100,
done: event.loaded === event.total,
2017-09-23 04:45:31 +08:00
});
2017-11-22 22:47:27 +08:00
},
onConversion: (conversion) => {
this.deepMergeUpdateFileKey(id, 'conversion', conversion);
},
onUpload: (upload) => {
this.deepMergeUpdateFileKey(id, 'upload', upload);
},
onDone: (newId) => {
this.updateFileKey(id, 'id', newId);
2017-11-22 22:47:27 +08:00
},
};
});
2017-04-29 02:42:32 +08:00
this.setState(({ presentations }) => ({
2017-09-08 02:18:14 +08:00
presentations: presentations.concat(presentationsToUpload),
}), () => {
// after the state is set (files have been dropped),
// make the first of the new presentations current
if (presentationsToUpload && presentationsToUpload.length) {
this.handleCurrentChange(presentationsToUpload[0].id);
}
});
if (rejected.length > 0) {
notify(intl.formatMessage(intlMessages.rejectedError), 'error');
}
2017-04-29 02:42:32 +08:00
}
handleCurrentChange(id) {
2017-09-27 03:45:33 +08:00
const { presentations, disableActions } = this.state;
if (disableActions) return;
2017-04-29 02:42:32 +08:00
const currentIndex = presentations.findIndex(p => p.isCurrent);
const newCurrentIndex = presentations.findIndex(p => p.id === id);
2017-04-29 02:42:32 +08:00
const commands = {};
// we can end up without a current presentation
if (currentIndex !== -1) {
commands[currentIndex] = {
$apply: (presentation) => {
const p = presentation;
p.isCurrent = false;
return p;
},
};
}
2017-04-29 02:42:32 +08:00
commands[newCurrentIndex] = {
$apply: (presentation) => {
const p = presentation;
2017-04-29 02:42:32 +08:00
p.isCurrent = true;
return p;
},
};
const presentationsUpdated = update(presentations, commands);
2017-04-29 02:42:32 +08:00
this.setState({
presentations: presentationsUpdated,
});
}
handleRemove(item) {
2017-09-27 03:45:33 +08:00
const { presentations, disableActions } = this.state;
if (disableActions) return;
2017-04-29 02:42:32 +08:00
const toRemoveIndex = presentations.indexOf(item);
this.setState({
presentations: update(presentations, {
$splice: [[toRemoveIndex, 1]],
}),
});
}
toggleDownloadable(item) {
const { dispatchTogglePresentationDownloadable } = this.props;
const { presentations } = this.state;
const oldDownloadableState = item.isDownloadable;
const outOfDatePresentationIndex = presentations.findIndex(p => p.id === item.id);
const commands = {};
commands[outOfDatePresentationIndex] = {
$apply: (presentation) => {
const p = presentation;
p.isDownloadable = !oldDownloadableState;
return p;
},
};
const presentationsUpdated = update(presentations, commands);
this.setState({
presentations: presentationsUpdated,
});
// If the presentation has not be uploaded yet, adjusting the state suffices
// otherwise set previously uploaded presentation to [not] be downloadable
if (item.upload.done) {
dispatchTogglePresentationDownloadable(item, !oldDownloadableState);
}
}
2017-04-29 02:42:32 +08:00
renderPresentationList() {
const { presentations } = this.state;
2019-05-15 00:51:13 +08:00
const { intl } = this.props;
2017-04-29 02:42:32 +08:00
const presentationsSorted = presentations
.sort((a, b) => a.uploadTimestamp - b.uploadTimestamp);
2017-04-29 02:42:32 +08:00
return (
2017-05-04 00:36:16 +08:00
<div className={styles.fileList}>
<table className={styles.table}>
<tbody>
2019-05-15 00:51:13 +08:00
<th className={styles.visuallyHidden} colSpan={3}>{intl.formatMessage(intlMessages.filename)}</th>
<th className={styles.visuallyHidden}>{intl.formatMessage(intlMessages.status)}</th>
<th className={styles.visuallyHidden}>{intl.formatMessage(intlMessages.options)}</th>
{ presentationsSorted.map(item => this.renderPresentationItem(item))}
2017-05-04 00:36:16 +08:00
</tbody>
</table>
</div>
2017-04-29 02:42:32 +08:00
);
}
2017-05-06 04:17:38 +08:00
renderPresentationItemStatus(item) {
const { intl } = this.props;
2017-09-08 02:18:14 +08:00
if (!item.upload.done && item.upload.progress === 0) {
return intl.formatMessage(intlMessages.fileToUpload);
}
if (!item.upload.done && !item.upload.error) {
return intl.formatMessage(intlMessages.uploadProcess, {
0: Math.floor(item.upload.progress).toString(),
2017-09-08 02:18:14 +08:00
});
}
2017-05-06 04:17:38 +08:00
2017-09-08 02:18:14 +08:00
if (item.upload.done && item.upload.error) {
const errorMessage = intlMessages[item.upload.status] || intlMessages.genericError;
2017-09-08 02:18:14 +08:00
return intl.formatMessage(errorMessage);
}
if (!item.conversion.done && item.conversion.error) {
const errorMessage = intlMessages[item.conversion.status] || intlMessages.genericError;
2017-05-06 04:17:38 +08:00
return intl.formatMessage(errorMessage);
}
2017-09-08 02:18:14 +08:00
if (!item.conversion.done && !item.conversion.error) {
if (item.conversion.pagesCompleted < item.conversion.numPages) {
2017-05-06 04:17:38 +08:00
return intl.formatMessage(intlMessages.conversionProcessingSlides, {
0: item.conversion.pagesCompleted,
1: item.conversion.numPages,
2017-05-06 04:17:38 +08:00
});
}
const conversionStatusMessage = intlMessages[item.conversion.status]
|| intlMessages.genericConversionStatus;
2017-05-06 04:17:38 +08:00
return intl.formatMessage(conversionStatusMessage);
}
2017-09-08 02:18:14 +08:00
return null;
2017-05-06 04:17:38 +08:00
}
2017-04-29 02:42:32 +08:00
renderPresentationItem(item) {
2017-12-05 00:10:37 +08:00
const { disableActions, oldCurrentId } = this.state;
const { intl } = this.props;
2017-05-04 00:36:16 +08:00
2017-12-05 00:10:37 +08:00
const isActualCurrent = item.id === oldCurrentId;
2017-11-28 20:26:00 +08:00
const isUploading = !item.upload.done && item.upload.progress > 0;
const isConverting = !item.conversion.done && item.upload.done;
const hasError = item.conversion.error || item.upload.error;
const isProcessing = (isUploading || isConverting) && !hasError;
const itemClassName = {
[styles.tableItemNew]: item.id.indexOf(item.filename) !== -1,
[styles.tableItemUploading]: isUploading,
[styles.tableItemConverting]: isConverting,
[styles.tableItemError]: hasError,
[styles.tableItemAnimated]: isProcessing,
};
2017-04-29 02:42:32 +08:00
const hideRemove = this.isDefault(item);
2019-02-21 06:44:44 +08:00
const formattedDownloadableLabel = item.isDownloadable
? intl.formatMessage(intlMessages.isDownloadable)
: intl.formatMessage(intlMessages.isNotDownloadable);
2017-05-04 04:51:17 +08:00
const isDownloadableStyle = item.isDownloadable
? cx(styles.itemAction, styles.itemActionRemove, styles.checked)
: cx(styles.itemAction, styles.itemActionRemove);
2017-04-29 02:42:32 +08:00
return (
<tr
2017-05-04 00:36:16 +08:00
key={item.id}
2017-04-29 02:42:32 +08:00
className={cx(itemClassName)}
>
<td className={styles.tableItemIcon}>
2017-11-22 22:47:27 +08:00
<Icon iconName="file" />
2017-04-29 02:42:32 +08:00
</td>
2017-12-05 00:10:37 +08:00
{
2018-12-06 01:42:31 +08:00
isActualCurrent
? (
<th className={styles.tableItemCurrent}>
<span className={styles.currentLabel}>
{intl.formatMessage(intlMessages.current)}
2018-12-06 01:42:31 +08:00
</span>
</th>
)
: null
2017-12-05 00:10:37 +08:00
}
<th className={styles.tableItemName} colSpan={!isActualCurrent ? 2 : 0}>
2017-04-29 02:42:32 +08:00
<span>{item.filename}</span>
</th>
2017-11-28 20:26:00 +08:00
<td className={styles.tableItemStatus} colSpan={hasError ? 2 : 0}>
2017-05-06 04:17:38 +08:00
{this.renderPresentationItemStatus(item)}
2017-04-29 02:42:32 +08:00
</td>
2017-11-28 20:26:00 +08:00
{ hasError ? null : (
<td className={styles.tableItemActions}>
<Button
className={isDownloadableStyle}
2019-02-21 06:44:44 +08:00
label={formattedDownloadableLabel}
hideLabel
size="sm"
icon={item.isDownloadable ? 'download' : 'download-off'}
onClick={() => this.toggleDownloadable(item)}
/>
<Checkbox
ariaLabel={intl.formatMessage(intlMessages.setAsCurrentPresentation)}
checked={item.isCurrent}
className={styles.itemAction}
disabled={disableActions}
keyValue={item.id}
onChange={this.handleCurrentChange}
/>
2017-11-28 20:26:00 +08:00
{ hideRemove ? null : (
<Button
2017-11-28 20:26:00 +08:00
disabled={disableActions}
className={cx(styles.itemAction, styles.itemActionRemove)}
2019-02-21 06:44:44 +08:00
label={intl.formatMessage(intlMessages.removePresentation)}
aria-label={`${intl.formatMessage(intlMessages.removePresentation)} ${item.filename}`}
size="sm"
icon="delete"
hideLabel
2017-11-28 20:26:00 +08:00
onClick={() => this.handleRemove(item)}
/>
2017-11-28 20:26:00 +08:00
)}
</td>
)}
2017-04-29 02:42:32 +08:00
</tr>
);
}
renderPicDropzone() {
const {
intl,
fileSizeMin,
fileSizeMax,
} = this.props;
const { disableActions } = this.state;
if (disableActions) return null;
return (
<Dropzone
multiple
className={styles.dropzone}
activeClassName={styles.dropzoneActive}
rejectClassName={styles.dropzoneReject}
accept="image/*"
minSize={fileSizeMin}
maxSize={fileSizeMax}
disablePreview
onDrop={this.handleFiledrop}
>
<Icon className={styles.dropzoneIcon} iconName="upload" />
<p className={styles.dropzoneMessage}>
{intl.formatMessage(intlMessages.dropzoneImagesLabel)}
&nbsp;
<span className={styles.dropzoneLink}>
{intl.formatMessage(intlMessages.browseImagesLabel)}
</span>
</p>
</Dropzone>
);
}
2017-04-29 02:42:32 +08:00
renderDropzone() {
2017-05-04 00:36:16 +08:00
const {
intl,
fileSizeMin,
fileSizeMax,
fileValidMimeTypes,
} = this.props;
2017-04-29 02:42:32 +08:00
2017-05-06 04:17:38 +08:00
const { disableActions } = this.state;
if (disableActions) return null;
2017-05-04 04:51:17 +08:00
2017-04-29 02:42:32 +08:00
return (
<Dropzone
2017-09-08 02:18:14 +08:00
multiple
2017-04-29 02:42:32 +08:00
className={styles.dropzone}
activeClassName={styles.dropzoneActive}
rejectClassName={styles.dropzoneReject}
2019-03-08 03:53:01 +08:00
accept={isMobileBrowser ? '' : fileValidMimeTypes.map(fileValid => fileValid.extension)}
2017-05-04 00:36:16 +08:00
minSize={fileSizeMin}
maxSize={fileSizeMax}
2018-12-06 01:42:31 +08:00
disablepreview="true"
2017-04-29 02:42:32 +08:00
onDrop={this.handleFiledrop}
>
2017-11-22 22:47:27 +08:00
<Icon className={styles.dropzoneIcon} iconName="upload" />
2017-04-29 02:42:32 +08:00
<p className={styles.dropzoneMessage}>
2018-12-06 01:42:31 +08:00
{intl.formatMessage(intlMessages.dropzoneLabel)}
&nbsp;
2017-04-29 02:42:32 +08:00
<span className={styles.dropzoneLink}>
{intl.formatMessage(intlMessages.browseFilesLabel)}
</span>
</p>
</Dropzone>
);
}
render() {
const { intl } = this.props;
const { preventClosing, disableActions } = this.state;
return (
<ModalFullscreen
title={intl.formatMessage(intlMessages.title)}
preventClosing={preventClosing}
confirm={{
callback: this.handleConfirm,
label: intl.formatMessage(intlMessages.confirmLabel),
description: intl.formatMessage(intlMessages.confirmDesc),
disabled: disableActions,
}}
dismiss={{
callback: this.handleDismiss,
label: intl.formatMessage(intlMessages.dismissLabel),
description: intl.formatMessage(intlMessages.dismissDesc),
disabled: disableActions,
}}
>
<p>{intl.formatMessage(intlMessages.message)}</p>
{this.renderPresentationList()}
<div className={styles.dropzoneWrapper}>
{isMobileBrowser ? this.renderPicDropzone() : null}
{this.renderDropzone()}
</div>
</ModalFullscreen>
);
}
}
2017-04-29 02:42:32 +08:00
2017-09-23 04:45:31 +08:00
PresentationUploader.propTypes = propTypes;
PresentationUploader.defaultProps = defaultProps;
export default withModalMounter(injectIntl(PresentationUploader));