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';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2021-08-30 08:53:06 +08:00
|
|
|
import { TAB } from '/imports/utils/keyCodes';
|
2021-04-01 01:13:36 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2022-02-15 04:20:50 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2017-05-04 00:36:16 +08:00
|
|
|
import update from 'immutability-helper';
|
2018-07-12 06:03:56 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2020-02-26 03:29:14 +08:00
|
|
|
import { toast } from 'react-toastify';
|
2021-09-05 06:36:48 +08:00
|
|
|
import { registerTitleView, unregisterTitleView } from '/imports/utils/dom-utils';
|
2021-11-08 21:57:55 +08:00
|
|
|
import Styled from './styles';
|
2023-04-14 22:04:24 +08:00
|
|
|
import PresentationDownloadDropdown from './presentation-download-dropdown/component';
|
2021-11-08 21:57:55 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2022-12-15 04:03:23 +08:00
|
|
|
import Radio from '/imports/ui/components/common/radio/component';
|
2023-02-23 21:44:29 +08:00
|
|
|
import { unique } from 'radash';
|
2023-02-23 04:16:43 +08:00
|
|
|
import { isPresentationEnabled } from '/imports/ui/services/features';
|
2017-06-07 20:28:41 +08:00
|
|
|
|
2021-04-01 01:13:36 +08:00
|
|
|
const { isMobile } = deviceInfo;
|
2017-09-08 02:18:14 +08:00
|
|
|
const propTypes = {
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadOriginal: PropTypes.bool.isRequired,
|
2023-08-25 22:37:32 +08:00
|
|
|
allowDownloadConverted: PropTypes.bool.isRequired,
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadWithAnnotations: PropTypes.bool.isRequired,
|
2023-03-10 19:30:46 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2022-01-20 03:45:24 +08:00
|
|
|
fileUploadConstraintsHint: PropTypes.bool.isRequired,
|
|
|
|
fileSizeMax: PropTypes.number.isRequired,
|
|
|
|
filePagesMax: PropTypes.number.isRequired,
|
2017-09-08 02:18:14 +08:00
|
|
|
handleSave: PropTypes.func.isRequired,
|
2023-08-22 22:53:38 +08:00
|
|
|
dispatchChangePresentationDownloadable: PropTypes.func.isRequired,
|
2023-03-10 19:30:46 +08:00
|
|
|
fileValidMimeTypes: PropTypes.arrayOf(PropTypes.shape).isRequired,
|
2017-09-08 02:18:14 +08:00
|
|
|
presentations: PropTypes.arrayOf(PropTypes.shape({
|
2023-10-17 03:27:22 +08:00
|
|
|
presentationId: PropTypes.string.isRequired,
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
current: PropTypes.bool.isRequired,
|
2017-09-08 02:18:14 +08:00
|
|
|
})).isRequired,
|
2023-05-01 22:01:04 +08:00
|
|
|
currentPresentation: PropTypes.string.isRequired,
|
2020-02-26 03:29:14 +08:00
|
|
|
isOpen: PropTypes.bool.isRequired,
|
2023-03-10 19:30:46 +08:00
|
|
|
handleFiledrop: PropTypes.func.isRequired,
|
|
|
|
selectedToBeNextCurrent: PropTypes.string,
|
|
|
|
renderPresentationItemStatus: PropTypes.func.isRequired,
|
|
|
|
externalUploadData: PropTypes.shape({
|
|
|
|
presentationUploadExternalDescription: PropTypes.string.isRequired,
|
|
|
|
presentationUploadExternalUrl: PropTypes.string.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
isPresenter: PropTypes.bool.isRequired,
|
2023-05-04 19:48:32 +08:00
|
|
|
exportPresentation: PropTypes.func.isRequired,
|
2017-09-08 02:18:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
2023-03-10 19:30:46 +08:00
|
|
|
selectedToBeNextCurrent: '',
|
2017-09-08 02:18:14 +08:00
|
|
|
};
|
|
|
|
|
2017-04-29 02:42:32 +08:00
|
|
|
const intlMessages = defineMessages({
|
2023-05-01 22:01:04 +08:00
|
|
|
currentBadge: {
|
2017-12-05 00:10:37 +08:00
|
|
|
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
|
|
|
},
|
2019-05-29 05:18:49 +08:00
|
|
|
uploadLabel: {
|
|
|
|
id: 'app.presentationUploder.uploadLabel',
|
|
|
|
description: 'confirm label when presentations are to be uploaded',
|
2017-04-29 02:42:32 +08:00
|
|
|
},
|
|
|
|
confirmLabel: {
|
|
|
|
id: 'app.presentationUploder.confirmLabel',
|
2019-05-25 03:51:50 +08:00
|
|
|
description: 'confirm label when no presentations are to be uploaded',
|
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
|
|
|
},
|
2022-06-25 00:47:17 +08:00
|
|
|
externalUploadTitle: {
|
|
|
|
id: 'app.presentationUploder.externalUploadTitle',
|
|
|
|
description: 'title for external upload area',
|
|
|
|
},
|
|
|
|
externalUploadLabel: {
|
|
|
|
id: 'app.presentationUploder.externalUploadLabel',
|
|
|
|
description: 'message of external upload button',
|
|
|
|
},
|
2018-12-17 17:30: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
|
|
|
},
|
2018-12-03 14:10:50 +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
|
|
|
},
|
2022-01-20 03:45:24 +08:00
|
|
|
extraHint: {
|
|
|
|
id: 'app.presentationUploder.extraHint',
|
|
|
|
description: 'message used to indicate upload file max sizes',
|
|
|
|
},
|
2018-12-03 11:40:58 +08:00
|
|
|
rejectedError: {
|
|
|
|
id: 'app.presentationUploder.rejectedError',
|
|
|
|
description: 'some files rejected, please check the file mime types',
|
|
|
|
},
|
2022-02-22 02:01:55 +08:00
|
|
|
badConnectionError: {
|
|
|
|
id: 'app.presentationUploder.connectionClosedError',
|
|
|
|
description: 'message indicating that the connection was closed',
|
|
|
|
},
|
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
|
|
|
},
|
2020-04-30 00:34:37 +08:00
|
|
|
408: {
|
|
|
|
id: 'app.presentationUploder.upload.408',
|
|
|
|
description: 'error for token request timeout',
|
|
|
|
},
|
|
|
|
404: {
|
|
|
|
id: 'app.presentationUploder.upload.404',
|
|
|
|
description: 'error not found',
|
|
|
|
},
|
|
|
|
401: {
|
|
|
|
id: 'app.presentationUploder.upload.401',
|
|
|
|
description: 'error for failed upload token request.',
|
|
|
|
},
|
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
|
|
|
},
|
2020-03-12 21:56:12 +08:00
|
|
|
genericError: {
|
|
|
|
id: 'app.presentationUploder.genericError',
|
|
|
|
description: 'generic error while uploading/converting',
|
|
|
|
},
|
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
|
|
|
},
|
2017-11-28 01:44:45 +08:00
|
|
|
TIMEOUT: {
|
|
|
|
id: 'app.presentationUploder.conversion.timeout',
|
|
|
|
},
|
2022-10-18 04:05:16 +08:00
|
|
|
CONVERSION_TIMEOUT: {
|
2023-03-10 19:30:46 +08:00
|
|
|
id: 'app.presentationUploder.conversion.conversionTimeout',
|
|
|
|
description: 'warns the user that the presentation timed out in the back-end in specific page of the document',
|
|
|
|
},
|
2017-05-06 04:17:38 +08:00
|
|
|
GENERATING_THUMBNAIL: {
|
|
|
|
id: 'app.presentationUploder.conversion.generatingThumbnail',
|
2017-11-28 01:44:45 +08:00
|
|
|
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-10-16 15:37:03 +08:00
|
|
|
PDF_HAS_BIG_PAGE: {
|
|
|
|
id: 'app.presentationUploder.conversion.pdfHasBigPage',
|
|
|
|
description: 'warns the user that the conversion failed because of the pdf page siz that exceeds the allowed limit',
|
|
|
|
},
|
2021-04-28 03:45:14 +08:00
|
|
|
OFFICE_DOC_CONVERSION_INVALID: {
|
|
|
|
id: 'app.presentationUploder.conversion.officeDocConversionInvalid',
|
|
|
|
description: '',
|
|
|
|
},
|
|
|
|
OFFICE_DOC_CONVERSION_FAILED: {
|
|
|
|
id: 'app.presentationUploder.conversion.officeDocConversionFailed',
|
|
|
|
description: 'warns the user that the conversion failed because of wrong office file',
|
|
|
|
},
|
|
|
|
UNSUPPORTED_DOCUMENT: {
|
|
|
|
id: 'app.presentationUploder.conversion.unsupportedDocument',
|
|
|
|
description: 'warns the user that the file extension is not supported',
|
|
|
|
},
|
2019-02-21 06:44:44 +08:00
|
|
|
isDownloadable: {
|
|
|
|
id: 'app.presentationUploder.isDownloadableLabel',
|
2019-02-22 05:10:32 +08:00
|
|
|
description: 'presentation is available for downloading by all viewers',
|
2019-02-21 06:44:44 +08:00
|
|
|
},
|
|
|
|
isNotDownloadable: {
|
|
|
|
id: 'app.presentationUploder.isNotDownloadableLabel',
|
2019-02-22 05:10:32 +08:00
|
|
|
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',
|
|
|
|
},
|
2019-02-22 07:43:11 +08:00
|
|
|
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',
|
|
|
|
},
|
2020-03-10 20:58:14 +08:00
|
|
|
uploading: {
|
|
|
|
id: 'app.presentationUploder.uploading',
|
|
|
|
description: 'uploading label for toast notification',
|
|
|
|
},
|
|
|
|
uploadStatus: {
|
|
|
|
id: 'app.presentationUploder.uploadStatus',
|
|
|
|
description: 'upload status for toast notification',
|
|
|
|
},
|
|
|
|
completed: {
|
|
|
|
id: 'app.presentationUploder.completed',
|
|
|
|
description: 'uploads complete label for toast notification',
|
|
|
|
},
|
|
|
|
item: {
|
|
|
|
id: 'app.presentationUploder.item',
|
|
|
|
description: 'single item label',
|
|
|
|
},
|
|
|
|
itemPlural: {
|
|
|
|
id: 'app.presentationUploder.itemPlural',
|
|
|
|
description: 'plural item label',
|
|
|
|
},
|
|
|
|
clearErrors: {
|
|
|
|
id: 'app.presentationUploder.clearErrors',
|
|
|
|
description: 'button label for clearing upload errors',
|
|
|
|
},
|
|
|
|
clearErrorsDesc: {
|
|
|
|
id: 'app.presentationUploder.clearErrorsDesc',
|
|
|
|
description: 'aria description for button clearing upload error',
|
|
|
|
},
|
2021-09-05 06:36:48 +08:00
|
|
|
uploadViewTitle: {
|
|
|
|
id: 'app.presentationUploder.uploadViewTitle',
|
|
|
|
description: 'view name apended to document title',
|
2022-07-20 03:36:00 +08:00
|
|
|
},
|
|
|
|
exportHint: {
|
|
|
|
id: 'app.presentationUploader.exportHint',
|
|
|
|
description: 'message to indicate the export presentation option',
|
|
|
|
},
|
|
|
|
exportToastHeader: {
|
|
|
|
id: 'app.presentationUploader.exportToastHeader',
|
|
|
|
description: 'exporting toast header',
|
|
|
|
},
|
|
|
|
exportToastHeaderPlural: {
|
|
|
|
id: 'app.presentationUploader.exportToastHeaderPlural',
|
|
|
|
description: 'exporting toast header in plural',
|
|
|
|
},
|
|
|
|
export: {
|
|
|
|
id: 'app.presentationUploader.export',
|
|
|
|
description: 'send presentation to chat',
|
|
|
|
},
|
|
|
|
exporting: {
|
|
|
|
id: 'app.presentationUploader.exporting',
|
|
|
|
description: 'presentation is being sent to chat',
|
|
|
|
},
|
|
|
|
currentLabel: {
|
|
|
|
id: 'app.presentationUploader.currentPresentationLabel',
|
|
|
|
description: 'current presentation label',
|
|
|
|
},
|
2023-07-10 20:44:34 +08:00
|
|
|
actionsLabel: {
|
|
|
|
id: 'app.presentation.actionsLabel',
|
|
|
|
description: 'actions label',
|
2022-07-20 03:36:00 +08:00
|
|
|
},
|
2017-04-29 02:42:32 +08:00
|
|
|
});
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const handleDismissToast = (id) => toast.dismiss(id);
|
|
|
|
|
2017-05-06 04:17:38 +08:00
|
|
|
class PresentationUploader extends Component {
|
2017-04-29 02:42:32 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
2020-02-26 03:29:14 +08:00
|
|
|
presentations: [],
|
2017-05-06 04:17:38 +08:00
|
|
|
disableActions: false,
|
2022-07-26 05:56:26 +08:00
|
|
|
presExporting: new Set(),
|
2017-04-29 02:42:32 +08:00
|
|
|
};
|
|
|
|
|
2020-02-26 03:29:14 +08:00
|
|
|
this.toastId = null;
|
2020-03-12 21:56:12 +08:00
|
|
|
this.hasError = null;
|
2022-07-20 03:36:00 +08:00
|
|
|
this.exportToastId = null;
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const { handleFiledrop } = this.props;
|
2020-02-26 03:29:14 +08:00
|
|
|
// handlers
|
2023-03-10 19:30:46 +08:00
|
|
|
this.handleFiledrop = handleFiledrop;
|
2017-04-29 02:42:32 +08:00
|
|
|
this.handleConfirm = this.handleConfirm.bind(this);
|
|
|
|
this.handleDismiss = this.handleDismiss.bind(this);
|
|
|
|
this.handleRemove = this.handleRemove.bind(this);
|
2020-02-26 03:29:14 +08:00
|
|
|
this.handleCurrentChange = this.handleCurrentChange.bind(this);
|
2023-04-20 19:48:43 +08:00
|
|
|
this.handleDownloadingOfPresentation = this.handleDownloadingOfPresentation.bind(this);
|
2020-02-26 03:29:14 +08:00
|
|
|
// renders
|
|
|
|
this.renderDropzone = this.renderDropzone.bind(this);
|
2022-06-25 00:47:17 +08:00
|
|
|
this.renderExternalUpload = this.renderExternalUpload.bind(this);
|
2020-02-26 03:29:14 +08:00
|
|
|
this.renderPicDropzone = this.renderPicDropzone.bind(this);
|
|
|
|
this.renderPresentationList = this.renderPresentationList.bind(this);
|
|
|
|
this.renderPresentationItem = this.renderPresentationItem.bind(this);
|
|
|
|
// utilities
|
2017-09-27 03:45:33 +08:00
|
|
|
this.deepMergeUpdateFileKey = this.deepMergeUpdateFileKey.bind(this);
|
2020-02-26 03:29:14 +08:00
|
|
|
this.updateFileKey = this.updateFileKey.bind(this);
|
2022-07-26 05:56:26 +08:00
|
|
|
this.getPresentationsToShow = this.getPresentationsToShow.bind(this);
|
2023-08-16 22:18:51 +08:00
|
|
|
this.handleDownloadableChange = this.handleDownloadableChange.bind(this);
|
2019-03-29 22:48:22 +08:00
|
|
|
}
|
|
|
|
|
2020-02-26 03:29:14 +08:00
|
|
|
componentDidUpdate(prevProps) {
|
2023-05-01 22:01:04 +08:00
|
|
|
const { isOpen, presentations: propPresentations, currentPresentation, intl } = this.props;
|
2020-02-26 03:29:14 +08:00
|
|
|
const { presentations } = this.state;
|
2022-06-29 00:33:54 +08:00
|
|
|
const { presentations: prevPropPresentations } = prevProps;
|
|
|
|
|
|
|
|
let shouldUpdateState = isOpen && !prevProps.isOpen;
|
|
|
|
const presState = Object.values({
|
2022-10-17 23:12:22 +08:00
|
|
|
...JSON.parse(JSON.stringify(propPresentations)),
|
|
|
|
...JSON.parse(JSON.stringify(presentations)),
|
2022-06-29 00:33:54 +08:00
|
|
|
});
|
2022-10-05 03:25:54 +08:00
|
|
|
if (propPresentations.length > prevPropPresentations.length) {
|
|
|
|
shouldUpdateState = true;
|
2023-03-10 19:30:46 +08:00
|
|
|
const propsDiffs = propPresentations.filter(
|
|
|
|
(p) => !prevPropPresentations.some(
|
2023-10-17 03:27:22 +08:00
|
|
|
(presentation) => p.presentationId === presentation.presentationId
|
2023-03-10 19:30:46 +08:00
|
|
|
|| p.temporaryPresentationId === presentation.temporaryPresentationId,
|
|
|
|
),
|
|
|
|
);
|
2022-10-05 03:25:54 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
propsDiffs.forEach((p) => {
|
|
|
|
const index = presState.findIndex(
|
2023-10-17 03:27:22 +08:00
|
|
|
(pres) => pres.temporaryPresentationId === p.temporaryPresentationId || pres.presentationId === p.presentationId,
|
2023-03-10 19:30:46 +08:00
|
|
|
);
|
2022-10-05 03:25:54 +08:00
|
|
|
if (index === -1) {
|
|
|
|
presState.push(p);
|
2022-10-06 20:58:42 +08:00
|
|
|
}
|
2023-03-10 19:30:46 +08:00
|
|
|
});
|
2022-10-05 03:25:54 +08:00
|
|
|
}
|
2022-08-24 00:42:28 +08:00
|
|
|
const presStateFiltered = presState.filter((presentation) => {
|
2023-10-17 03:27:22 +08:00
|
|
|
const currentPropPres = propPresentations.find((pres) => pres.presentationId === presentation.presentationId);
|
|
|
|
const prevPropPres = prevPropPresentations.find((pres) => pres.presentationId === presentation.presentationId);
|
2023-10-18 00:35:48 +08:00
|
|
|
const hasConversionError = !!presentation?.uploadErrorMsgKey;
|
|
|
|
const finishedConversion = !presentation?.uploadInProgress
|
|
|
|
|| !currentPropPres?.uploadInProgress;
|
2023-10-17 03:27:22 +08:00
|
|
|
const hasTemporaryId = presentation.presentationId.startsWith(presentation.name);
|
2022-08-12 00:29:48 +08:00
|
|
|
|
2022-08-24 00:42:28 +08:00
|
|
|
if (hasConversionError || (!finishedConversion && hasTemporaryId)) return true;
|
2022-08-12 00:29:48 +08:00
|
|
|
if (!currentPropPres) return false;
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const modPresentation = presentation;
|
2023-10-17 03:27:22 +08:00
|
|
|
if (currentPropPres.current !== prevPropPres?.current) {
|
|
|
|
modPresentation.current = currentPropPres.current;
|
2023-10-19 20:57:40 +08:00
|
|
|
shouldUpdateState = true;
|
2022-08-25 00:34:50 +08:00
|
|
|
}
|
|
|
|
|
2023-10-28 01:57:25 +08:00
|
|
|
if (currentPropPres?.totalPagesUploaded !== prevPropPres?.totalPagesUploaded
|
|
|
|
|| presentation.totalPagesUploaded !== currentPropPres?.totalPagesUploaded) {
|
2023-10-18 00:35:48 +08:00
|
|
|
modPresentation.totalPagesUploaded = currentPropPres.totalPagesUploaded;
|
2023-10-28 01:57:25 +08:00
|
|
|
shouldUpdateState = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentPropPres?.uploadCompleted !== prevPropPres?.uploadCompleted
|
|
|
|
|| presentation.uploadCompleted !== currentPropPres?.uploadCompleted) {
|
2023-10-17 03:27:22 +08:00
|
|
|
modPresentation.uploadCompleted = currentPropPres.uploadCompleted;
|
|
|
|
shouldUpdateState = true;
|
|
|
|
}
|
|
|
|
|
2023-10-28 01:57:25 +08:00
|
|
|
if (currentPropPres?.totalPages !== prevPropPres?.totalPages
|
|
|
|
|| presentation.totalPages !== currentPropPres?.totalPages) {
|
|
|
|
modPresentation.totalPages = currentPropPres.totalPages;
|
|
|
|
shouldUpdateState = true;
|
|
|
|
}
|
|
|
|
|
2023-10-17 03:27:22 +08:00
|
|
|
if (currentPropPres?.downloadable !== prevPropPres?.downloadable) {
|
|
|
|
presentation.downloadable = currentPropPres.downloadable;
|
2023-04-20 19:48:43 +08:00
|
|
|
shouldUpdateState = true;
|
|
|
|
}
|
|
|
|
|
2023-10-26 03:35:06 +08:00
|
|
|
if (currentPropPres?.downloadFileUri !== prevPropPres?.downloadFileUri) {
|
|
|
|
presentation.downloadFileUri = currentPropPres.downloadFileUri;
|
2023-08-10 23:18:59 +08:00
|
|
|
shouldUpdateState = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentPropPres?.filenameConverted !== prevPropPres?.filenameConverted) {
|
|
|
|
presentation.filenameConverted = currentPropPres.filenameConverted;
|
|
|
|
shouldUpdateState = true;
|
|
|
|
}
|
|
|
|
|
2023-10-18 00:35:48 +08:00
|
|
|
modPresentation.uploadInProgress = currentPropPres.uploadInProgress;
|
2023-10-28 01:57:25 +08:00
|
|
|
modPresentation.removable = currentPropPres.removable;
|
2022-08-12 00:29:48 +08:00
|
|
|
|
2022-08-24 00:42:28 +08:00
|
|
|
return true;
|
2023-03-10 19:30:46 +08:00
|
|
|
}).filter((presentation) => {
|
2022-08-24 00:42:28 +08:00
|
|
|
const duplicated = presentations.find(
|
2023-10-17 03:27:22 +08:00
|
|
|
(pres) => pres.name === presentation.name
|
|
|
|
&& pres.presentationId !== presentation.presentationId,
|
2022-08-24 00:42:28 +08:00
|
|
|
);
|
|
|
|
if (duplicated
|
2023-10-17 03:27:22 +08:00
|
|
|
&& duplicated.presentationId.startsWith(presentation.name)
|
|
|
|
&& !presentation.presentationId.startsWith(presentation.name)
|
2023-10-18 00:35:48 +08:00
|
|
|
&& presentation?.uploadInProgress === duplicated?.uploadInProgress) {
|
2023-03-10 19:30:46 +08:00
|
|
|
return false; // Prioritizing propPresentations (the one with id from back-end)
|
2022-08-24 00:42:28 +08:00
|
|
|
}
|
2022-08-12 00:29:48 +08:00
|
|
|
return true;
|
2022-06-29 00:33:54 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
if (shouldUpdateState) {
|
|
|
|
this.setState({
|
2023-10-17 03:27:22 +08:00
|
|
|
presentations: unique(presStateFiltered, p => p.presentationId)
|
2022-06-29 00:33:54 +08:00
|
|
|
});
|
|
|
|
}
|
2021-09-05 06:36:48 +08:00
|
|
|
|
|
|
|
if (!isOpen && prevProps.isOpen) {
|
|
|
|
unregisterTitleView();
|
|
|
|
}
|
|
|
|
|
2023-05-01 22:01:04 +08:00
|
|
|
// Updates presentation list when modal opens to avoid missing presentations
|
2021-05-07 22:09:30 +08:00
|
|
|
if (isOpen && !prevProps.isOpen) {
|
2021-09-05 06:36:48 +08:00
|
|
|
registerTitleView(intl.formatMessage(intlMessages.uploadViewTitle));
|
2023-03-10 19:30:46 +08:00
|
|
|
const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
2021-08-15 08:09:46 +08:00
|
|
|
const modal = document.getElementById('upload-modal');
|
|
|
|
const firstFocusableElement = modal?.querySelectorAll(focusableElements)[0];
|
|
|
|
const focusableContent = modal?.querySelectorAll(focusableElements);
|
|
|
|
const lastFocusableElement = focusableContent[focusableContent.length - 1];
|
2023-03-10 19:30:46 +08:00
|
|
|
|
2021-08-15 08:09:46 +08:00
|
|
|
firstFocusableElement.focus();
|
2023-03-10 19:30:46 +08:00
|
|
|
|
|
|
|
modal.addEventListener('keydown', (e) => {
|
|
|
|
const tab = e.key === 'Tab' || e.keyCode === TAB;
|
2021-08-15 08:09:46 +08:00
|
|
|
if (!tab) return;
|
|
|
|
if (e.shiftKey) {
|
|
|
|
if (document.activeElement === firstFocusableElement) {
|
|
|
|
lastFocusableElement.focus();
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2023-03-10 19:30:46 +08:00
|
|
|
} else if (document.activeElement === lastFocusableElement) {
|
|
|
|
firstFocusableElement.focus();
|
|
|
|
e.preventDefault();
|
2021-08-15 08:09:46 +08:00
|
|
|
}
|
|
|
|
});
|
2021-05-07 21:52:12 +08:00
|
|
|
}
|
|
|
|
|
2023-05-01 22:01:04 +08:00
|
|
|
if (currentPresentation && currentPresentation !== prevProps.currentPresentation) {
|
|
|
|
this.handleCurrentChange(currentPresentation);
|
|
|
|
}
|
|
|
|
|
2020-04-02 06:54:47 +08:00
|
|
|
if (presentations.length > 0) {
|
2023-10-17 03:27:22 +08:00
|
|
|
const selected = propPresentations.filter((p) => p.current);
|
|
|
|
if (selected.length > 0) Session.set('selectedToBeNextCurrent', selected[0].presentationId);
|
2020-02-26 03:29:14 +08:00
|
|
|
}
|
2022-10-08 01:36:02 +08:00
|
|
|
|
|
|
|
if (this.exportToastId) {
|
|
|
|
if (!prevProps.isOpen && isOpen) {
|
2023-03-10 19:30:46 +08:00
|
|
|
handleDismissToast(this.exportToastId);
|
2022-10-08 01:36:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
toast.update(this.exportToastId, {
|
|
|
|
render: this.renderExportToast(),
|
|
|
|
});
|
|
|
|
}
|
2017-09-27 03:45:33 +08:00
|
|
|
}
|
|
|
|
|
2021-06-12 03:33:15 +08:00
|
|
|
componentWillUnmount() {
|
2023-03-10 19:30:46 +08:00
|
|
|
const id = Session.get('presentationUploaderToastId');
|
2023-02-15 05:43:35 +08:00
|
|
|
if (id) {
|
|
|
|
toast.dismiss(id);
|
2023-03-10 19:30:46 +08:00
|
|
|
Session.set('presentationUploaderToastId', null);
|
2023-02-15 05:43:35 +08:00
|
|
|
}
|
|
|
|
Session.set('showUploadPresentationView', false);
|
2022-10-08 01:36:02 +08:00
|
|
|
}
|
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
handleRemove(item, withErr = false) {
|
|
|
|
if (withErr) {
|
2023-02-08 04:38:50 +08:00
|
|
|
const { presentations } = this.state;
|
|
|
|
const { presentations: propPresentations } = this.props;
|
2023-03-14 20:56:27 +08:00
|
|
|
|
2023-10-18 00:35:48 +08:00
|
|
|
const filteredPropPresentations = propPresentations.filter(d => d.uploadCompleted && !d.uploadInProgress);
|
2023-10-17 03:27:22 +08:00
|
|
|
const ids = new Set(filteredPropPresentations.map((d) => d.presentationId));
|
2023-02-08 04:38:50 +08:00
|
|
|
const filteredPresentations = presentations.filter((d) => {
|
2023-10-17 03:27:22 +08:00
|
|
|
d.current = false;
|
2023-10-18 00:35:48 +08:00
|
|
|
return !ids.has(d.presentationId) && !d.uploadErrorMsgKey && !(d.uploadCompleted && !d.uploadInProgress)});
|
2023-02-08 04:38:50 +08:00
|
|
|
const merged = [
|
|
|
|
...filteredPresentations,
|
2023-03-14 20:56:27 +08:00
|
|
|
...filteredPropPresentations,
|
2023-02-08 04:38:50 +08:00
|
|
|
];
|
2023-03-24 20:21:49 +08:00
|
|
|
let hasUploading
|
|
|
|
merged.forEach(d => {
|
2023-10-18 00:35:48 +08:00
|
|
|
if (!d.uploadCompleted || d.uploadInProgress) {
|
2023-03-24 20:21:49 +08:00
|
|
|
hasUploading = true;
|
|
|
|
}})
|
2021-04-21 01:21:12 +08:00
|
|
|
this.hasError = false;
|
2023-03-24 20:21:49 +08:00
|
|
|
if (hasUploading) {
|
|
|
|
return this.setState({
|
|
|
|
presentations: merged,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
return this.setState({
|
|
|
|
presentations: merged,
|
|
|
|
disableActions: false,
|
|
|
|
});
|
|
|
|
}
|
2021-04-21 01:21:12 +08:00
|
|
|
}
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
const { presentations } = this.state;
|
|
|
|
const toRemoveIndex = presentations.indexOf(item);
|
|
|
|
return this.setState({
|
|
|
|
presentations: update(presentations, {
|
|
|
|
$splice: [[toRemoveIndex, 1]],
|
|
|
|
}),
|
|
|
|
}, () => {
|
|
|
|
const { presentations: updatedPresentations, oldCurrentId } = this.state;
|
2021-08-24 05:04:16 +08:00
|
|
|
const commands = {};
|
|
|
|
|
2023-10-17 03:27:22 +08:00
|
|
|
const currentIndex = updatedPresentations.findIndex((p) => p.current);
|
|
|
|
const actualCurrentIndex = updatedPresentations.findIndex((p) => p.presentationId === oldCurrentId);
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
if (currentIndex === -1 && updatedPresentations.length > 0) {
|
|
|
|
const newCurrentIndex = actualCurrentIndex === -1 ? 0 : actualCurrentIndex;
|
|
|
|
commands[newCurrentIndex] = {
|
|
|
|
$apply: (presentation) => {
|
|
|
|
const p = presentation;
|
2023-10-17 03:27:22 +08:00
|
|
|
p.current = true;
|
2021-04-21 01:21:12 +08:00
|
|
|
return p;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-08-24 05:04:16 +08:00
|
|
|
|
|
|
|
const updatedCurrent = update(updatedPresentations, commands);
|
|
|
|
this.setState({ presentations: updatedCurrent });
|
2021-04-21 01:21:12 +08:00
|
|
|
});
|
2020-02-26 03:29:14 +08:00
|
|
|
}
|
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
handleCurrentChange(id) {
|
|
|
|
const { presentations, disableActions } = this.state;
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2023-05-01 22:01:04 +08:00
|
|
|
if (disableActions || presentations?.length === 0) return;
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2023-10-17 03:27:22 +08:00
|
|
|
const currentIndex = presentations.findIndex((p) => p.current);
|
|
|
|
const newCurrentIndex = presentations.findIndex((p) => p.presentationId === id);
|
2020-02-26 03:29:14 +08:00
|
|
|
const commands = {};
|
2021-04-21 01:21:12 +08:00
|
|
|
|
|
|
|
// we can end up without a current presentation
|
|
|
|
if (currentIndex !== -1) {
|
|
|
|
commands[currentIndex] = {
|
|
|
|
$apply: (presentation) => {
|
|
|
|
const p = presentation;
|
2023-10-17 03:27:22 +08:00
|
|
|
p.current = false;
|
2021-04-21 01:21:12 +08:00
|
|
|
return p;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
commands[newCurrentIndex] = {
|
2020-02-26 03:29:14 +08:00
|
|
|
$apply: (presentation) => {
|
|
|
|
const p = presentation;
|
2023-10-17 03:27:22 +08:00
|
|
|
if (p) {
|
|
|
|
p.current = true;
|
|
|
|
}
|
2020-02-26 03:29:14 +08:00
|
|
|
return p;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
const presentationsUpdated = update(presentations, commands);
|
|
|
|
this.setState({ presentations: presentationsUpdated });
|
2020-02-26 03:29:14 +08:00
|
|
|
}
|
|
|
|
|
2022-08-09 23:24:44 +08:00
|
|
|
handleConfirm() {
|
2020-02-26 03:29:14 +08:00
|
|
|
const {
|
2021-08-24 05:04:16 +08:00
|
|
|
handleSave,
|
|
|
|
selectedToBeNextCurrent,
|
2021-08-23 21:23:09 +08:00
|
|
|
presentations: propPresentations,
|
2023-08-22 22:53:38 +08:00
|
|
|
dispatchChangePresentationDownloadable,
|
2024-01-23 20:51:14 +08:00
|
|
|
setPresentation,
|
2020-02-26 03:29:14 +08:00
|
|
|
} = this.props;
|
|
|
|
const { disableActions, presentations } = this.state;
|
|
|
|
const presentationsToSave = presentations;
|
|
|
|
|
2023-02-23 04:16:43 +08:00
|
|
|
if (!isPresentationEnabled()) {
|
2023-02-21 20:38:44 +08:00
|
|
|
this.setState(
|
|
|
|
{ presentations: [] },
|
|
|
|
Session.set('showUploadPresentationView', false),
|
|
|
|
);
|
2023-03-10 19:30:46 +08:00
|
|
|
return null;
|
2023-02-21 20:38:44 +08:00
|
|
|
}
|
|
|
|
|
2020-02-26 03:29:14 +08:00
|
|
|
this.setState({ disableActions: true });
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
presentations.forEach((item) => {
|
2023-10-17 03:27:22 +08:00
|
|
|
if (item.uploadCompleted) {
|
2021-08-23 21:23:09 +08:00
|
|
|
const didDownloadableStateChange = propPresentations.some(
|
2023-10-17 03:27:22 +08:00
|
|
|
(p) => p.presentationId === item.presentationId && p.downloadable !== item.downloadable,
|
2021-08-23 21:23:09 +08:00
|
|
|
);
|
|
|
|
if (didDownloadableStateChange) {
|
2023-10-17 03:27:22 +08:00
|
|
|
dispatchChangePresentationDownloadable(item, item.downloadable);
|
2021-08-23 21:23:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-26 03:29:14 +08:00
|
|
|
if (!disableActions) {
|
2020-03-10 20:58:14 +08:00
|
|
|
Session.set('showUploadPresentationView', false);
|
2024-01-23 20:51:14 +08:00
|
|
|
return handleSave(presentationsToSave, true, {}, propPresentations, setPresentation)
|
2020-02-26 03:29:14 +08:00
|
|
|
.then(() => {
|
2023-10-18 00:35:48 +08:00
|
|
|
const hasError = presentations.some((p) => !!p.uploadErrorMsgKey);
|
2020-02-26 03:29:14 +08:00
|
|
|
if (!hasError) {
|
|
|
|
this.setState({
|
|
|
|
disableActions: false,
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// if there's error we don't want to close the modal
|
|
|
|
this.setState({
|
|
|
|
disableActions: true,
|
|
|
|
// preventClosing: true,
|
|
|
|
}, () => {
|
|
|
|
// if the selected current has error we revert back to the old one
|
2023-10-17 03:27:22 +08:00
|
|
|
const newCurrent = presentations.find((p) => p.current);
|
2023-10-18 00:35:48 +08:00
|
|
|
if (newCurrent.uploadErrorMsgKey) {
|
2020-03-10 23:19:14 +08:00
|
|
|
this.handleCurrentChange(selectedToBeNextCurrent);
|
2020-02-26 03:29:14 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
logger.error({
|
|
|
|
logCode: 'presentationuploader_component_save_error',
|
|
|
|
extraInfo: { error },
|
|
|
|
}, 'Presentation uploader catch error on confirm');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-03-10 20:58:14 +08:00
|
|
|
Session.set('showUploadPresentationView', false);
|
2020-02-26 03:29:14 +08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-08-18 21:57:50 +08:00
|
|
|
handleDownloadableChange(item, fileStateType, downloadable) {
|
2023-08-16 22:18:51 +08:00
|
|
|
const { dispatchChangePresentationDownloadable } = this.props;
|
2023-04-20 19:48:43 +08:00
|
|
|
|
2023-08-18 21:57:50 +08:00
|
|
|
dispatchChangePresentationDownloadable(item, downloadable, fileStateType);
|
2023-04-20 19:48:43 +08:00
|
|
|
}
|
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
handleDismiss() {
|
|
|
|
const { presentations } = this.state;
|
|
|
|
const { presentations: propPresentations } = this.props;
|
2023-02-08 04:38:50 +08:00
|
|
|
|
2023-10-17 03:27:22 +08:00
|
|
|
const ids = new Set(propPresentations.map((d) => d.presentationId));
|
2023-02-23 21:17:01 +08:00
|
|
|
|
2023-10-17 03:27:22 +08:00
|
|
|
const filteredPresentations = presentations.filter((d) => !ids.has(d.presentationId)
|
2023-10-18 00:35:48 +08:00
|
|
|
&& (d.uploadCompleted || d.totalPagesUploaded !== 0));
|
2023-10-17 03:27:22 +08:00
|
|
|
const isThereStateCurrentPres = filteredPresentations.some((p) => p.current);
|
2021-04-21 01:21:12 +08:00
|
|
|
const merged = [
|
2023-02-23 21:17:01 +08:00
|
|
|
...filteredPresentations,
|
2023-05-12 05:06:48 +08:00
|
|
|
...propPresentations.filter((p) => {
|
2023-02-23 21:17:01 +08:00
|
|
|
if (isThereStateCurrentPres) {
|
2023-10-17 03:27:22 +08:00
|
|
|
p.current = false;
|
2023-02-23 21:17:01 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}),
|
2021-04-21 01:21:12 +08:00
|
|
|
];
|
|
|
|
this.setState(
|
|
|
|
{ presentations: merged },
|
|
|
|
Session.set('showUploadPresentationView', false),
|
|
|
|
);
|
2020-02-26 03:29:14 +08:00
|
|
|
}
|
|
|
|
|
2023-08-18 21:57:50 +08:00
|
|
|
handleDownloadingOfPresentation(item, fileStateType) {
|
2023-10-20 02:56:13 +08:00
|
|
|
const { exportPresentation } = this.props;
|
2022-12-14 02:20:59 +08:00
|
|
|
|
2023-10-20 02:56:13 +08:00
|
|
|
exportPresentation(item.presentationId, fileStateType);
|
2021-04-21 01:21:12 +08:00
|
|
|
}
|
2017-09-27 03:45:33 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
getPresentationsToShow() {
|
|
|
|
const { presentations, presExporting } = this.state;
|
|
|
|
|
|
|
|
return Array.from(presExporting)
|
2023-10-17 03:27:22 +08:00
|
|
|
.map((id) => presentations.find((p) => p.presentationId === id))
|
2023-03-10 19:30:46 +08:00
|
|
|
.filter((p) => p);
|
|
|
|
}
|
|
|
|
|
|
|
|
deepMergeUpdateFileKey(id, key, value) {
|
|
|
|
const applyValue = (toUpdate) => update(toUpdate, { $merge: value });
|
|
|
|
this.updateFileKey(id, key, applyValue, '$apply');
|
|
|
|
}
|
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
updateFileKey(id, key, value, operation = '$set') {
|
|
|
|
this.setState(({ presentations }) => {
|
2023-10-17 03:27:22 +08:00
|
|
|
const fileIndex = presentations.findIndex((f) => f.presentationId === id);
|
2020-07-14 21:49:00 +08:00
|
|
|
|
2021-04-21 01:21:12 +08:00
|
|
|
return fileIndex === -1 ? false : {
|
|
|
|
presentations: update(presentations, {
|
|
|
|
[fileIndex]: {
|
|
|
|
$apply: (file) => update(file, {
|
|
|
|
[key]: {
|
|
|
|
[operation]: value,
|
|
|
|
},
|
|
|
|
}),
|
2020-07-14 21:49:00 +08:00
|
|
|
},
|
2021-04-21 01:21:12 +08:00
|
|
|
}),
|
|
|
|
};
|
2019-02-21 06:20:04 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-20 03:45:24 +08:00
|
|
|
renderExtraHint() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
fileSizeMax,
|
|
|
|
filePagesMax,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const options = {
|
2022-10-05 03:25:54 +08:00
|
|
|
0: fileSizeMax / 1000000,
|
2022-01-20 03:45:24 +08:00
|
|
|
1: filePagesMax,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2022-01-26 00:56:52 +08:00
|
|
|
<Styled.ExtraHint>
|
2022-01-20 03:45:24 +08:00
|
|
|
{intl.formatMessage(intlMessages.extraHint, options)}
|
2022-01-26 00:56:52 +08:00
|
|
|
</Styled.ExtraHint>
|
2021-04-21 01:21:12 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-29 02:42:32 +08:00
|
|
|
renderPresentationList() {
|
2017-06-07 20:28:41 +08:00
|
|
|
const { presentations } = this.state;
|
2023-08-01 04:03:29 +08:00
|
|
|
const { intl } = this.props;
|
2017-04-29 02:42:32 +08:00
|
|
|
|
2021-11-30 20:18:44 +08:00
|
|
|
let presentationsSorted = presentations;
|
|
|
|
|
|
|
|
try {
|
|
|
|
presentationsSorted = presentations
|
|
|
|
.sort((a, b) => a.uploadTimestamp - b.uploadTimestamp)
|
2023-10-17 03:27:22 +08:00
|
|
|
.sort((a, b) => a.name.localeCompare(b.name))
|
2023-10-18 00:35:48 +08:00
|
|
|
.sort((a, b) => b.totalPagesUploaded - a.totalPagesUploaded)
|
|
|
|
.sort((a, b) => b.uploadInProgress - a.uploadInProgress)
|
2021-11-30 20:18:44 +08:00
|
|
|
.sort((a, b) => {
|
2023-10-18 00:35:48 +08:00
|
|
|
const aUploadNotTriggeredYet = !a.uploadCompleted && a.totalPagesUploaded === 0;
|
|
|
|
const bUploadNotTriggeredYet = !b.uploadCompleted && b.totalPagesUploaded === 0;
|
2021-11-30 20:18:44 +08:00
|
|
|
return bUploadNotTriggeredYet - aUploadNotTriggeredYet;
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
logger.error({
|
|
|
|
logCode: 'presentationuploader_component_render_error',
|
|
|
|
extraInfo: { error },
|
|
|
|
}, 'Presentation uploader catch error on render presentation list');
|
|
|
|
}
|
2017-04-29 02:42:32 +08:00
|
|
|
|
|
|
|
return (
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.FileList>
|
|
|
|
<Styled.Table>
|
2019-05-15 03:45:12 +08:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2022-07-22 04:20:03 +08:00
|
|
|
<Styled.VisuallyHidden>
|
|
|
|
{intl.formatMessage(intlMessages.setAsCurrentPresentation)}
|
|
|
|
</Styled.VisuallyHidden>
|
|
|
|
<Styled.VisuallyHidden colSpan={2}>
|
2019-05-31 01:46:05 +08:00
|
|
|
{intl.formatMessage(intlMessages.filename)}
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.VisuallyHidden>
|
|
|
|
<Styled.VisuallyHidden>
|
|
|
|
{intl.formatMessage(intlMessages.status)}
|
|
|
|
</Styled.VisuallyHidden>
|
|
|
|
<Styled.VisuallyHidden>
|
|
|
|
{intl.formatMessage(intlMessages.options)}
|
|
|
|
</Styled.VisuallyHidden>
|
2019-05-15 03:45:12 +08:00
|
|
|
</tr>
|
2022-07-22 04:20:03 +08:00
|
|
|
<Styled.Head>
|
|
|
|
<th colSpan={4}>{intl.formatMessage(intlMessages.currentLabel)}</th>
|
2023-08-01 04:03:29 +08:00
|
|
|
<th>{intl.formatMessage(intlMessages.actionsLabel)}</th>
|
2022-07-22 04:20:03 +08:00
|
|
|
</Styled.Head>
|
2019-05-15 03:45:12 +08:00
|
|
|
</thead>
|
2017-05-04 00:36:16 +08:00
|
|
|
<tbody>
|
2023-10-17 03:27:22 +08:00
|
|
|
{unique(presentationsSorted, p => p.presentationId) .map((item) => this.renderPresentationItem(item))}
|
2017-05-04 00:36:16 +08:00
|
|
|
</tbody>
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.Table>
|
|
|
|
</Styled.FileList>
|
2017-04-29 02:42:32 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-20 03:36:00 +08:00
|
|
|
|
|
|
|
|
2022-07-26 05:56:26 +08:00
|
|
|
|
|
|
|
|
2022-12-20 02:29:36 +08:00
|
|
|
renderDownloadableWithAnnotationsHint() {
|
|
|
|
const {
|
|
|
|
intl,
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadWithAnnotations,
|
2022-12-20 02:29:36 +08:00
|
|
|
} = this.props;
|
|
|
|
|
2023-08-01 04:03:29 +08:00
|
|
|
return allowDownloadWithAnnotations ? (
|
2023-03-10 19:30:46 +08:00
|
|
|
<Styled.ExportHint>
|
|
|
|
{intl.formatMessage(intlMessages.exportHint)}
|
|
|
|
</Styled.ExportHint>
|
|
|
|
)
|
2022-12-20 02:29:36 +08:00
|
|
|
: null;
|
|
|
|
}
|
2023-03-10 19:30:46 +08:00
|
|
|
|
2017-04-29 02:42:32 +08:00
|
|
|
renderPresentationItem(item) {
|
2021-09-01 19:48:46 +08:00
|
|
|
const { disableActions } = this.state;
|
2020-02-26 03:29:14 +08:00
|
|
|
const {
|
2021-08-24 05:04:16 +08:00
|
|
|
intl,
|
|
|
|
selectedToBeNextCurrent,
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadOriginal,
|
2023-08-25 22:37:32 +08:00
|
|
|
allowDownloadConverted,
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadWithAnnotations,
|
2023-03-10 19:30:46 +08:00
|
|
|
renderPresentationItemStatus,
|
2020-02-26 03:29:14 +08:00
|
|
|
} = this.props;
|
2017-05-04 00:36:16 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const isActualCurrent = selectedToBeNextCurrent
|
2023-10-17 03:27:22 +08:00
|
|
|
? item.presentationId === selectedToBeNextCurrent
|
|
|
|
: item.current;
|
|
|
|
const isUploading = !item.uploadCompleted;
|
2023-10-18 00:35:48 +08:00
|
|
|
const uploadInProgress = item.uploadInProgress;
|
|
|
|
const hasError = !!item.uploadErrorMsgKey;
|
|
|
|
const isProcessing = (isUploading || uploadInProgress) && !hasError;
|
2017-11-28 20:26:00 +08:00
|
|
|
|
2021-09-01 19:48:46 +08:00
|
|
|
if (hasError) {
|
2020-03-12 21:56:12 +08:00
|
|
|
this.hasError = true;
|
2020-02-26 03:29:14 +08:00
|
|
|
}
|
|
|
|
|
2022-07-20 03:36:00 +08:00
|
|
|
const { animations } = Settings.application;
|
2017-05-04 04:51:17 +08:00
|
|
|
|
2023-10-20 20:52:00 +08:00
|
|
|
const { removable, downloadable } = item;
|
2019-05-09 05:47:00 +08:00
|
|
|
|
2023-10-20 20:52:00 +08:00
|
|
|
const isExporting = item?.exportToChatStatus === 'RUNNING';
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2023-05-03 19:50:36 +08:00
|
|
|
const shouldDisableExportButton = (isExporting
|
2023-10-18 00:35:48 +08:00
|
|
|
|| item.uploadInProgress
|
2022-07-20 03:36:00 +08:00
|
|
|
|| hasError
|
2023-10-18 00:35:48 +08:00
|
|
|
|| disableActions) && item.uploadInProgress;
|
2022-07-20 03:36:00 +08:00
|
|
|
|
|
|
|
const formattedDownloadLabel = isExporting
|
|
|
|
? intl.formatMessage(intlMessages.exporting)
|
|
|
|
: intl.formatMessage(intlMessages.export);
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2023-10-17 03:27:22 +08:00
|
|
|
const formattedDownloadAriaLabel = `${formattedDownloadLabel} ${item.name}`;
|
2022-02-03 22:37:14 +08:00
|
|
|
|
2017-04-29 02:42:32 +08:00
|
|
|
return (
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.PresentationItem
|
2023-10-17 03:27:22 +08:00
|
|
|
key={item.presentationId}
|
|
|
|
isNew={item.presentationId.indexOf(item.name) !== -1}
|
2021-11-08 21:57:55 +08:00
|
|
|
uploading={isUploading}
|
2023-10-18 00:35:48 +08:00
|
|
|
uploadInProgress={uploadInProgress}
|
2021-11-08 21:57:55 +08:00
|
|
|
error={hasError}
|
|
|
|
animated={isProcessing}
|
|
|
|
animations={animations}
|
2017-04-29 02:42:32 +08:00
|
|
|
>
|
2022-07-20 03:36:00 +08:00
|
|
|
<Styled.SetCurrentAction>
|
2022-12-15 04:03:23 +08:00
|
|
|
<Radio
|
2022-07-20 03:36:00 +08:00
|
|
|
animations={animations}
|
2023-10-17 03:27:22 +08:00
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.setAsCurrentPresentation)} ${item.name}`}
|
|
|
|
checked={item.current}
|
|
|
|
keyValue={item.presentationId}
|
|
|
|
onChange={() => this.handleCurrentChange(item.presentationId)}
|
2022-07-20 03:36:00 +08:00
|
|
|
disabled={disableActions || hasError}
|
|
|
|
/>
|
|
|
|
</Styled.SetCurrentAction>
|
|
|
|
<Styled.TableItemName colSpan={!isActualCurrent ? 2 : 0}>
|
2023-10-17 03:27:22 +08:00
|
|
|
<span>{item.name}</span>
|
2022-07-20 03:36:00 +08:00
|
|
|
</Styled.TableItemName>
|
2017-12-05 00:10:37 +08:00
|
|
|
{
|
2018-12-06 01:42:31 +08:00
|
|
|
isActualCurrent
|
|
|
|
? (
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.TableItemCurrent>
|
|
|
|
<Styled.CurrentLabel>
|
2023-05-01 22:01:04 +08:00
|
|
|
{intl.formatMessage(intlMessages.currentBadge)}
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.CurrentLabel>
|
|
|
|
</Styled.TableItemCurrent>
|
2018-12-06 01:42:31 +08:00
|
|
|
)
|
|
|
|
: null
|
2017-12-05 00:10:37 +08:00
|
|
|
}
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.TableItemStatus colSpan={hasError ? 2 : 0}>
|
2023-03-10 19:30:46 +08:00
|
|
|
{renderPresentationItemStatus(item, intl)}
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.TableItemStatus>
|
2023-04-14 22:04:24 +08:00
|
|
|
{
|
|
|
|
hasError ? null : (
|
2023-08-01 04:03:29 +08:00
|
|
|
<Styled.TableItemActions notDownloadable={!allowDownloadOriginal}>
|
2023-08-25 22:37:32 +08:00
|
|
|
{allowDownloadOriginal || allowDownloadWithAnnotations || allowDownloadConverted ? (
|
2023-05-04 19:48:32 +08:00
|
|
|
<PresentationDownloadDropdown
|
2022-07-20 03:36:00 +08:00
|
|
|
disabled={shouldDisableExportButton}
|
2023-05-04 19:48:32 +08:00
|
|
|
data-test="exportPresentation"
|
2022-07-20 03:36:00 +08:00
|
|
|
aria-label={formattedDownloadAriaLabel}
|
|
|
|
color="primary"
|
2023-10-17 03:27:22 +08:00
|
|
|
isDownloadable={downloadable}
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadOriginal={allowDownloadOriginal}
|
2023-08-25 22:37:32 +08:00
|
|
|
allowDownloadConverted={allowDownloadConverted}
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadWithAnnotations={allowDownloadWithAnnotations}
|
2023-08-16 22:18:51 +08:00
|
|
|
handleDownloadableChange={this.handleDownloadableChange}
|
2023-04-20 19:48:43 +08:00
|
|
|
item={item}
|
2023-05-03 19:50:36 +08:00
|
|
|
closeModal={() => Session.set('showUploadPresentationView', false)}
|
2023-08-18 21:57:50 +08:00
|
|
|
handleDownloadingOfPresentation={(fileStateType) => this
|
|
|
|
.handleDownloadingOfPresentation(item, fileStateType)}
|
2021-09-18 04:55:31 +08:00
|
|
|
/>
|
2022-07-20 03:36:00 +08:00
|
|
|
) : null}
|
2023-10-20 20:52:00 +08:00
|
|
|
{removable ? (
|
2022-02-03 23:03:26 +08:00
|
|
|
<Styled.RemoveButton
|
|
|
|
disabled={disableActions}
|
|
|
|
label={intl.formatMessage(intlMessages.removePresentation)}
|
|
|
|
data-test="removePresentation"
|
2023-10-17 03:27:22 +08:00
|
|
|
aria-label={`${intl.formatMessage(intlMessages.removePresentation)} ${item.name}`}
|
2022-02-03 23:03:26 +08:00
|
|
|
size="sm"
|
|
|
|
icon="delete"
|
|
|
|
hideLabel
|
|
|
|
onClick={() => this.handleRemove(item)}
|
|
|
|
animations={animations}
|
2022-02-03 22:37:14 +08:00
|
|
|
/>
|
2023-03-10 19:30:46 +08:00
|
|
|
) : null}
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.TableItemActions>
|
2017-11-28 20:26:00 +08:00
|
|
|
)}
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.PresentationItem>
|
2017-04-29 02:42:32 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-02-26 03:29:14 +08:00
|
|
|
renderDropzone() {
|
2018-12-03 14:10:50 +08:00
|
|
|
const {
|
|
|
|
intl,
|
2020-02-26 03:29:14 +08:00
|
|
|
fileValidMimeTypes,
|
2018-12-03 14:10:50 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const { disableActions } = this.state;
|
|
|
|
|
2020-03-12 21:56:12 +08:00
|
|
|
if (disableActions && !this.hasError) return null;
|
2018-12-03 14:10:50 +08:00
|
|
|
|
2020-03-12 21:56:12 +08:00
|
|
|
return this.hasError ? (
|
2020-02-26 03:29:14 +08:00
|
|
|
<div>
|
|
|
|
<Button
|
|
|
|
color="danger"
|
|
|
|
onClick={() => this.handleRemove(null, true)}
|
|
|
|
label={intl.formatMessage(intlMessages.clearErrors)}
|
|
|
|
aria-describedby="clearErrorDesc"
|
|
|
|
/>
|
|
|
|
<div id="clearErrorDesc" style={{ display: 'none' }}>
|
|
|
|
{intl.formatMessage(intlMessages.clearErrorsDesc)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
// Until the Dropzone package has fixed the mime type hover validation, the rejectClassName
|
|
|
|
// prop is being remove to prevent the error styles from being applied to valid file types.
|
|
|
|
// Error handling is being done in the onDrop prop.
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.UploaderDropzone
|
2018-12-03 14:10:50 +08:00
|
|
|
multiple
|
2023-03-10 19:30:46 +08:00
|
|
|
activeClassName="dropzoneActive"
|
2021-04-21 01:21:12 +08:00
|
|
|
accept={fileValidMimeTypes.map((fileValid) => fileValid.extension)}
|
2020-02-26 03:29:14 +08:00
|
|
|
disablepreview="true"
|
2023-02-24 00:52:51 +08:00
|
|
|
onDrop={(files, files2) => this.handleFiledrop(files, files2, this, intl, intlMessages)}
|
2018-12-03 14:10:50 +08:00
|
|
|
>
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.DropzoneIcon iconName="upload" />
|
|
|
|
<Styled.DropzoneMessage>
|
2020-02-26 03:29:14 +08:00
|
|
|
{intl.formatMessage(intlMessages.dropzoneLabel)}
|
2019-08-30 20:48:59 +08:00
|
|
|
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.DropzoneLink>
|
2020-02-26 03:29:14 +08:00
|
|
|
{intl.formatMessage(intlMessages.browseFilesLabel)}
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.DropzoneLink>
|
|
|
|
</Styled.DropzoneMessage>
|
|
|
|
</Styled.UploaderDropzone>
|
2018-12-03 14:10:50 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-06-25 00:47:17 +08:00
|
|
|
renderExternalUpload() {
|
|
|
|
const { externalUploadData, intl } = this.props;
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const {
|
|
|
|
presentationUploadExternalDescription, presentationUploadExternalUrl,
|
|
|
|
} = externalUploadData;
|
2022-06-25 00:47:17 +08:00
|
|
|
|
2022-09-12 22:04:13 +08:00
|
|
|
if (!presentationUploadExternalDescription || !presentationUploadExternalUrl) return null;
|
2022-06-25 00:47:17 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Styled.ExternalUpload>
|
|
|
|
<div>
|
|
|
|
<Styled.ExternalUploadTitle>
|
|
|
|
{intl.formatMessage(intlMessages.externalUploadTitle)}
|
|
|
|
</Styled.ExternalUploadTitle>
|
|
|
|
|
2022-09-12 22:04:13 +08:00
|
|
|
<p>{presentationUploadExternalDescription}</p>
|
2022-06-25 00:47:17 +08:00
|
|
|
</div>
|
|
|
|
<Styled.ExternalUploadButton
|
|
|
|
color="default"
|
2022-09-12 22:04:13 +08:00
|
|
|
onClick={() => window.open(`${presentationUploadExternalUrl}`)}
|
2022-06-25 00:47:17 +08:00
|
|
|
label={intl.formatMessage(intlMessages.externalUploadLabel)}
|
|
|
|
aria-describedby={intl.formatMessage(intlMessages.externalUploadLabel)}
|
2022-09-03 03:07:21 +08:00
|
|
|
/>
|
2022-06-25 00:47:17 +08:00
|
|
|
</Styled.ExternalUpload>
|
2023-03-10 19:30:46 +08:00
|
|
|
);
|
2022-06-25 00:47:17 +08:00
|
|
|
}
|
|
|
|
|
2020-02-26 03:29:14 +08:00
|
|
|
renderPicDropzone() {
|
2017-05-04 00:36:16 +08:00
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
} = this.props;
|
2017-04-29 02:42:32 +08:00
|
|
|
|
2017-05-06 04:17:38 +08:00
|
|
|
const { disableActions } = this.state;
|
|
|
|
|
2020-03-12 21:56:12 +08:00
|
|
|
if (disableActions && !this.hasError) return null;
|
2017-05-04 04:51:17 +08:00
|
|
|
|
2020-03-12 21:56:12 +08:00
|
|
|
return this.hasError ? (
|
2020-02-26 03:29:14 +08:00
|
|
|
<div>
|
|
|
|
<Button
|
|
|
|
color="danger"
|
|
|
|
onClick={() => this.handleRemove(null, true)}
|
|
|
|
label={intl.formatMessage(intlMessages.clearErrors)}
|
|
|
|
aria-describedby="clearErrorDesc"
|
|
|
|
/>
|
|
|
|
<div id="clearErrorDesc" style={{ display: 'none' }}>
|
|
|
|
{intl.formatMessage(intlMessages.clearErrorsDesc)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.UploaderDropzone
|
2017-09-08 02:18:14 +08:00
|
|
|
multiple
|
2020-02-26 03:29:14 +08:00
|
|
|
accept="image/*"
|
2018-12-06 01:42:31 +08:00
|
|
|
disablepreview="true"
|
2020-07-18 03:13:47 +08:00
|
|
|
data-test="fileUploadDropZone"
|
2023-02-24 00:52:51 +08:00
|
|
|
onDrop={(files, files2) => this.handleFiledrop(files, files2, this, intl, intlMessages)}
|
2017-04-29 02:42:32 +08:00
|
|
|
>
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.DropzoneIcon iconName="upload" />
|
|
|
|
<Styled.DropzoneMessage>
|
2020-02-26 03:29:14 +08:00
|
|
|
{intl.formatMessage(intlMessages.dropzoneImagesLabel)}
|
2019-08-30 20:48:59 +08:00
|
|
|
|
2021-11-08 21:57:55 +08:00
|
|
|
<Styled.DropzoneLink>
|
2020-02-26 03:29:14 +08:00
|
|
|
{intl.formatMessage(intlMessages.browseImagesLabel)}
|
2021-11-08 21:57:55 +08:00
|
|
|
</Styled.DropzoneLink>
|
|
|
|
</Styled.DropzoneMessage>
|
|
|
|
</Styled.UploaderDropzone>
|
2017-04-29 02:42:32 +08:00
|
|
|
);
|
|
|
|
}
|
2017-06-07 20:28:41 +08:00
|
|
|
|
|
|
|
render() {
|
2019-05-29 05:18:49 +08:00
|
|
|
const {
|
2022-01-20 03:45:24 +08:00
|
|
|
isOpen,
|
|
|
|
isPresenter,
|
|
|
|
intl,
|
|
|
|
fileUploadConstraintsHint,
|
2020-02-26 03:29:14 +08:00
|
|
|
} = this.props;
|
2020-03-10 20:58:14 +08:00
|
|
|
if (!isPresenter) return null;
|
2020-02-26 03:29:14 +08:00
|
|
|
const { presentations, disableActions } = this.state;
|
|
|
|
|
|
|
|
let hasNewUpload = false;
|
2019-05-25 03:51:50 +08:00
|
|
|
|
2022-04-08 01:06:51 +08:00
|
|
|
presentations.forEach((item) => {
|
2023-10-18 00:35:48 +08:00
|
|
|
if (item?.presentationId.indexOf(item.name) !== -1 && item.totalPagesUploaded === 0) hasNewUpload = true;
|
2019-05-25 03:51:50 +08:00
|
|
|
});
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{isOpen
|
|
|
|
? (
|
|
|
|
<Styled.UploaderModal id="upload-modal">
|
|
|
|
<Styled.ModalInner>
|
|
|
|
<Styled.ModalHeader>
|
|
|
|
<Styled.Title>{intl.formatMessage(intlMessages.title)}</Styled.Title>
|
|
|
|
<Styled.ActionWrapper>
|
|
|
|
<Styled.DismissButton
|
|
|
|
color="secondary"
|
|
|
|
onClick={this.handleDismiss}
|
|
|
|
label={intl.formatMessage(intlMessages.dismissLabel)}
|
|
|
|
aria-describedby={intl.formatMessage(intlMessages.dismissDesc)}
|
|
|
|
/>
|
|
|
|
<Styled.ConfirmButton
|
|
|
|
data-test="confirmManagePresentation"
|
|
|
|
color="primary"
|
|
|
|
onClick={() => this.handleConfirm()}
|
|
|
|
disabled={disableActions}
|
|
|
|
label={hasNewUpload
|
|
|
|
? intl.formatMessage(intlMessages.uploadLabel)
|
|
|
|
: intl.formatMessage(intlMessages.confirmLabel)}
|
|
|
|
/>
|
|
|
|
</Styled.ActionWrapper>
|
|
|
|
</Styled.ModalHeader>
|
|
|
|
|
|
|
|
<Styled.ModalHint>
|
|
|
|
{`${intl.formatMessage(intlMessages.message)}`}
|
|
|
|
{fileUploadConstraintsHint ? this.renderExtraHint() : null}
|
|
|
|
</Styled.ModalHint>
|
|
|
|
{this.renderPresentationList()}
|
|
|
|
{this.renderDownloadableWithAnnotationsHint()}
|
|
|
|
{isMobile ? this.renderPicDropzone() : null}
|
|
|
|
{this.renderDropzone()}
|
|
|
|
{this.renderExternalUpload()}
|
|
|
|
</Styled.ModalInner>
|
|
|
|
</Styled.UploaderModal>
|
|
|
|
)
|
|
|
|
: null}
|
|
|
|
</>
|
|
|
|
);
|
2017-06-07 20:28:41 +08:00
|
|
|
}
|
|
|
|
}
|
2017-04-29 02:42:32 +08:00
|
|
|
|
2017-09-23 04:45:31 +08:00
|
|
|
PresentationUploader.propTypes = propTypes;
|
|
|
|
PresentationUploader.defaultProps = defaultProps;
|
|
|
|
|
2020-03-10 20:58:14 +08:00
|
|
|
export default injectIntl(PresentationUploader);
|