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

113 lines
4.7 KiB
React
Raw Normal View History

import React from 'react';
import ErrorBoundary from '/imports/ui/components/common/error-boundary/component';
import FallbackModal from '/imports/ui/components/common/fallback-errors/fallback-modal/component';
import { 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 {
useIsPresentationEnabled,
useIsDownloadPresentationOriginalFileEnabled,
useIsDownloadPresentationConvertedToPdfEnabled,
useIsDownloadPresentationWithAnnotationsEnabled,
} from '/imports/ui/services/features';
import {
PRESENTATIONS_SUBSCRIPTION,
} from '/imports/ui/components/whiteboard/queries';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import {
PRESENTATION_SET_DOWNLOADABLE,
PRESENTATION_EXPORT,
PRESENTATION_SET_CURRENT,
PRESENTATION_REMOVE,
} from '../mutations';
import { useStorageKey } from '/imports/ui/services/storage/hooks';
import useDeduplicatedSubscription from '/imports/ui/core/hooks/useDeduplicatedSubscription';
2020-02-26 03:29:14 +08:00
const PresentationUploaderContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
}));
const userIsPresenter = currentUserData?.presenter;
const { data: presentationData } = useDeduplicatedSubscription(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);
const [presentationExport] = useMutation(PRESENTATION_EXPORT);
2024-01-23 20:51:14 +08:00
const [presentationSetCurrent] = useMutation(PRESENTATION_SET_CURRENT);
2024-01-23 21:55:40 +08:00
const [presentationRemove] = useMutation(PRESENTATION_REMOVE);
2024-01-20 22:43:34 +08:00
2023-10-20 02:56:13 +08:00
const exportPresentation = (presentationId, fileStateType) => {
presentationExport({
2024-01-20 22:43:34 +08:00
variables: {
presentationId,
fileStateType,
},
});
2023-10-20 02:56:13 +08:00
};
const dispatchChangePresentationDownloadable = (presentationId, downloadable, fileStateType) => {
presentationSetDownloadable({
variables: {
presentationId,
downloadable,
fileStateType,
},
});
};
2024-01-23 20:51:14 +08:00
const setPresentation = (presentationId) => {
presentationSetCurrent({ variables: { presentationId } });
};
2024-01-23 21:55:40 +08:00
const removePresentation = (presentationId) => {
presentationRemove({ variables: { presentationId } });
};
const presentationEnabled = useIsPresentationEnabled();
const allowDownloadOriginal = useIsDownloadPresentationOriginalFileEnabled();
const allowDownloadConverted = useIsDownloadPresentationConvertedToPdfEnabled();
const allowDownloadWithAnnotations = useIsDownloadPresentationWithAnnotationsEnabled();
const externalUploadData = Service.useExternalUploadData();
const PRESENTATION_CONFIG = window.meetingClientSettings.public.presentation;
const isOpen = (useStorageKey('showUploadPresentationView') || false) && presentationEnabled;
const selectedToBeNextCurrent = useStorageKey('selectedToBeNextCurrent') || null;
return userIsPresenter && (
<ErrorBoundary Fallback={FallbackModal}>
<PresentationUploader
isPresenter={userIsPresenter}
presentations={presentations}
currentPresentation={currentPresentation}
2023-10-20 02:56:13 +08:00
exportPresentation={exportPresentation}
dispatchChangePresentationDownloadable={dispatchChangePresentationDownloadable}
2024-01-23 20:51:14 +08:00
setPresentation={setPresentation}
2024-01-23 21:55:40 +08:00
removePresentation={removePresentation}
isOpen={isOpen}
selectedToBeNextCurrent={selectedToBeNextCurrent}
fileUploadConstraintsHint={PRESENTATION_CONFIG.fileUploadConstraintsHint}
fileSizeMax={PRESENTATION_CONFIG.mirroredFromBBBCore.uploadSizeMax}
filePagesMax={PRESENTATION_CONFIG.mirroredFromBBBCore.uploadPagesMax}
fileValidMimeTypes={PRESENTATION_CONFIG.uploadValidMimeTypes}
allowDownloadOriginal={allowDownloadOriginal}
allowDownloadConverted={allowDownloadConverted}
allowDownloadWithAnnotations={allowDownloadWithAnnotations}
presentationEnabled={presentationEnabled}
externalUploadData={externalUploadData}
handleSave={Service.handleSavePresentation}
handleDismissToast={PresUploaderToast.handleDismissToast}
renderToastList={Service.renderToastList}
renderPresentationItemStatus={PresUploaderToast.renderPresentationItemStatus}
handleFiledrop={Service.handleFiledrop}
dispatchDisableDownloadable={Service.dispatchDisableDownloadable}
dispatchEnableDownloadable={Service.dispatchEnableDownloadable}
{...props}
/>
</ErrorBoundary>
);
};
2017-05-04 00:36:16 +08:00
export default PresentationUploaderContainer;