bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/lock-viewers/component.jsx

450 lines
16 KiB
React
Raw Normal View History

import React, { Fragment, Component } from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import PropTypes from 'prop-types';
2022-02-15 23:58:28 +08:00
import Toggle from '/imports/ui/components/common/switch/component';
import NotesService from '/imports/ui/components/notes/service';
2021-10-29 21:41:24 +08:00
import Styled from './styles';
2022-03-09 22:19:25 +08:00
import { isChatEnabled } from '/imports/ui/services/features';
const intlMessages = defineMessages({
lockViewersTitle: {
id: 'app.lock-viewers.title',
description: 'lock-viewers title',
},
closeLabel: {
id: 'app.shortcut-help.closeLabel',
description: 'label for close button',
},
closeDesc: {
id: 'app.shortcut-help.closeDesc',
description: 'description for close button',
},
lockViewersDescription: {
id: 'app.lock-viewers.description',
description: 'description for lock viewers feature',
},
featuresLable: {
id: 'app.lock-viewers.featuresLable',
description: 'features label',
},
lockStatusLabel: {
id: 'app.lock-viewers.lockStatusLabel',
description: 'description for close button',
},
webcamLabel: {
id: 'app.lock-viewers.webcamLabel',
description: 'label for webcam toggle',
},
otherViewersWebcamLabel: {
id: 'app.lock-viewers.otherViewersWebcamLabel',
description: 'label for other viewers webcam toggle',
},
microphoneLable: {
id: 'app.lock-viewers.microphoneLable',
description: 'label for microphone toggle',
},
publicChatLabel: {
id: 'app.lock-viewers.PublicChatLabel',
description: 'label for public chat toggle',
},
privateChatLable: {
id: 'app.lock-viewers.PrivateChatLable',
description: 'label for private chat toggle',
},
notesLabel: {
id: 'app.lock-viewers.notesLabel',
description: 'label for shared notes toggle',
},
userListLabel: {
id: 'app.lock-viewers.userListLabel',
description: 'label for user list toggle',
},
2019-05-08 21:16:00 +08:00
ariaModalTitle: {
2019-05-08 22:08:47 +08:00
id: 'app.lock-viewers.ariaTitle',
2019-05-08 21:16:00 +08:00
description: 'aria label for modal title',
},
buttonApply: {
id: 'app.lock-viewers.button.apply',
description: 'label for apply button',
},
buttonCancel: {
id: 'app.lock-viewers.button.cancel',
description: 'label for cancel button',
},
lockedLabel: {
id: 'app.lock-viewers.locked',
description: 'locked element label',
},
2022-03-22 11:10:47 +08:00
hideCursorsLabel: {
id: "app.lock-viewers.hideViewersCursor",
description: 'label for other viewers cursor',
},
hideAnnotationsLabel: {
id: "app.lock-viewers.hideAnnotationsLabel",
description: 'label for other viewers annotation',
2022-03-22 11:10:47 +08:00
}
});
const propTypes = {
closeModal: PropTypes.func.isRequired,
intl: PropTypes.shape({
formatMessage: PropTypes.func.isRequired,
}).isRequired,
meeting: PropTypes.object.isRequired,
showToggleLabel: PropTypes.bool.isRequired,
updateLockSettings: PropTypes.func.isRequired,
updateWebcamsOnlyForModerator: PropTypes.func.isRequired,
};
class LockViewersComponent extends Component {
constructor(props) {
super(props);
const { meeting: { lockSettingsProps, usersProp } } = this.props;
this.state = {
lockSettingsProps,
usersProp,
};
}
toggleLockSettings(property) {
const { lockSettingsProps } = this.state;
lockSettingsProps[property] = !lockSettingsProps[property];
this.setState({
lockSettingsProps,
});
}
toggleUserProps(property) {
const { usersProp } = this.state;
usersProp[property] = !usersProp[property];
this.setState({
usersProp,
});
}
displayLockStatus(status) {
const { intl } = this.props;
return (
status && <Styled.ToggleLabel>
{intl.formatMessage(intlMessages.lockedLabel)}
2021-10-29 21:41:24 +08:00
</Styled.ToggleLabel>
);
}
componentWillUnmount() {
const { closeModal } = this.props;
closeModal();
}
2019-01-18 00:33:43 +08:00
render() {
const {
closeModal,
intl,
showToggleLabel,
updateLockSettings,
updateWebcamsOnlyForModerator,
isOpen,
onRequestClose,
priority,
2019-01-18 00:33:43 +08:00
} = this.props;
const { lockSettingsProps, usersProp } = this.state;
const invertColors = true;
return (
2021-10-29 21:41:24 +08:00
<Styled.LockViewersModal
2019-01-18 00:33:43 +08:00
onRequestClose={closeModal}
2019-05-08 21:16:00 +08:00
contentLabel={intl.formatMessage(intlMessages.ariaModalTitle)}
title={intl.formatMessage(intlMessages.lockViewersTitle)}
{...{
isOpen,
onRequestClose,
priority,
}}
>
2021-10-29 21:41:24 +08:00
<Styled.Container>
<Styled.Description>
{`${intl.formatMessage(intlMessages.lockViewersDescription)}`}
2021-10-29 21:41:24 +08:00
</Styled.Description>
2021-10-29 21:41:24 +08:00
<Styled.Form>
<Styled.SubHeader>
<Styled.Bold>{intl.formatMessage(intlMessages.featuresLable)}</Styled.Bold>
<Styled.Bold>{intl.formatMessage(intlMessages.lockStatusLabel)}</Styled.Bold>
</Styled.SubHeader>
<Styled.Row data-test="lockShareWebcamItem">
2021-10-29 21:41:24 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.webcamLabel)}
2021-10-29 21:41:24 +08:00
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.disableCam)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.disableCam}
onChange={() => {
this.toggleLockSettings('disableCam');
}}
ariaLabel={intl.formatMessage(intlMessages.webcamLabel)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
2022-01-29 03:52:22 +08:00
data-test="lockShareWebcam"
/>
2021-10-29 21:41:24 +08:00
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
<Styled.Row data-test="lockSeeOtherViewersWebcamItem">
2021-10-29 21:41:24 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.otherViewersWebcamLabel)}
2021-10-29 21:41:24 +08:00
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(usersProp.webcamsOnlyForModerator)}
<Toggle
icons={false}
defaultChecked={usersProp.webcamsOnlyForModerator}
onChange={() => {
this.toggleUserProps('webcamsOnlyForModerator');
}}
ariaLabel={intl.formatMessage(intlMessages.otherViewersWebcamLabel)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
2022-01-29 03:52:22 +08:00
data-test="lockSeeOtherViewersWebcam"
/>
2021-10-29 21:41:24 +08:00
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
<Styled.Row data-test="lockShareMicrophoneItem">
2021-10-29 21:41:24 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.microphoneLable)}
2021-10-29 21:41:24 +08:00
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.disableMic)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.disableMic}
onChange={() => {
this.toggleLockSettings('disableMic');
}}
ariaLabel={intl.formatMessage(intlMessages.microphoneLable)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
2022-01-29 03:52:22 +08:00
data-test="lockShareMicrophone"
/>
2021-10-29 21:41:24 +08:00
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
2022-03-09 22:19:25 +08:00
{isChatEnabled() ? (
<Fragment>
<Styled.Row data-test="lockPublicChatItem">
2021-10-29 21:41:24 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.publicChatLabel)}
2021-10-29 21:41:24 +08:00
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.disablePublicChat)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.disablePublicChat}
onChange={() => {
this.toggleLockSettings('disablePublicChat');
}}
ariaLabel={intl.formatMessage(intlMessages.publicChatLabel)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
2022-01-29 03:52:22 +08:00
data-test="lockPublicChat"
/>
2021-10-29 21:41:24 +08:00
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
<Styled.Row data-test="lockPrivateChatItem">
2021-10-29 21:41:24 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.privateChatLable)}
2021-10-29 21:41:24 +08:00
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.disablePrivateChat)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.disablePrivateChat}
onChange={() => {
this.toggleLockSettings('disablePrivateChat');
}}
ariaLabel={intl.formatMessage(intlMessages.privateChatLable)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
2022-01-29 03:52:22 +08:00
data-test="lockPrivateChat"
/>
2021-10-29 21:41:24 +08:00
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
</Fragment>
) : null
}
{NotesService.isEnabled()
? (
<Styled.Row data-test="lockEditSharedNotesItem">
2021-10-29 21:41:24 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.notesLabel)}
2021-10-29 21:41:24 +08:00
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.disableNotes)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.disableNotes}
onChange={() => {
this.toggleLockSettings('disableNotes');
}}
ariaLabel={intl.formatMessage(intlMessages.notesLabel)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
2022-01-29 03:52:22 +08:00
data-test="lockEditSharedNotes"
/>
2021-10-29 21:41:24 +08:00
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
)
: null
}
<Styled.Row data-test="lockUserListItem">
2021-10-29 21:41:24 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.userListLabel)}
2021-10-29 21:41:24 +08:00
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.hideUserList)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.hideUserList}
onChange={() => {
this.toggleLockSettings('hideUserList');
}}
ariaLabel={intl.formatMessage(intlMessages.userListLabel)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
2022-01-29 03:52:22 +08:00
data-test="lockUserList"
/>
2021-10-29 21:41:24 +08:00
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
2022-03-22 11:10:47 +08:00
<Styled.Row data-test="hideViewersCursorItem">
2022-03-22 11:10:47 +08:00
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.hideCursorsLabel)}
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.hideViewersCursor)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.hideViewersCursor}
onChange={() => {
this.toggleLockSettings('hideViewersCursor');
}}
ariaLabel={intl.formatMessage(intlMessages.hideCursorsLabel)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
data-test="hideViewersCursor"
/>
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
<Styled.Row data-test="hideViewersAnnotation">
<Styled.Col aria-hidden="true">
<Styled.FormElement>
<Styled.Label>
{intl.formatMessage(intlMessages.hideAnnotationsLabel)}
</Styled.Label>
</Styled.FormElement>
</Styled.Col>
<Styled.Col>
<Styled.FormElementRight>
{this.displayLockStatus(lockSettingsProps.hideViewersAnnotation)}
<Toggle
icons={false}
defaultChecked={lockSettingsProps.hideViewersAnnotation}
onChange={() => {
this.toggleLockSettings('hideViewersAnnotation');
}}
ariaLabel={intl.formatMessage(intlMessages.hideAnnotationsLabel)}
showToggleLabel={showToggleLabel}
invertColors={invertColors}
data-test="hideViewersAnnotation"
/>
</Styled.FormElementRight>
</Styled.Col>
</Styled.Row>
2021-10-29 21:41:24 +08:00
</Styled.Form>
</Styled.Container>
<Styled.Footer>
<Styled.Actions>
<Styled.ButtonCancel
label={intl.formatMessage(intlMessages.buttonCancel)}
onClick={closeModal}
color="secondary"
/>
<Styled.ButtonApply
color="primary"
label={intl.formatMessage(intlMessages.buttonApply)}
onClick={() => {
updateLockSettings(lockSettingsProps);
updateWebcamsOnlyForModerator(usersProp.webcamsOnlyForModerator);
closeModal();
}}
2022-01-29 03:52:22 +08:00
data-test="applyLockSettings"
/>
2021-10-29 21:41:24 +08:00
</Styled.Actions>
</Styled.Footer>
</Styled.LockViewersModal>
);
}
}
LockViewersComponent.propTypes = propTypes;
export default injectIntl(LockViewersComponent);