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

139 lines
4.7 KiB
React
Raw Normal View History

2016-09-22 03:49:31 +08:00
import React, { Component, PropTypes } from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import cx from 'classnames';
import styles from '../styles';
2016-09-02 04:19:37 +08:00
import { showModal } from '/imports/ui/components/app/service';
import LogoutConfirmation from '/imports/ui/components/logout-confirmation/component';
2016-12-08 23:40:11 +08:00
import AboutContainer from '/imports/ui/components/about/container';
import SettingsMenuContainer from '/imports/ui/components/settings/container';
2016-09-02 04:19:37 +08:00
import Button from '/imports/ui/components/button/component';
import Dropdown from '/imports/ui/components/dropdown/component';
import DropdownTrigger from '/imports/ui/components/dropdown/trigger/component';
import DropdownContent from '/imports/ui/components/dropdown/content/component';
import DropdownList from '/imports/ui/components/dropdown/list/component';
import DropdownListItem from '/imports/ui/components/dropdown/list/item/component';
import DropdownListSeparator from '/imports/ui/components/dropdown/list/separator/component';
2016-09-22 03:49:31 +08:00
const intlMessages = defineMessages({
optionsLabel: {
2016-09-27 05:55:33 +08:00
id: 'app.navBar.settingsDropdown.optionsLabel',
2016-09-22 03:49:31 +08:00
defaultMessage: 'Options',
},
fullscreenLabel: {
2016-09-27 05:55:33 +08:00
id: 'app.navBar.settingsDropdown.fullscreenLabel',
2016-09-22 03:49:31 +08:00
defaultMessage: 'Make fullscreen',
},
settingsLabel: {
2016-09-27 05:55:33 +08:00
id: 'app.navBar.settingsDropdown.settingsLabel',
2016-09-22 03:49:31 +08:00
defaultMessage: 'Open settings',
},
2016-12-08 05:14:14 +08:00
aboutLabel: {
id: 'app.navBar.settingsDropdown.aboutLabel',
defaultMessage: 'About',
},
aboutDesc: {
id: 'app.navBar.settingsDropdown.aboutDesc',
defaultMessage: 'About',
},
2016-09-22 03:49:31 +08:00
leaveSessionLabel: {
2016-09-27 05:55:33 +08:00
id: 'app.navBar.settingsDropdown.leaveSessionLabel',
2016-09-22 03:49:31 +08:00
defaultMessage: 'Logout',
},
fullscreenDesc: {
2016-09-27 05:55:33 +08:00
id: 'app.navBar.settingsDropdown.fullscreenDesc',
defaultMessage: 'Make the settings menu fullscreen',
},
settingsDesc: {
2016-09-27 05:55:33 +08:00
id: 'app.navBar.settingsDropdown.settingsDesc',
defaultMessage: 'Change the general settings',
},
leaveSessionDesc: {
2016-09-27 05:55:33 +08:00
id: 'app.navBar.settingsDropdown.leaveSessionDesc',
defaultMessage: 'Leave the meeting',
},
2017-02-14 00:21:53 +08:00
exitFullScreenDesc: {
id: 'app.navBar.settingsDropdown.exitFullScreenDesc',
2017-02-14 23:11:27 +08:00
defaultMessage: 'exit fullscreen mode',
2017-02-14 00:21:53 +08:00
},
exitFullScreenLabel: {
id: 'app.navBar.settingsDropdown.exitFullScreenLabel',
defaultMessage: 'Exit fullscreen',
},
2016-09-22 03:49:31 +08:00
});
const openSettings = () => showModal(<SettingsMenuContainer />);
2016-09-02 04:19:37 +08:00
const openAbout = () => showModal(<AboutContainer />);
2016-12-08 05:14:14 +08:00
const openLogoutConfirmation = () => showModal(<LogoutConfirmation />);
2016-09-02 04:19:37 +08:00
2016-09-27 05:55:33 +08:00
class SettingsDropdown extends Component {
constructor(props) {
super(props);
2016-09-02 04:19:37 +08:00
}
render() {
2017-02-14 00:21:53 +08:00
2017-03-17 08:29:58 +08:00
const { intl, isFullScreen } = this.props;
2017-02-14 00:21:53 +08:00
2017-03-17 08:29:58 +08:00
let fullScreenLabel = intl.formatMessage(intlMessages.fullscreenLabel);
let fullScreenDesc = intl.formatMessage(intlMessages.fullscreenDesc);
2017-02-14 00:21:53 +08:00
2017-03-17 08:29:58 +08:00
if (isFullScreen) {
2017-02-14 00:21:53 +08:00
fullScreenLabel = intl.formatMessage(intlMessages.exitFullScreenLabel);
fullScreenDesc = intl.formatMessage(intlMessages.exitFullScreenDesc);
}
2016-09-02 04:19:37 +08:00
return (
<Dropdown ref="dropdown">
<DropdownTrigger>
<Button
label={intl.formatMessage(intlMessages.optionsLabel)}
2016-09-02 04:19:37 +08:00
icon="more"
ghost={true}
circle={true}
hideLabel={true}
className={cx(styles.btn, styles.btnSettings)}
// FIXME: Without onClick react proptypes keep warning
// even after the DropdownTrigger inject an onClick handler
onClick={() => null}
2016-09-02 04:19:37 +08:00
/>
</DropdownTrigger>
<DropdownContent placement="bottom right">
<DropdownList>
<DropdownListItem
2016-09-14 03:46:12 +08:00
icon="fullscreen"
2017-02-14 00:21:53 +08:00
label={fullScreenLabel}
description={fullScreenDesc}
onClick={this.props.handleToggleFullscreen}
/>
<DropdownListItem
icon="more"
2016-09-22 03:49:31 +08:00
label={intl.formatMessage(intlMessages.settingsLabel)}
description={intl.formatMessage(intlMessages.settingsDesc)}
onClick={openSettings.bind(this)}
/>
2016-12-08 05:14:14 +08:00
<DropdownListItem
2016-12-08 23:58:58 +08:00
label={intl.formatMessage(intlMessages.aboutLabel)}
description={intl.formatMessage(intlMessages.aboutDesc)}
2016-12-09 00:04:28 +08:00
onClick={openAbout.bind(this)}
2016-12-08 05:14:14 +08:00
/>
<DropdownListSeparator />
<DropdownListItem
icon="logout"
2016-09-22 03:49:31 +08:00
label={intl.formatMessage(intlMessages.leaveSessionLabel)}
description={intl.formatMessage(intlMessages.leaveSessionDesc)}
onClick={openLogoutConfirmation.bind(this)}
/>
</DropdownList>
2016-09-02 04:19:37 +08:00
</DropdownContent>
</Dropdown>
);
}
}
2016-09-22 03:49:31 +08:00
export default injectIntl(SettingsDropdown);