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

88 lines
3.5 KiB
React
Raw Normal View History

import React from 'react';
2020-02-26 03:29:14 +08:00
import { Meteor } from 'meteor/meteor';
import { withTracker } from 'meteor/react-meteor-data';
import ErrorBoundary from '/imports/ui/components/common/error-boundary/component';
import FallbackModal from '/imports/ui/components/common/fallback-errors/fallback-modal/component';
2024-01-20 22:43:34 +08:00
import { useSubscription, useMutation } from '@apollo/client';
2017-05-04 00:36:16 +08:00
import Service from './service';
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';
import {
isDownloadPresentationWithAnnotationsEnabled,
isDownloadPresentationOriginalFileEnabled,
isDownloadPresentationConvertedToPdfEnabled,
isPresentationEnabled,
} from '/imports/ui/services/features';
import {
PRESENTATIONS_SUBSCRIPTION,
} from '/imports/ui/components/whiteboard/queries';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
2024-01-20 22:43:34 +08:00
import { PRESENTATION_SET_DOWNLOADABLE } from '../mutations';
2020-02-26 03:29:14 +08:00
const PRESENTATION_CONFIG = Meteor.settings.public.presentation;
2017-05-04 00:36:16 +08:00
const PresentationUploaderContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
}));
const userIsPresenter = currentUserData?.presenter;
const { data: presentationData } = useSubscription(PRESENTATIONS_SUBSCRIPTION);
const presentations = presentationData?.pres_presentation || [];
const currentPresentation = presentations.find((p) => p.current)?.presentationId || '';
2024-01-20 22:43:34 +08:00
const [presentationSetDownloadable] = useMutation(PRESENTATION_SET_DOWNLOADABLE);
2023-10-20 02:56:13 +08:00
const exportPresentation = (presentationId, fileStateType) => {
2024-01-20 22:43:34 +08:00
presentationSetDownloadable({
variables: {
presentationId,
downloadable: true,
fileStateType,
},
});
2023-10-20 02:56:13 +08:00
};
return userIsPresenter && (
<ErrorBoundary Fallback={FallbackModal}>
<PresentationUploader
isPresenter={userIsPresenter}
presentations={presentations}
currentPresentation={currentPresentation}
2023-10-20 02:56:13 +08:00
exportPresentation={exportPresentation}
{...props}
/>
</ErrorBoundary>
);
};
2017-05-04 00:36:16 +08:00
2021-06-14 20:55:18 +08:00
export default withTracker(() => {
const {
dispatchDisableDownloadable,
dispatchEnableDownloadable,
dispatchChangePresentationDownloadable,
} = Service;
const isOpen = isPresentationEnabled() && (Session.get('showUploadPresentationView') || false);
2017-05-04 00:36:16 +08:00
return {
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,
allowDownloadOriginal: isDownloadPresentationOriginalFileEnabled(),
allowDownloadConverted: isDownloadPresentationConvertedToPdfEnabled(),
allowDownloadWithAnnotations: isDownloadPresentationWithAnnotationsEnabled(),
handleSave: Service.handleSavePresentation,
handleDismissToast: PresUploaderToast.handleDismissToast,
renderToastList: Service.renderToastList,
renderPresentationItemStatus: PresUploaderToast.renderPresentationItemStatus,
dispatchDisableDownloadable,
dispatchEnableDownloadable,
dispatchChangePresentationDownloadable,
isOpen,
selectedToBeNextCurrent: Session.get('selectedToBeNextCurrent') || null,
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);