From 4f00c6b9943800d1c0357bfb06425ac551088704 Mon Sep 17 00:00:00 2001 From: Joao Siebel Date: Mon, 9 Sep 2019 11:21:54 -0300 Subject: [PATCH] Update lock viewers modal With this changes you need to click apply button in order to lock have effect, also update the lock text. close #7766 --- .../server/methods/toggleLockSettings.js | 34 +++-- .../methods/toggleWebcamsOnlyForModerator.js | 6 +- .../ui/components/lock-viewers/component.jsx | 127 +++++++++++++----- .../ui/components/lock-viewers/container.jsx | 14 +- .../ui/components/lock-viewers/service.js | 14 +- .../ui/components/lock-viewers/styles.scss | 27 ++++ bigbluebutton-html5/private/locales/en.json | 23 ++-- 7 files changed, 169 insertions(+), 76 deletions(-) diff --git a/bigbluebutton-html5/imports/api/meetings/server/methods/toggleLockSettings.js b/bigbluebutton-html5/imports/api/meetings/server/methods/toggleLockSettings.js index e8d14fa370..8238403207 100755 --- a/bigbluebutton-html5/imports/api/meetings/server/methods/toggleLockSettings.js +++ b/bigbluebutton-html5/imports/api/meetings/server/methods/toggleLockSettings.js @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor'; import { check } from 'meteor/check'; import RedisPubSub from '/imports/startup/server/redis'; -export default function toggleLockSettings(credentials, meeting) { +export default function toggleLockSettings(credentials, lockSettingsProps) { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; const EVENT_NAME = 'ChangeLockSettingsInMeetingCmdMsg'; @@ -11,7 +11,7 @@ export default function toggleLockSettings(credentials, meeting) { check(meetingId, String); check(requesterUserId, String); - check(meeting.lockSettingsProps, { + check(lockSettingsProps, { disableCam: Boolean, disableMic: Boolean, disablePrivateChat: Boolean, @@ -24,16 +24,28 @@ export default function toggleLockSettings(credentials, meeting) { setBy: Match.Maybe(String), }); + const { + disableCam, + disableMic, + disablePrivateChat: disablePrivChat, + disablePublicChat: disablePubChat, + disableNote, + hideUserList, + lockedLayout, + lockOnJoin, + lockOnJoinConfigurable, + } = lockSettingsProps; + const payload = { - disableCam: meeting.lockSettingsProps.disableCam, - disableMic: meeting.lockSettingsProps.disableMic, - disablePrivChat: meeting.lockSettingsProps.disablePrivateChat, - disablePubChat: meeting.lockSettingsProps.disablePublicChat, - disableNote: meeting.lockSettingsProps.disableNote, - hideUserList: meeting.lockSettingsProps.hideUserList, - lockedLayout: meeting.lockSettingsProps.lockedLayout, - lockOnJoin: meeting.lockSettingsProps.lockOnJoin, - lockOnJoinConfigurable: meeting.lockSettingsProps.lockOnJoinConfigurable, + disableCam, + disableMic, + disablePrivChat, + disablePubChat, + disableNote, + hideUserList, + lockedLayout, + lockOnJoin, + lockOnJoinConfigurable, setBy: requesterUserId, }; diff --git a/bigbluebutton-html5/imports/api/meetings/server/methods/toggleWebcamsOnlyForModerator.js b/bigbluebutton-html5/imports/api/meetings/server/methods/toggleWebcamsOnlyForModerator.js index 75f052de76..94935c51a7 100755 --- a/bigbluebutton-html5/imports/api/meetings/server/methods/toggleWebcamsOnlyForModerator.js +++ b/bigbluebutton-html5/imports/api/meetings/server/methods/toggleWebcamsOnlyForModerator.js @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor'; import { check } from 'meteor/check'; import RedisPubSub from '/imports/startup/server/redis'; -export default function toggleWebcamsOnlyForModerator(credentials, meeting) { +export default function toggleWebcamsOnlyForModerator(credentials, webcamsOnlyForModerator) { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; const EVENT_NAME = 'UpdateWebcamsOnlyForModeratorCmdMsg'; @@ -11,10 +11,10 @@ export default function toggleWebcamsOnlyForModerator(credentials, meeting) { check(meetingId, String); check(requesterUserId, String); - check(meeting.usersProp.webcamsOnlyForModerator, Boolean); + check(webcamsOnlyForModerator, Boolean); const payload = { - webcamsOnlyForModerator: meeting.usersProp.webcamsOnlyForModerator, + webcamsOnlyForModerator, setBy: requesterUserId, }; diff --git a/bigbluebutton-html5/imports/ui/components/lock-viewers/component.jsx b/bigbluebutton-html5/imports/ui/components/lock-viewers/component.jsx index d2c6e52e4c..ee3a20f8a8 100755 --- a/bigbluebutton-html5/imports/ui/components/lock-viewers/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/lock-viewers/component.jsx @@ -1,11 +1,15 @@ -import React, { Fragment } from 'react'; +import React, { Fragment, PureComponent } from 'react'; import { defineMessages, injectIntl } from 'react-intl'; -import Toggle from '/imports/ui/components/switch/component'; +import PropTypes from 'prop-types'; import cx from 'classnames'; +import Toggle from '/imports/ui/components/switch/component'; import Modal from '/imports/ui/components/modal/simple/component'; import NoteService from '/imports/ui/components/note/service'; +import Button from '/imports/ui/components/button/component'; import { styles } from './styles'; +const CHAT_ENABLED = Meteor.settings.public.chat.enabled; + const intlMessages = defineMessages({ lockViewersTitle: { id: 'app.lock-viewers.title', @@ -63,30 +67,79 @@ const intlMessages = defineMessages({ id: 'app.lock-viewers.ariaTitle', 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', + }, }); -const CHAT_ENABLED = Meteor.settings.public.chat.enabled; +const propTypes = { + closeModal: PropTypes.func.isRequired, + intl: PropTypes.shape({ + formatMessage: PropTypes.func.isRequired, + }).isRequired, + meeting: PropTypes.object.isRequired, + updateLockSettings: PropTypes.func.isRequired, + updateWebcamsOnlyForModerator: PropTypes.func.isRequired, +}; + +class LockViewersComponent extends PureComponent { + 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, + }); + } -class LockViewersComponent extends React.PureComponent { render() { const { intl, - meeting, closeModal, - toggleLockSettings, - toggleWebcamsOnlyForModerator, + updateLockSettings, + updateWebcamsOnlyForModerator, } = this.props; + const { lockSettingsProps, usersProp } = this.state; + return ( -
+

{intl.formatMessage(intlMessages.lockViewersTitle)}

@@ -111,10 +164,9 @@ class LockViewersComponent extends React.PureComponent {
{ - meeting.lockSettingsProps.disableCam = !meeting.lockSettingsProps.disableCam; - toggleLockSettings(meeting); + this.toggleLockSettings('disableCam'); }} ariaLabel={intl.formatMessage(intlMessages.webcamLabel)} /> @@ -133,10 +185,9 @@ class LockViewersComponent extends React.PureComponent {
{ - meeting.usersProp.webcamsOnlyForModerator = !meeting.usersProp.webcamsOnlyForModerator; - toggleWebcamsOnlyForModerator(meeting); + this.toggleUserProps('webcamsOnlyForModerator'); }} ariaLabel={intl.formatMessage(intlMessages.otherViewersWebcamLabel)} /> @@ -155,10 +206,9 @@ class LockViewersComponent extends React.PureComponent {
{ - meeting.lockSettingsProps.disableMic = !meeting.lockSettingsProps.disableMic; - toggleLockSettings(meeting); + this.toggleLockSettings('disableMic'); }} ariaLabel={intl.formatMessage(intlMessages.microphoneLable)} /> @@ -180,10 +230,9 @@ class LockViewersComponent extends React.PureComponent {
{ - meeting.lockSettingsProps.disablePublicChat = !meeting.lockSettingsProps.disablePublicChat; - toggleLockSettings(meeting); + this.toggleLockSettings('disablePublicChat'); }} ariaLabel={intl.formatMessage(intlMessages.publicChatLabel)} /> @@ -202,10 +251,9 @@ class LockViewersComponent extends React.PureComponent {
{ - meeting.lockSettingsProps.disablePrivateChat = !meeting.lockSettingsProps.disablePrivateChat; - toggleLockSettings(meeting); + this.toggleLockSettings('disablePrivateChat'); }} ariaLabel={intl.formatMessage(intlMessages.privateChatLable)} /> @@ -215,8 +263,7 @@ class LockViewersComponent extends React.PureComponent { ) : null } - - { NoteService.isEnabled() + {NoteService.isEnabled() ? (