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';
|
2018-12-15 04:16:15 +08:00
|
|
|
|
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;
|
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={() => {
|
|
|
|
setPresentationIsOpen(layoutContextDispatch, !presentationIsOpen);
|
|
|
|
if (!hasExternalVideo && !hasScreenshare && !hasPinnedSharedNotes) {
|
|
|
|
Session.set('presentationLastState', !presentationIsOpen);
|
|
|
|
}
|
|
|
|
}}
|
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);
|