2023-03-03 03:58:08 +08:00
|
|
|
import React from 'react';
|
2018-12-15 04:16:15 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2022-06-17 03:59:01 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2024-09-09 19:54:46 +08:00
|
|
|
import { ACTIONS, PANELS } from '/imports/ui/components/layout/enums';
|
|
|
|
import {
|
|
|
|
layoutSelectInput,
|
|
|
|
} from '/imports/ui/components/layout/context';
|
|
|
|
import { useStorageKey } from '/imports/ui/services/storage/hooks';
|
2023-04-11 03:25:19 +08:00
|
|
|
|
2018-12-15 04:16:15 +08:00
|
|
|
const propTypes = {
|
2021-08-09 22:24:02 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2022-02-11 22:30:35 +08:00
|
|
|
setPresentationIsOpen: PropTypes.func.isRequired,
|
2018-12-15 04:16:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
2020-08-19 04:35:56 +08:00
|
|
|
minimizePresentationLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.minimizePresentationLabel',
|
|
|
|
description: '',
|
|
|
|
},
|
|
|
|
minimizePresentationDesc: {
|
2021-09-28 03:43:30 +08:00
|
|
|
id: 'app.actionsBar.actionsDropdown.restorePresentationDesc',
|
2020-08-19 04:35:56 +08:00
|
|
|
description: '',
|
|
|
|
},
|
2018-12-15 04:16:15 +08:00
|
|
|
restorePresentationLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.restorePresentationLabel',
|
|
|
|
description: 'Restore Presentation option label',
|
|
|
|
},
|
|
|
|
restorePresentationDesc: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.restorePresentationDesc',
|
|
|
|
description: 'button to restore presentation after it has been closed',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-07-17 02:42:16 +08:00
|
|
|
const PresentationOptionsContainer = ({
|
|
|
|
intl,
|
2022-02-11 22:30:35 +08:00
|
|
|
presentationIsOpen,
|
|
|
|
setPresentationIsOpen,
|
2021-08-09 22:24:02 +08:00
|
|
|
layoutContextDispatch,
|
2023-03-14 00:09:31 +08:00
|
|
|
hasPresentation,
|
2021-09-25 02:37:55 +08:00
|
|
|
hasExternalVideo,
|
|
|
|
hasScreenshare,
|
2023-02-21 23:44:12 +08:00
|
|
|
hasPinnedSharedNotes,
|
2023-03-28 05:40:08 +08:00
|
|
|
hasGenericContent,
|
|
|
|
hasCameraAsContent,
|
2021-09-25 02:37:55 +08:00
|
|
|
}) => {
|
2021-09-28 03:13:06 +08:00
|
|
|
let buttonType = 'presentation';
|
2021-09-25 02:37:55 +08:00
|
|
|
if (hasExternalVideo) {
|
2021-09-28 03:13:06 +08:00
|
|
|
// hack until we have an external-video icon
|
2021-10-02 04:11:02 +08:00
|
|
|
buttonType = 'external-video';
|
2021-09-25 02:37:55 +08:00
|
|
|
} else if (hasScreenshare) {
|
|
|
|
buttonType = 'desktop';
|
2023-03-28 05:40:08 +08:00
|
|
|
} else if (hasCameraAsContent) {
|
|
|
|
buttonType = 'video';
|
2021-09-25 02:37:55 +08:00
|
|
|
}
|
|
|
|
|
2023-04-11 03:25:19 +08:00
|
|
|
const isThereCurrentPresentation = hasExternalVideo || hasScreenshare
|
2023-03-28 05:40:08 +08:00
|
|
|
|| hasPresentation || hasPinnedSharedNotes
|
|
|
|
|| hasGenericContent || hasCameraAsContent;
|
2024-08-08 04:57:09 +08:00
|
|
|
const onlyPresentation = hasPresentation
|
|
|
|
&& !hasExternalVideo && !hasScreenshare
|
|
|
|
&& !hasPinnedSharedNotes && !hasGenericContent
|
|
|
|
&& !hasCameraAsContent;
|
2024-09-09 19:54:46 +08:00
|
|
|
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
|
|
|
|
const isChatOpen = sidebarContent.sidebarContentPanel === PANELS.CHAT;
|
|
|
|
const PUBLIC_CHAT_ID = window.meetingClientSettings.public.chat.public_group_id;
|
|
|
|
const isGridLayout = useStorageKey('isGridEnabled');
|
2021-09-25 02:37:55 +08:00
|
|
|
return (
|
2022-06-17 03:59:01 +08:00
|
|
|
<Button
|
2022-02-11 22:30:35 +08:00
|
|
|
icon={`${buttonType}${!presentationIsOpen ? '_off' : ''}`}
|
|
|
|
label={intl.formatMessage(!presentationIsOpen ? intlMessages.restorePresentationLabel : intlMessages.minimizePresentationLabel)}
|
|
|
|
aria-label={intl.formatMessage(!presentationIsOpen ? intlMessages.restorePresentationLabel : intlMessages.minimizePresentationLabel)}
|
|
|
|
aria-describedby={intl.formatMessage(!presentationIsOpen ? intlMessages.restorePresentationDesc : intlMessages.minimizePresentationDesc)}
|
|
|
|
description={intl.formatMessage(!presentationIsOpen ? intlMessages.restorePresentationDesc : intlMessages.minimizePresentationDesc)}
|
|
|
|
color={presentationIsOpen ? "primary" : "default"}
|
2021-09-25 02:37:55 +08:00
|
|
|
hideLabel
|
|
|
|
circle
|
|
|
|
size="lg"
|
2023-04-11 03:25:19 +08:00
|
|
|
onClick={() => {
|
2024-09-09 19:54:46 +08:00
|
|
|
if (!isChatOpen && isGridLayout && !presentationIsOpen) {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
|
|
|
|
value: PANELS.CHAT,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_ID_CHAT_OPEN,
|
|
|
|
value: PUBLIC_CHAT_ID,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
|
|
|
|
value: true,
|
|
|
|
});
|
|
|
|
}
|
2023-04-11 03:25:19 +08:00
|
|
|
setPresentationIsOpen(layoutContextDispatch, !presentationIsOpen);
|
2024-08-08 04:57:09 +08:00
|
|
|
if (onlyPresentation) {
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('presentationLastState', !presentationIsOpen);
|
2023-04-11 03:25:19 +08:00
|
|
|
}
|
|
|
|
}}
|
2021-09-25 02:37:55 +08:00
|
|
|
id="restore-presentation"
|
2022-02-11 22:30:35 +08:00
|
|
|
ghost={!presentationIsOpen}
|
2021-09-25 02:37:55 +08:00
|
|
|
disabled={!isThereCurrentPresentation}
|
2022-02-11 22:30:35 +08:00
|
|
|
data-test={!presentationIsOpen ? 'restorePresentation' : 'minimizePresentation'}
|
2021-09-25 02:37:55 +08:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2018-12-15 04:16:15 +08:00
|
|
|
|
|
|
|
PresentationOptionsContainer.propTypes = propTypes;
|
|
|
|
export default injectIntl(PresentationOptionsContainer);
|