import { Fragment } from 'react' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { defineMessages, injectIntl } from 'react-intl' import { NavLink } from 'react-router-dom' import classNames from 'classnames/bind' import { shortNumberFormat } from '../../utils/numbers' import PanelLayout from './panel_layout' import Icon from '../icon' const messages = defineMessages({ title: { id: 'groups.sidebar-panel.title', defaultMessage: 'Groups you\'re in' }, show_all: { id: 'groups.sidebar-panel.show_all', defaultMessage: 'Show all' }, all: { id: 'groups.sidebar-panel.all', defaultMessage: 'All' }, new_statuses: { id: 'groups.sidebar-panel.item.view', defaultMessage: 'new gabs' }, no_recent_activity: { id: 'groups.sidebar-panel.item.no_recent_activity', defaultMessage: 'No recent activity' }, }) const mapStateToProps = (state) => ({ groupIds: state.getIn(['group_lists', 'member']), }) export default @connect(mapStateToProps) @injectIntl class GroupSidebarPanel extends ImmutablePureComponent { static propTypes = { groupIds: ImmutablePropTypes.list, } render() { const { intl, groupIds } = this.props const count = groupIds.count() if (count === 0) return null return ( {intl.formatMessage(messages.all)} )} >
{ groupIds.slice(0, 6).map(groupId => ( )) } { count > 6 && {intl.formatMessage(messages.show_all)} }
) } } const mapStateToProps2 = (state, { id }) => ({ group: state.getIn(['groups', id]), relationships: state.getIn(['group_relationships', id]), }) @connect(mapStateToProps2) @injectIntl class GroupPanelItem extends ImmutablePureComponent { static propTypes = { group: ImmutablePropTypes.map, relationships: ImmutablePropTypes.map, } state = { hovering: false, } handleOnMouseEnter = () => { this.setState({ hovering: true }) } handleOnMouseLeave = () => { this.setState({ hovering: false }) } render() { const { intl, group, relationships } = this.props const { hovering } = this.state if (!relationships) return null const unreadCount = relationships.get('unread_count') const cx = classNames.bind(styles) const titleClasses = cx({ default: 1, text: 1, displayFlex: 1, colorBrand: 1, fontSize14PX: 1, fontWeightBold: 1, lineHeight15: 1, underline: hovering, }) return ( this.handleOnMouseEnter()} onMouseLeave={() => this.handleOnMouseLeave()} >
{group.get('title')}
{group.get('title')} { unreadCount > 0 && {shortNumberFormat(unreadCount)}   {intl.formatMessage(messages.new_statuses)} } { unreadCount === 0 && {intl.formatMessage(messages.no_recent_activity)} }
) } }