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

148 lines
4.1 KiB
React
Raw Normal View History

import React, { Component } from 'react';
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 Application from '/imports/ui/components/settings/submenus/application/container';
2017-02-16 02:49:40 +08:00
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 Icon from '../icon/component';
import styles from './styles';
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-03-09 22:34:33 +08:00
const video = props.video;
const application = props.application;
const cc = props.cc;
const participants = props.participants;
2017-01-27 23:41:11 +08:00
this.state = {
current: {
2017-03-09 22:34:33 +08:00
video,
application,
cc,
participants,
2017-01-27 23:41:11 +08:00
},
saved: {
2017-03-09 22:34:33 +08:00
video: _.clone(video),
application: _.clone(application),
cc: _.clone(cc),
participants: _.clone(participants),
},
selectedTab: 0,
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.handleSelectTab = this.handleSelectTab.bind(this);
2016-07-12 01:43:42 +08:00
}
setHtmlFontSize(size) {
document.getElementsByTagName('html')[0].style.fontSize = size;
};
render() {
2016-05-06 05:14:39 +08:00
return (
<Modal
title="Settings"
confirm={{
callback: (() => {
2017-02-16 02:49:40 +08:00
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-03-09 22:34:33 +08:00
2017-02-25 04:38:16 +08:00
this.setHtmlFontSize(this.state.saved.application.fontSize);
}),
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) {
2017-03-09 22:34:33 +08:00
let settings = this.state;
2017-01-27 23:41:11 +08:00
settings.current[key] = newSettings;
this.setState(settings);
2017-01-27 23:41:11 +08:00
}
handleSelectTab(tab) {
2017-01-27 23:41:11 +08:00
this.setState({
selectedTab: tab,
});
}
renderModalContent() {
const {
isModerator,
} = this.props;
2017-01-27 23:41:11 +08:00
return (
<Tabs
className={styles.tabs}
onSelect={this.handleSelectTab}
2017-01-27 23:41:11 +08:00
selectedIndex={this.state.selectedTab}
>
<TabList className={styles.tabList}>
2017-03-09 22:34:33 +08:00
<Tab className={styles.tabSelector}>
<Icon iconName='application' className={styles.icon}/>
Application
</Tab>
2017-01-27 23:41:11 +08:00
<Tab className={styles.tabSelector}>
<Icon iconName='video' className={styles.icon}/>
Video
</Tab>
<Tab className={styles.tabSelector}>
<Icon iconName='user' className={styles.icon}/>
Closed Captions
</Tab>
{ isModerator ?
<Tab className={styles.tabSelector}>
<Icon iconName='user' className={styles.icon}/>
Participants
</Tab>
: null }
2017-01-27 23:41:11 +08:00
</TabList>
2017-03-09 22:34:33 +08:00
<TabPanel className={styles.tabPanel}>
<Application
handleUpdateSettings={this.handleUpdateSettings}
settings={this.state.current.application}
/>
</TabPanel>
2017-01-27 23:41:11 +08:00
<TabPanel className={styles.tabPanel}>
2017-02-16 02:49:40 +08:00
<Video
handleUpdateSettings={this.handleUpdateSettings}
2017-02-16 02:49:40 +08:00
settings={this.state.current.video}
/>
2017-01-27 23:41:11 +08:00
</TabPanel>
<TabPanel className={styles.tabPanel}>
2017-02-16 02:49:40 +08:00
<ClosedCaptions
settings={this.state.current.cc}
handleUpdateSettings={this.handleUpdateSettings}
locales={this.props.locales}/>
2017-01-27 23:41:11 +08:00
</TabPanel>
{ isModerator ?
<TabPanel className={styles.tabPanel}>
<Participants
settings={this.state.current.participants}
handleUpdateSettings={this.handleUpdateSettings}/>
</TabPanel>
: null }
2017-01-27 23:41:11 +08:00
</Tabs>
);
}
}
2017-02-16 02:49:40 +08:00
Settings.propTypes = propTypes;