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

131 lines
4.3 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 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';
import Settings from '/imports/ui/components/settings/component';
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: {
id: 'app.dropdown.optionsLabel',
2016-09-22 03:49:31 +08:00
defaultMessage: 'Options',
},
fullscreenLabel: {
id: 'app.dropdown.fullscreenLabel',
defaultMessage: 'Make fullscreen',
},
settingsLabel: {
id: 'app.dropdown.settingsLabel',
defaultMessage: 'Open settings',
},
leaveSessionLabel: {
id: 'app.dropdown.leaveSessionLabel',
defaultMessage: 'Logout',
},
fullscreenDesc: {
id: 'app.dropdown.fullscreenDesc',
defaultMessage: 'Make the settings menu fullscreen',
},
settingsDesc: {
id: 'app.dropdown.settingsDesc',
defaultMessage: 'Change the general settings',
},
leaveSessionDesc: {
id: 'app.dropdown.leaveSessionDesc',
defaultMessage: 'Leave the meeting',
},
2016-09-22 03:49:31 +08:00
});
const toggleFullScreen = () => {
let element = document.documentElement;
if (document.fullscreenEnabled
|| document.mozFullScreenEnabled
|| document.webkitFullscreenEnabled) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
2016-09-02 04:19:37 +08:00
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
2016-09-02 04:19:37 +08:00
}
}
};
2016-09-02 04:19:37 +08:00
const openSettings = () => showModal(<Settings />);
2016-09-02 04:19:37 +08:00
const openLogoutConfirmation = () => showModal(<LogoutConfirmation />);
2016-09-02 04:19:37 +08:00
export default class SettingsDropdown extends Component {
constructor(props) {
super(props);
2016-09-02 04:19:37 +08:00
}
render() {
2016-09-22 03:49:31 +08:00
const { intl } = this.props;
2016-09-02 04:19:37 +08:00
return (
<Dropdown ref="dropdown">
<DropdownTrigger>
<Button
role="button"
label={intl.formatMessage(intlMessages.optionsLabel)}
2016-09-02 04:19:37 +08:00
icon="more"
ghost={true}
circle={true}
hideLabel={true}
className={styles.settingBtn}
// 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"
2016-09-22 03:49:31 +08:00
label={intl.formatMessage(intlMessages.fullscreenLabel)}
description={intl.formatMessage(intlMessages.fullscreenDesc)}
onClick={toggleFullScreen.bind(this)}
/>
<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)}
/>
<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);