bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/video-provider/video-menu/component.jsx

87 lines
2.6 KiB
React
Raw Normal View History

2017-09-20 11:12:10 +08:00
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
2017-09-20 11:12:10 +08:00
import Button from '/imports/ui/components/button/component';
import { defineMessages, injectIntl, intlShape } from 'react-intl';
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 { styles } from './styles';
2017-09-20 11:12:10 +08:00
const intlMessages = defineMessages({
videoMenu: {
id: 'app.video.videoMenu',
description: 'video menu label',
2017-09-20 11:12:10 +08:00
},
videoMenuDesc: {
id: 'app.video.videoMenuDesc',
description: 'video menu description',
2017-09-20 11:12:10 +08:00
},
2018-03-23 01:02:59 +08:00
videoMenuDisabled: {
id: 'app.video.videoMenuDisabled',
description: 'video menu label',
},
2017-09-20 11:12:10 +08:00
});
2018-01-29 19:52:07 +08:00
const propTypes = {
intl: intlShape.isRequired,
isSharingVideo: PropTypes.bool.isRequired,
videoItems: PropTypes.arrayOf(PropTypes.object).isRequired,
};
const JoinVideoOptions = ({
intl,
isSharingVideo,
videoItems,
2018-03-23 01:02:59 +08:00
videoShareAllowed,
}) => {
const menuItems = videoItems
.filter(item => !item.disabled)
.map(item =>
(
<DropdownListItem
key={_.uniqueId('video-menu-')}
className={styles.item}
description={item.description}
onClick={item.click}
tabIndex={-1}
>
<img src={item.iconPath} className={styles.imageSize} alt="video menu icon" />
<span className={styles.label}>{item.label}</span>
</DropdownListItem>
));
return (
<Dropdown
autoFocus
>
<DropdownTrigger tabIndex={0}>
2018-01-29 19:52:07 +08:00
<Button
2018-03-23 01:02:59 +08:00
label={!videoShareAllowed ?
intl.formatMessage(intlMessages.videoMenuDisabled)
: intl.formatMessage(intlMessages.videoMenu)
}
2018-04-04 04:20:20 +08:00
className={styles.button}
onClick={() => null}
2018-01-29 19:52:07 +08:00
hideLabel
aria-label={intl.formatMessage(intlMessages.videoMenuDesc)}
color={isSharingVideo ? 'danger' : 'primary'}
icon={isSharingVideo ? 'video_off' : 'video'}
2018-01-29 19:52:07 +08:00
size="lg"
circle
2018-03-23 01:02:59 +08:00
disabled={!videoShareAllowed}
2018-01-29 19:52:07 +08:00
/>
</DropdownTrigger>
<DropdownContent placement="top" >
<DropdownList horizontal>
{menuItems}
</DropdownList>
</DropdownContent>
</Dropdown>
);
};
JoinVideoOptions.propTypes = propTypes;
export default injectIntl(JoinVideoOptions);