2023-11-30 19:08:16 +08:00
|
|
|
import React from 'react';
|
2020-02-26 03:29:14 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2023-10-20 02:56:13 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2022-02-15 22:11:03 +08:00
|
|
|
import ErrorBoundary from '/imports/ui/components/common/error-boundary/component';
|
2022-02-15 22:29:38 +08:00
|
|
|
import FallbackModal from '/imports/ui/components/common/fallback-errors/fallback-modal/component';
|
2017-05-04 00:36:16 +08:00
|
|
|
import Service from './service';
|
2022-09-23 23:24:39 +08:00
|
|
|
import PresUploaderToast from '/imports/ui/components/presentation/presentation-toast/presentation-uploader-toast/component';
|
2017-05-04 00:36:16 +08:00
|
|
|
import PresentationUploader from './component';
|
2023-08-01 04:03:29 +08:00
|
|
|
import {
|
|
|
|
isDownloadPresentationWithAnnotationsEnabled,
|
2023-08-25 20:27:01 +08:00
|
|
|
isDownloadPresentationOriginalFileEnabled,
|
2023-08-25 22:37:32 +08:00
|
|
|
isDownloadPresentationConvertedToPdfEnabled,
|
2023-08-01 04:03:29 +08:00
|
|
|
isPresentationEnabled,
|
|
|
|
} from '/imports/ui/services/features';
|
2023-10-17 03:27:22 +08:00
|
|
|
import { useSubscription } from '@apollo/client';
|
|
|
|
import {
|
|
|
|
PRESENTATIONS_SUBSCRIPTION,
|
|
|
|
} from '/imports/ui/components/whiteboard/queries';
|
2023-11-30 19:08:16 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2020-03-10 20:58:14 +08:00
|
|
|
const PRESENTATION_CONFIG = Meteor.settings.public.presentation;
|
2017-05-04 00:36:16 +08:00
|
|
|
|
2021-11-23 22:12:00 +08:00
|
|
|
const PresentationUploaderContainer = (props) => {
|
2023-11-30 19:08:16 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
presenter: user.presenter,
|
|
|
|
}));
|
|
|
|
const userIsPresenter = currentUserData?.presenter;
|
2021-11-23 22:12:00 +08:00
|
|
|
|
2023-10-17 03:27:22 +08:00
|
|
|
const { data: presentationData } = useSubscription(PRESENTATIONS_SUBSCRIPTION);
|
|
|
|
const presentations = presentationData?.pres_presentation || [];
|
|
|
|
const currentPresentation = presentations.find((p) => p.current)?.presentationId || '';
|
|
|
|
|
2023-10-20 02:56:13 +08:00
|
|
|
const exportPresentation = (presentationId, fileStateType) => {
|
|
|
|
makeCall('exportPresentation', presentationId, fileStateType);
|
|
|
|
};
|
|
|
|
|
2021-11-23 22:12:00 +08:00
|
|
|
return userIsPresenter && (
|
2023-03-24 21:07:56 +08:00
|
|
|
<ErrorBoundary Fallback={FallbackModal}>
|
2023-10-17 03:27:22 +08:00
|
|
|
<PresentationUploader
|
|
|
|
isPresenter={userIsPresenter}
|
|
|
|
presentations={presentations}
|
|
|
|
currentPresentation={currentPresentation}
|
2023-10-20 02:56:13 +08:00
|
|
|
exportPresentation={exportPresentation}
|
2023-10-17 03:27:22 +08:00
|
|
|
{...props}
|
|
|
|
/>
|
2021-06-12 03:33:15 +08:00
|
|
|
</ErrorBoundary>
|
2021-11-23 22:12:00 +08:00
|
|
|
);
|
|
|
|
};
|
2017-05-04 00:36:16 +08:00
|
|
|
|
2021-06-14 20:55:18 +08:00
|
|
|
export default withTracker(() => {
|
2019-12-24 22:48:44 +08:00
|
|
|
const {
|
2021-11-23 22:12:00 +08:00
|
|
|
dispatchDisableDownloadable,
|
|
|
|
dispatchEnableDownloadable,
|
2023-08-16 22:18:51 +08:00
|
|
|
dispatchChangePresentationDownloadable,
|
2021-11-23 22:12:00 +08:00
|
|
|
} = Service;
|
2023-02-23 04:16:43 +08:00
|
|
|
const isOpen = isPresentationEnabled() && (Session.get('showUploadPresentationView') || false);
|
2017-05-04 00:36:16 +08:00
|
|
|
|
|
|
|
return {
|
2022-01-20 03:45:24 +08:00
|
|
|
fileUploadConstraintsHint: PRESENTATION_CONFIG.fileUploadConstraintsHint,
|
|
|
|
fileSizeMax: PRESENTATION_CONFIG.mirroredFromBBBCore.uploadSizeMax,
|
|
|
|
filePagesMax: PRESENTATION_CONFIG.mirroredFromBBBCore.uploadPagesMax,
|
2017-05-04 00:36:16 +08:00
|
|
|
fileValidMimeTypes: PRESENTATION_CONFIG.uploadValidMimeTypes,
|
2023-08-25 20:27:01 +08:00
|
|
|
allowDownloadOriginal: isDownloadPresentationOriginalFileEnabled(),
|
2023-08-25 22:37:32 +08:00
|
|
|
allowDownloadConverted: isDownloadPresentationConvertedToPdfEnabled(),
|
2023-08-01 04:03:29 +08:00
|
|
|
allowDownloadWithAnnotations: isDownloadPresentationWithAnnotationsEnabled(),
|
2022-08-08 19:50:52 +08:00
|
|
|
handleSave: Service.handleSavePresentation,
|
2022-09-23 23:24:39 +08:00
|
|
|
handleDismissToast: PresUploaderToast.handleDismissToast,
|
2022-07-22 21:06:32 +08:00
|
|
|
renderToastList: Service.renderToastList,
|
2022-09-23 23:24:39 +08:00
|
|
|
renderPresentationItemStatus: PresUploaderToast.renderPresentationItemStatus,
|
2019-02-21 06:20:04 +08:00
|
|
|
dispatchDisableDownloadable,
|
|
|
|
dispatchEnableDownloadable,
|
2023-08-16 22:18:51 +08:00
|
|
|
dispatchChangePresentationDownloadable,
|
2023-02-21 20:38:44 +08:00
|
|
|
isOpen,
|
2020-03-10 23:19:14 +08:00
|
|
|
selectedToBeNextCurrent: Session.get('selectedToBeNextCurrent') || null,
|
2022-06-25 00:47:17 +08:00
|
|
|
externalUploadData: Service.getExternalUploadData(),
|
2022-12-08 22:20:17 +08:00
|
|
|
handleFiledrop: Service.handleFiledrop,
|
2017-05-04 00:36:16 +08:00
|
|
|
};
|
2021-06-14 20:55:18 +08:00
|
|
|
})(PresentationUploaderContainer);
|