Merge branch 'OpenSettings-Menu-Options' of github.com:KDSBrowne/bigbluebutton into kert-pres-2

This commit is contained in:
Anton Georgiev 2016-11-28 19:17:15 +00:00
commit 929ac08acb
4 changed files with 93 additions and 43 deletions

View File

@ -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(<Settings />);
const openSettings = () => showModal(<SettingsMenuContainer />);
const openLogoutConfirmation = () => showModal(<LogoutConfirmation />);

View File

@ -14,29 +14,58 @@ 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 });
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,
renderSettingOptions() {
const { isPresenter, role } = this.props;
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', }, });
this.submenus.push({ componentName: UsersMenu, tabIndex: 6,
if (isPresenter || role === 'MODERATOR') {
this.submenus.push(
{ componentName: UsersMenu, tabIndex: 6,
props: { title: 'Participants', prependIconName: 'icon-', icon: 'bbb-user', }, });
}
createMenu() {
const curr = this.state.activeSubmenu === undefined ? 0 : this.state.activeSubmenu;
return (
<div className={styles.full} role='presentation'>
<div className={styles.settingsMenuLeft}>
<ul className={styles.settingsSubmenu} role='menu'>
{this.submenus.map((value, index) => (
<li key={index} ref={'submenu' + index} role='menuitem' tabIndex={value.tabIndex}
onClick={this.handleClickSubmenu.bind(this, index)}
onKeyDown={this.handleKeyDown.bind(this)}
onFocus={this.handleFocus.bind(this, index)}
className={classNames(styles.settingsSubmenuItem,
index == this.state.activeSubmenu ? styles.settingsSubmenuItemActive : null)}>
<Icon key={index} prependIconName={value.props.prependIconName}
iconName={value.props.icon} title={value.props.title}/>
<span className={styles.settingsSubmenuItemText}>{value.props.title}</span>
</li>
))}
</ul>
</div>
<div className={styles.settingsMenuRight} role='presentation'>
{this.renderMenu()}
</div>
</div>
);
}
renderMenu() {
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,
@ -54,7 +83,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;
@ -174,27 +203,7 @@ export default class Settings extends React.Component {
label: 'Cancel',
description: 'Discart the changes and close the settings menu',
}}>
<div className={styles.full} role='presentation'>
<div className={styles.settingsMenuLeft}>
<ul className={styles.settingsSubmenu} role='menu'>
{this.submenus.map((value, index) => (
<li key={index} ref={'submenu' + index} role='menuitem' tabIndex={value.tabIndex}
onClick={this.clickSubmenu.bind(this, index)}
onKeyDown={this.handleKeyDown.bind(this)}
onFocus={this.handleFocus.bind(this, index)}
className={classNames(styles.settingsSubmenuItem,
index == this.state.activeSubmenu ? styles.settingsSubmenuItemActive : null)}>
<Icon key={index} prependIconName={value.props.prependIconName}
iconName={value.props.icon} title={value.props.title}/>
<span className={styles.settingsSubmenuItemText}>{value.props.title}</span>
</li>
))}
</ul>
</div>
<div className={styles.settingsMenuRight} role='presentation'>
{this.createMenu()}
</div>
</div>
{this.renderSettingOptions()}
</Modal>
);
}

View File

@ -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 (
<Settings {...this.props}>
{this.props.children}
</Settings>
);
}
}
export default createContainer(() => {
let data = Service.checkUserRoles();
return data;
}, SettingsMenuContainer);

View File

@ -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,
};