const React = require('react'); const {findDOMNode} = require('react-dom'); const PropTypes = require('prop-types'); const {Glyphicon, Nav, NavItem, Overlay} = require('react-bootstrap'); const PermissionRequestDialog = require('./PermissionRequestDialog.jsx'); class TabBar extends React.Component { // need "this" render() { const tabs = this.props.teams.map((team, index) => { let unreadCount = 0; if (this.props.unreadCounts[index] > 0) { unreadCount = this.props.unreadCounts[index]; } if (this.props.unreadAtActive[index]) { unreadCount += 1; } let mentionCount = 0; if (this.props.mentionCounts[index] > 0) { mentionCount = this.props.mentionCounts[index]; } if (this.props.mentionAtActiveCounts[index] > 0) { mentionCount += this.props.mentionAtActiveCounts[index]; } let badgeDiv; if (mentionCount !== 0) { badgeDiv = (
{mentionCount}
); } const id = 'teamTabItem' + index; const permissionOverlay = this.props.requestingPermission[index] ? ( findDOMNode(this.refs[id])} > ) : null; if (unreadCount === 0) { return ( { team.name } { ' ' } { badgeDiv } {permissionOverlay} ); } return ( { team.name } { ' ' } { badgeDiv } ); }); if (this.props.showAddServerButton === true) { tabs.push( ); } return ( ); } } TabBar.propTypes = { activeKey: PropTypes.number, id: PropTypes.string, onSelect: PropTypes.func, teams: PropTypes.array, unreadCounts: PropTypes.array, unreadAtActive: PropTypes.array, mentionCounts: PropTypes.array, mentionAtActiveCounts: PropTypes.array, showAddServerButton: PropTypes.bool, requestingPermission: PropTypes.arrayOf(PropTypes.shape({ origin: PropTypes.string, permission: PropTypes.string })), onAddServer: PropTypes.func, onClickPermissionDialog: PropTypes.func }; module.exports = TabBar;