bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/settings/component.jsx

138 lines
4.3 KiB
React
Raw Normal View History

2017-01-27 23:41:11 +08:00
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';
import Modal from '/imports/ui/components/modal/component';
2017-01-27 23:41:11 +08:00
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
2017-02-16 02:49:40 +08:00
import ClosedCaptions from '/imports/ui/components/settings/submenus/closed-captions/component';
import Audio from '/imports/ui/components/settings/submenus/audio/component';
import Application from '/imports/ui/components/settings/submenus/application/component';
import Participants from '/imports/ui/components/settings/submenus/participants/component';
import Video from '/imports/ui/components/settings/submenus/video/component';
2017-01-27 23:41:11 +08:00
import Button from '../button/component';
import Icon from '../icon/component';
import styles from './styles';
import cx from 'classnames';
const propTypes = {
};
2016-05-06 05:14:39 +08:00
2017-02-16 02:49:40 +08:00
export default class Settings extends Component {
2016-05-06 05:14:39 +08:00
constructor(props) {
super(props);
2017-01-27 23:41:11 +08:00
this.state = {
current: {
2017-02-16 02:49:40 +08:00
audio: props.audio,
cc: props.cc,
participants: {},
2017-01-27 23:41:11 +08:00
},
2017-02-16 02:49:40 +08:00
selectedTab: 3,
2016-05-06 05:14:39 +08:00
};
2017-02-16 02:49:40 +08:00
this.handleSettingsApply = props.updateSettings;
2017-01-27 23:41:11 +08:00
this.handleUpdateSettings = this.handleUpdateSettings.bind(this);
this.handleSelect = this.handleSelect.bind(this);
2016-07-12 01:43:42 +08:00
}
render() {
2016-05-06 05:14:39 +08:00
return (
<Modal
title="Settings"
confirm={{
callback: (() => {
2017-01-27 23:41:11 +08:00
// this.commit(this.state.current);
// this.setState({ activeSubmenu: 0, focusSubmenu: 0 });
// console.log('SHOULD APPLY SETTINGS CHANGES');
2017-02-16 02:49:40 +08:00
console.log('SETTINGS', this.state.current);
this.handleSettingsApply(this.state.current);
}),
2016-12-14 23:40:13 +08:00
label: 'Save',
description: 'Saves the changes and close the settings menu',
}}
dismiss={{
callback: (() => {
2017-01-27 23:41:11 +08:00
// this.setState({ activeSubmenu: 0, focusSubmenu: 0 });
// console.log('SHOULD DISCART SETTINGS CHANGES');
// this.props.handleRevertFontState();
}),
label: 'Cancel',
description: 'Discart the changes and close the settings menu',
}}>
2017-01-27 23:41:11 +08:00
{this.renderModalContent()}
</Modal>
2016-05-06 05:14:39 +08:00
);
}
2016-05-07 01:46:14 +08:00
2017-01-27 23:41:11 +08:00
handleUpdateSettings(key, newSettings) {
let settings = {
2017-02-16 02:49:40 +08:00
current: this.state.current,
2017-01-27 23:41:11 +08:00
};
settings.current[key] = newSettings;
this.setState(settings, () => console.log(this.state));
}
handleSelect(tab) {
this.setState({
selectedTab: tab,
});
}
renderModalContent() {
return (
<Tabs
className={styles.tabs}
onSelect={this.handleSelect}
selectedIndex={this.state.selectedTab}
>
<TabList className={styles.tabList}>
<Tab className={styles.tabSelector}>
<Icon iconName='audio' className={styles.icon}/>
<span>Audio</span>
</Tab>
<Tab className={styles.tabSelector}>
<Icon iconName='video' className={styles.icon}/>
Video
</Tab>
<Tab className={styles.tabSelector}>
<Icon iconName='application' className={styles.icon}/>
Application
</Tab>
<Tab className={styles.tabSelector}>
<Icon iconName='user' className={styles.icon}/>
Closed Captions
</Tab>
<Tab className={styles.tabSelector}>
<Icon iconName='user' className={styles.icon}/>
Participants
</Tab>
</TabList>
<TabPanel className={styles.tabPanel}>
2017-02-16 02:49:40 +08:00
<Audio
settings={this.state.current.audio}
handleUpdateSettings={this.handleUpdateSettings}/>
2017-01-27 23:41:11 +08:00
</TabPanel>
<TabPanel className={styles.tabPanel}>
2017-02-16 02:49:40 +08:00
<Video
settings={this.state.current.video}
/>
2017-01-27 23:41:11 +08:00
</TabPanel>
<TabPanel className={styles.tabPanel}>
<Application />
</TabPanel>
<TabPanel className={styles.tabPanel}>
2017-02-16 02:49:40 +08:00
<ClosedCaptions
settings={this.state.current.cc}
handleUpdateSettings={this.handleUpdateSettings}/>
2017-01-27 23:41:11 +08:00
</TabPanel>
<TabPanel className={styles.tabPanel}>
2017-02-16 02:49:40 +08:00
<Participants
settings={this.state.current.participants}
handleUpdateSettings={this.handleUpdateSettings}/>
2017-01-27 23:41:11 +08:00
</TabPanel>
</Tabs>
);
}
}
2017-02-16 02:49:40 +08:00
Settings.propTypes = propTypes;