From f5d82b8d38538bc78d40e3b9dbf1a25e1048d53e Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Wed, 23 Nov 2016 12:01:09 -0800 Subject: [PATCH 1/7] Shows main setting options based on role --- .../nav-bar/settings-dropdown/component.jsx | 4 +- .../ui/components/settings/component.jsx | 74 ++++++++++--------- .../ui/components/settings/container.jsx | 24 ++++++ .../imports/ui/components/settings/service.js | 17 +++++ 4 files changed, 84 insertions(+), 35 deletions(-) mode change 100644 => 100755 bigbluebutton-html5/imports/ui/components/settings/component.jsx create mode 100755 bigbluebutton-html5/imports/ui/components/settings/container.jsx create mode 100755 bigbluebutton-html5/imports/ui/components/settings/service.js diff --git a/bigbluebutton-html5/imports/ui/components/nav-bar/settings-dropdown/component.jsx b/bigbluebutton-html5/imports/ui/components/nav-bar/settings-dropdown/component.jsx index 3832c6bd43..888fe0ba93 100755 --- a/bigbluebutton-html5/imports/ui/components/nav-bar/settings-dropdown/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/nav-bar/settings-dropdown/component.jsx @@ -4,7 +4,7 @@ import styles from '../styles'; import { showModal } from '/imports/ui/components/app/service'; import LogoutConfirmation from '/imports/ui/components/logout-confirmation/component'; -import Settings from '/imports/ui/components/settings/component'; +import SettingsMenuContainer from '/imports/ui/components/settings/container'; import Button from '/imports/ui/components/button/component'; import Dropdown from '/imports/ui/components/dropdown/component'; @@ -81,7 +81,7 @@ const toggleFullScreen = () => { } }; -const openSettings = () => showModal(); +const openSettings = () => showModal(); const openLogoutConfirmation = () => showModal(); diff --git a/bigbluebutton-html5/imports/ui/components/settings/component.jsx b/bigbluebutton-html5/imports/ui/components/settings/component.jsx old mode 100644 new mode 100755 index fac41c195e..3f3e951237 --- a/bigbluebutton-html5/imports/ui/components/settings/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/settings/component.jsx @@ -14,29 +14,57 @@ export default class Settings extends React.Component { constructor(props) { super(props); this.submenus = []; + this.state = { activeSubmenu: 0, focusSubmenu: 0 }; } - componentWillMount() { - /* activeSubmenu represents the submenu in the submenus array to be displayed to the user, - * initialized to 0 - */ - this.setState({ activeSubmenu: 0 }); - /* focusSubmenu represents the submenu in the submenus array which currently has focus, - * initialized to 0 - */ - this.setState({ focusSubmenu: 0 }); + renderSettings(){ + const { isPresenter, role } = this.props; + this.submenus = []; + this.submenus.push({ componentName: AudioMenu, tabIndex: 3, props: { title: 'Audio', prependIconName: 'icon-', icon: 'bbb-audio', }, }); this.submenus.push({ componentName: VideoMenu, tabIndex: 4, props: { title: 'Video', prependIconName: 'icon-', icon: 'bbb-video', }, }); this.submenus.push({ componentName: ApplicationMenu, tabIndex: 5, props: { title: 'Application', prependIconName: 'icon-', icon: 'bbb-application', }, }); - this.submenus.push({ componentName: UsersMenu, tabIndex: 6, - props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); + + if(isPresenter){ + this.submenus.push({ componentName: UsersMenu, tabIndex: 6, + props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); + } + + return( +
+
+
    + {this.submenus.map((value, index) => ( +
  • + + {value.props.title} +
  • + ))} +
+
+
+ {this.createMenu()} +
+
+ ); } + createMenu() { - const curr = this.state.activeSubmenu === undefined ? 0 : this.state.activeSubmenu; + let curr = this.state.activeSubmenu === undefined ? 0 : this.state.activeSubmenu; + + if(!this.submenus[curr]){ + curr = (this.state.activeSubmenu - 1); + } let props = { title: this.submenus[curr].props.title, @@ -174,27 +202,7 @@ export default class Settings extends React.Component { label: 'Cancel', description: 'Discart the changes and close the settings menu', }}> -
-
-
    - {this.submenus.map((value, index) => ( -
  • - - {value.props.title} -
  • - ))} -
-
-
- {this.createMenu()} -
-
+ {this.renderSettings()} ); } diff --git a/bigbluebutton-html5/imports/ui/components/settings/container.jsx b/bigbluebutton-html5/imports/ui/components/settings/container.jsx new file mode 100755 index 0000000000..8b847f9458 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/settings/container.jsx @@ -0,0 +1,24 @@ +import React, { Component, PropTypes } from 'react'; +import { createContainer } from 'meteor/react-meteor-data'; + +import Settings from './component'; +import Service from './service'; + +class SettingsMenuContainer extends Component { + constructor(props) { + super(props); + } + + render() { + return ( + + {this.props.children} + + ); + } +} + +export default createContainer(() => { + let data = Service.checkUserRoles(); + return data; +}, SettingsMenuContainer); diff --git a/bigbluebutton-html5/imports/ui/components/settings/service.js b/bigbluebutton-html5/imports/ui/components/settings/service.js new file mode 100755 index 0000000000..e53217bb0d --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/settings/service.js @@ -0,0 +1,17 @@ +import Users from '/imports/api/users'; +import AuthSingleton from '/imports/ui/services/auth/index.js'; + +checkUserRoles = () => { + const user = Users.findOne({ + userId: AuthSingleton.getCredentials().requesterUserId, + }).user; + + return { + isPresenter: user.presenter, + role: user.role, + }; +}; + +export default { + checkUserRoles, +}; From 525279ecb0b5216dfb1e1a1b4d3e0b51c0be95a6 Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Wed, 23 Nov 2016 17:55:14 -0800 Subject: [PATCH 2/7] added moderator condition --- .../imports/ui/components/settings/component.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/settings/component.jsx b/bigbluebutton-html5/imports/ui/components/settings/component.jsx index 3f3e951237..9987c7cdba 100755 --- a/bigbluebutton-html5/imports/ui/components/settings/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/settings/component.jsx @@ -17,8 +17,10 @@ export default class Settings extends React.Component { this.state = { activeSubmenu: 0, focusSubmenu: 0 }; } - renderSettings(){ + renderSettingOptions(){ const { isPresenter, role } = this.props; + console.log(this.props); + console.log(role); this.submenus = []; this.submenus.push({ componentName: AudioMenu, tabIndex: 3, @@ -28,7 +30,7 @@ export default class Settings extends React.Component { this.submenus.push({ componentName: ApplicationMenu, tabIndex: 5, props: { title: 'Application', prependIconName: 'icon-', icon: 'bbb-application', }, }); - if(isPresenter){ + if(isPresenter || role === 'MODERATOR'){ this.submenus.push({ componentName: UsersMenu, tabIndex: 6, props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); } @@ -202,7 +204,7 @@ export default class Settings extends React.Component { label: 'Cancel', description: 'Discart the changes and close the settings menu', }}> - {this.renderSettings()} + {this.renderSettingOptions()} ); } From d580f01efd7759810a9e072828fd8036f0a3c903 Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Wed, 23 Nov 2016 18:01:51 -0800 Subject: [PATCH 3/7] fixed lint issues --- .../imports/ui/components/settings/component.jsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/settings/component.jsx b/bigbluebutton-html5/imports/ui/components/settings/component.jsx index 9987c7cdba..60017ffda5 100755 --- a/bigbluebutton-html5/imports/ui/components/settings/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/settings/component.jsx @@ -17,7 +17,7 @@ export default class Settings extends React.Component { this.state = { activeSubmenu: 0, focusSubmenu: 0 }; } - renderSettingOptions(){ + renderSettingOptions() { const { isPresenter, role } = this.props; console.log(this.props); console.log(role); @@ -30,12 +30,12 @@ export default class Settings extends React.Component { this.submenus.push({ componentName: ApplicationMenu, tabIndex: 5, props: { title: 'Application', prependIconName: 'icon-', icon: 'bbb-application', }, }); - if(isPresenter || role === 'MODERATOR'){ - this.submenus.push({ componentName: UsersMenu, tabIndex: 6, - props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); + if (isPresenter || role === 'MODERATOR') { + this.submenus.push({ componentName: UsersMenu, tabIndex: 6, + props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); } - return( + return (
    @@ -60,11 +60,10 @@ export default class Settings extends React.Component { ); } - createMenu() { let curr = this.state.activeSubmenu === undefined ? 0 : this.state.activeSubmenu; - if(!this.submenus[curr]){ + if (!this.submenus[curr]) { curr = (this.state.activeSubmenu - 1); } From 407833756907edce52fa3932ff8683d2ef4f549d Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Wed, 23 Nov 2016 18:12:36 -0800 Subject: [PATCH 4/7] removed console logs --- .../imports/ui/components/settings/component.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/settings/component.jsx b/bigbluebutton-html5/imports/ui/components/settings/component.jsx index 60017ffda5..f074e0cada 100755 --- a/bigbluebutton-html5/imports/ui/components/settings/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/settings/component.jsx @@ -19,8 +19,6 @@ export default class Settings extends React.Component { renderSettingOptions() { const { isPresenter, role } = this.props; - console.log(this.props); - console.log(role); this.submenus = []; this.submenus.push({ componentName: AudioMenu, tabIndex: 3, From 59ded8461ef8e85a8a5dd94e6a942c48facac49e Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Thu, 24 Nov 2016 20:00:46 -0800 Subject: [PATCH 5/7] added suggestions --- .../ui/components/settings/component.jsx | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/settings/component.jsx b/bigbluebutton-html5/imports/ui/components/settings/component.jsx index f074e0cada..5674114567 100755 --- a/bigbluebutton-html5/imports/ui/components/settings/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/settings/component.jsx @@ -15,23 +15,25 @@ export default class Settings extends React.Component { super(props); this.submenus = []; this.state = { activeSubmenu: 0, focusSubmenu: 0 }; + + const { isPresenter, role } = this.props; + + this.submenus.push( + { componentName: AudioMenu, tabIndex: 3, + props: { title: 'Audio', prependIconName: 'icon-', icon: 'bbb-audio', }, }, + { componentName: VideoMenu, tabIndex: 4, + props: { title: 'Video', prependIconName: 'icon-', icon: 'bbb-video', }, }, + { componentName: ApplicationMenu, tabIndex: 5, + props: { title: 'Application', prependIconName: 'icon-', icon: 'bbb-application', }, }); + + if (isPresenter || role === 'MODERATOR') { + this.submenus.push( + { componentName: UsersMenu, tabIndex: 6, + props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); + } } renderSettingOptions() { - const { isPresenter, role } = this.props; - this.submenus = []; - - this.submenus.push({ componentName: AudioMenu, tabIndex: 3, - props: { title: 'Audio', prependIconName: 'icon-', icon: 'bbb-audio', }, }); - this.submenus.push({ componentName: VideoMenu, tabIndex: 4, - props: { title: 'Video', prependIconName: 'icon-', icon: 'bbb-video', }, }); - this.submenus.push({ componentName: ApplicationMenu, tabIndex: 5, - props: { title: 'Application', prependIconName: 'icon-', icon: 'bbb-application', }, }); - - if (isPresenter || role === 'MODERATOR') { - this.submenus.push({ componentName: UsersMenu, tabIndex: 6, - props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); - } return (
    @@ -39,7 +41,7 @@ export default class Settings extends React.Component {
      {this.submenus.map((value, index) => (
    - {this.createMenu()} + {this.renderMenu()}
); } - createMenu() { +componentWillReceiveProps(nextProps){ + this.submenus = []; + + this.submenus.push( + { componentName: AudioMenu, tabIndex: 3, + props: { title: 'Audio', prependIconName: 'icon-', icon: 'bbb-audio', }, }, + { componentName: VideoMenu, tabIndex: 4, + props: { title: 'Video', prependIconName: 'icon-', icon: 'bbb-video', }, }, + { componentName: ApplicationMenu, tabIndex: 5, + props: { title: 'Application', prependIconName: 'icon-', icon: 'bbb-application', }, }); + + if (nextProps.isPresenter || nextProps.role === 'MODERATOR') { + this.submenus.push( + { componentName: UsersMenu, tabIndex: 6, + props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); + } +} + + + renderMenu() { let curr = this.state.activeSubmenu === undefined ? 0 : this.state.activeSubmenu; if (!this.submenus[curr]) { @@ -81,7 +102,7 @@ export default class Settings extends React.Component { * activeSubmenu: the submenu to be displayed to the user * focusSubmenu: the submenu to set focus to */ - clickSubmenu(i) { + handleClickSubmenu(i) { if (i <= 0) { this.setState({ activeSubmenu: 0, focusSubmenu: 0, }); return; From b52d06fd859772c82df2e1ce78a7d0bd9a3d8f5b Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Fri, 25 Nov 2016 05:11:50 -0800 Subject: [PATCH 6/7] fixed lint issue --- .../imports/ui/components/settings/component.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/settings/component.jsx b/bigbluebutton-html5/imports/ui/components/settings/component.jsx index 5674114567..a5c1427d0e 100755 --- a/bigbluebutton-html5/imports/ui/components/settings/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/settings/component.jsx @@ -60,7 +60,7 @@ export default class Settings extends React.Component { ); } -componentWillReceiveProps(nextProps){ +componentWillReceiveProps(nextProps) { this.submenus = []; this.submenus.push( @@ -78,7 +78,6 @@ componentWillReceiveProps(nextProps){ } } - renderMenu() { let curr = this.state.activeSubmenu === undefined ? 0 : this.state.activeSubmenu; From 0fc3883397fa9e0fe8b6aabadc0daf4013c18c0d Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Fri, 25 Nov 2016 08:07:41 -0800 Subject: [PATCH 7/7] removed duplication --- .../ui/components/settings/component.jsx | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/settings/component.jsx b/bigbluebutton-html5/imports/ui/components/settings/component.jsx index a5c1427d0e..21b7b66f0e 100755 --- a/bigbluebutton-html5/imports/ui/components/settings/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/settings/component.jsx @@ -15,9 +15,12 @@ export default class Settings extends React.Component { super(props); this.submenus = []; this.state = { activeSubmenu: 0, focusSubmenu: 0 }; + } + renderSettingOptions() { const { isPresenter, role } = this.props; - + + this.submenus = []; this.submenus.push( { componentName: AudioMenu, tabIndex: 3, props: { title: 'Audio', prependIconName: 'icon-', icon: 'bbb-audio', }, }, @@ -31,9 +34,6 @@ export default class Settings extends React.Component { { componentName: UsersMenu, tabIndex: 6, props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); } - } - - renderSettingOptions() { return (
@@ -60,24 +60,6 @@ export default class Settings extends React.Component { ); } -componentWillReceiveProps(nextProps) { - this.submenus = []; - - this.submenus.push( - { componentName: AudioMenu, tabIndex: 3, - props: { title: 'Audio', prependIconName: 'icon-', icon: 'bbb-audio', }, }, - { componentName: VideoMenu, tabIndex: 4, - props: { title: 'Video', prependIconName: 'icon-', icon: 'bbb-video', }, }, - { componentName: ApplicationMenu, tabIndex: 5, - props: { title: 'Application', prependIconName: 'icon-', icon: 'bbb-application', }, }); - - if (nextProps.isPresenter || nextProps.role === 'MODERATOR') { - this.submenus.push( - { componentName: UsersMenu, tabIndex: 6, - props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, }); - } -} - renderMenu() { let curr = this.state.activeSubmenu === undefined ? 0 : this.state.activeSubmenu;