From f5d82b8d38538bc78d40e3b9dbf1a25e1048d53e Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Wed, 23 Nov 2016 12:01:09 -0800 Subject: [PATCH] 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, +};