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

194 lines
5.9 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-04-18 02:19:27 +08:00
import { defineMessages, injectIntl } from 'react-intl';
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-04-05 01:51:05 +08:00
import _ from 'lodash';
2017-01-27 23:41:11 +08:00
import Icon from '../icon/component';
import styles from './styles';
2017-04-18 02:19:27 +08:00
const intlMessages = defineMessages({
appTabLabel: {
id: 'app.settings.applicationTab.label',
description: 'label for application tab',
},
audioTabLabel: {
id: 'app.settings.audioTab.label',
description: 'label for audio tab',
},
videoTabLabel: {
id: 'app.settings.videoTab.label',
description: 'label for video tab',
},
closecaptionTabLabel: {
id: 'app.settings.closedcaptionTab.label',
description: 'label for closed-captions tab',
},
usersTabLabel: {
id: 'app.settings.usersTab.label',
description: 'label for participants tab',
},
2017-04-28 23:56:27 +08:00
SettingsLabel: {
id: 'app.settings.main.label',
description: 'General settings label',
},
CancelLabel: {
id: 'app.settings.main.cancel.label',
description: 'Discard the changes and close the settings menu',
},
SaveLabel: {
id: 'app.settings.main.save.label',
description: 'Save the changes and close the settings menu',
},
2017-04-18 02:19:27 +08:00
});
2017-01-27 23:41:11 +08:00
const propTypes = {
};
2016-05-06 05:14:39 +08:00
2017-04-18 02:19:27 +08:00
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-29 04:16:57 +08:00
video: _.clone(video),
application: _.clone(application),
cc: _.clone(cc),
participants: _.clone(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-03-29 02:41:48 +08:00
this.updateSettings = 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
}
2017-04-06 20:36:59 +08:00
componentWillMount() {
this.props.availableLocales.then(locales => {
this.setState({ availableLocales: locales });
});
}
setHtmlFontSize(size) {
document.getElementsByTagName('html')[0].style.fontSize = size;
};
render() {
2017-04-28 23:56:27 +08:00
const intl = this.props.intl;
2016-05-06 05:14:39 +08:00
return (
<Modal
2017-04-28 23:56:27 +08:00
title={intl.formatMessage(intlMessages.SettingsLabel)}
confirm={{
callback: (() => {
2017-03-29 02:41:48 +08:00
this.updateSettings(this.state.current);
}),
2017-04-28 23:56:27 +08:00
label: intl.formatMessage(intlMessages.SaveLabel),
}}
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);
}),
2017-04-28 23:56:27 +08:00
label: intl.formatMessage(intlMessages.CancelLabel),
}}>
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,
2017-04-18 02:19:27 +08:00
intl,
} = 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}
2017-04-18 02:19:27 +08:00
role="presentation"
2017-01-27 23:41:11 +08:00
>
<TabList className={styles.tabList}>
2017-04-18 02:19:27 +08:00
<Tab className={styles.tabSelector} aria-labelledby="appTab">
2017-03-09 22:34:33 +08:00
<Icon iconName='application' className={styles.icon}/>
2017-04-18 02:19:27 +08:00
<span id="appTab">{intl.formatMessage(intlMessages.appTabLabel)}</span>
2017-03-09 22:34:33 +08:00
</Tab>
{/*<Tab className={styles.tabSelector} aria-labelledby="videoTab">*/}
{/*<Icon iconName='video' className={styles.icon}/>*/}
{/*<span id="videoTab">{intl.formatMessage(intlMessages.videoTabLabel)}</span>*/}
{/*</Tab>*/}
2017-04-18 02:19:27 +08:00
<Tab className={styles.tabSelector} aria-labelledby="ccTab">
2017-01-27 23:41:11 +08:00
<Icon iconName='user' className={styles.icon}/>
2017-04-18 02:19:27 +08:00
<span id="ccTab">{intl.formatMessage(intlMessages.closecaptionTabLabel)}</span>
2017-01-27 23:41:11 +08:00
</Tab>
{ isModerator ?
2017-04-18 02:19:27 +08:00
<Tab className={styles.tabSelector} aria-labelledby="usersTab">
<Icon iconName='user' className={styles.icon}/>
2017-04-18 02:19:27 +08:00
<span id="usersTab">{intl.formatMessage(intlMessages.usersTabLabel)}</span>
</Tab>
: null }
2017-01-27 23:41:11 +08:00
</TabList>
2017-03-09 22:34:33 +08:00
<TabPanel className={styles.tabPanel}>
<Application
2017-04-06 20:36:59 +08:00
availableLocales={this.state.availableLocales}
2017-03-09 22:34:33 +08:00
handleUpdateSettings={this.handleUpdateSettings}
settings={this.state.current.application}
/>
</TabPanel>
{/*<TabPanel className={styles.tabPanel}>*/}
{/*<Video*/}
{/*handleUpdateSettings={this.handleUpdateSettings}*/}
{/*settings={this.state.current.video}*/}
{/*/>*/}
{/*</TabPanel>*/}
2017-01-27 23:41:11 +08:00
<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;
2017-04-18 02:19:27 +08:00
export default injectIntl(Settings);