import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl } from 'react-intl'; import { connect } from 'react-redux'; import Item from './item'; import Icon from 'gabsocial/components/icon'; import { Link } from 'react-router-dom'; 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' }, }); const mapStateToProps = (state, { id }) => ({ 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(); // Only when there are groups to show if (count === 0) return null; return (
{intl.formatMessage(messages.title)}
{groupIds.slice(0, 10).map(groupId => )} {count > 10 && {intl.formatMessage(messages.show_all)}}
); } }