// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // Copyright (c) 2015-2016 Yuya Ochiai import React from 'react'; import PropTypes from 'prop-types'; import {Nav, NavItem} from 'react-bootstrap'; import {Container, Draggable} from 'react-smooth-dnd'; import PlusIcon from 'mdi-react/PlusIcon'; import {GET_CONFIGURATION} from 'common/communication'; export default class TabBar extends React.PureComponent { // need "this" constructor(props) { super(props); this.state = { hasGPOTeams: false, }; } componentDidMount() { window.ipcRenderer.invoke(GET_CONFIGURATION).then((config) => { this.setState({hasGPOTeams: config.registryTeams && config.registryTeams.length > 0}); }); } render() { const orderedTabs = this.props.teams.concat().sort((a, b) => a.order - b.order); const tabs = orderedTabs.map((team) => { const index = this.props.teams.indexOf(team); const sessionExpired = this.props.sessionsExpired[index]; const hasUnreads = this.props.unreadCounts[index]; let mentionCount = 0; if (this.props.mentionCounts[index] > 0) { mentionCount = this.props.mentionCounts[index]; } let badgeDiv; if (sessionExpired) { badgeDiv = (
); } else if (mentionCount !== 0) { badgeDiv = (
{mentionCount}
); } else if (hasUnreads) { badgeDiv = (
); } const id = `teamTabItem${index}`; const navItem = () => ( { this.props.onSelect(team.name, index); }} onSelect={() => { this.props.onSelect(team.name, index); }} title={team.name} disabled={this.props.tabsDisabled} >
{team.name} { badgeDiv }
); return ( ); }); if (this.props.showAddServerButton === true) { tabs.push( { this.props.onAddServer(); }} disabled={this.props.tabsDisabled} >
, ); } const navContainer = (ref) => ( ); return ( { return !this.state.hasGPOTeams && !this.props.tabsDisabled; }} /> ); } } TabBar.propTypes = { activeKey: PropTypes.number, id: PropTypes.string, isDarkMode: PropTypes.bool, onSelect: PropTypes.func, teams: PropTypes.array, sessionsExpired: PropTypes.object, unreadCounts: PropTypes.object, mentionCounts: PropTypes.object, showAddServerButton: PropTypes.bool, onAddServer: PropTypes.func, onDrop: PropTypes.func, tabsDisabled: PropTypes.bool, };