'use strict'; import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { FormattedMessage } from 'react-intl'; import { NavLink, withRouter } from 'react-router-dom'; import Icon from 'soapbox/components/icon'; import IconWithCounter from 'soapbox/components/icon_with_counter'; import classNames from 'classnames'; import { getFeatures } from 'soapbox/utils/features'; import { getSoapboxConfig } from 'soapbox/actions/soapbox'; import { isStaff } from 'soapbox/utils/accounts'; const mapStateToProps = state => { const me = state.get('me'); const reportsCount = state.getIn(['admin', 'openReports']).count(); const approvalCount = state.getIn(['admin', 'awaitingApproval']).count(); const instance = state.get('instance'); return { account: state.getIn(['accounts', me]), logo: getSoapboxConfig(state).get('logo'), notificationCount: state.getIn(['notifications', 'unread']), chatsCount: state.get('chats').reduce((acc, curr) => acc + Math.min(curr.get('unread', 0), 1), 0), dashboardCount: reportsCount + approvalCount, features: getFeatures(instance), instance, }; }; export default @withRouter @connect(mapStateToProps) class PrimaryNavigation extends React.PureComponent { static contextTypes = { router: PropTypes.object, }; static propTypes = { dispatch: PropTypes.func.isRequired, logo: PropTypes.string, account: ImmutablePropTypes.map, dashboardCount: PropTypes.number, notificationCount: PropTypes.number, chatsCount: PropTypes.number, features: PropTypes.object.isRequired, location: PropTypes.object, instance: ImmutablePropTypes.map.isRequired, }; render() { const { account, features, notificationCount, chatsCount, dashboardCount, location, instance } = this.props; return (
); } }