You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
soapbox/app/gabsocial/features/groups/sidebar_panel/index.js

52 lines
1.7 KiB

5 years ago
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({
4 years ago
title: { id: 'groups.sidebar-panel.title', defaultMessage: 'Groups You\'re In' },
show_all: { id: 'groups.sidebar-panel.show_all', defaultMessage: 'Show all' },
5 years ago
});
const mapStateToProps = (state, { id }) => ({
4 years ago
groupIds: state.getIn(['group_lists', 'member']),
5 years ago
});
export default @connect(mapStateToProps)
@injectIntl
class GroupSidebarPanel extends ImmutablePureComponent {
4 years ago
5 years ago
static propTypes = {
4 years ago
groupIds: ImmutablePropTypes.list,
5 years ago
}
render() {
4 years ago
const { intl, groupIds } = this.props;
const count = groupIds.count();
// Only when there are groups to show
if (count === 0) return null;
return (
<div className='wtf-panel group-sidebar-panel'>
<div className='wtf-panel-header'>
<Icon id='users' className='wtf-panel-header__icon' />
<span className='wtf-panel-header__label'>{intl.formatMessage(messages.title)}</span>
</div>
<div className='wtf-panel__content'>
<div className='group-sidebar-panel__items'>
{groupIds.slice(0, 10).map(groupId => <Item key={groupId} id={groupId} />)}
{count > 10 && <Link className='group-sidebar-panel__items__show-all' to='/groups/browse/member'>{intl.formatMessage(messages.show_all)}</Link>}
5 years ago
</div>
4 years ago
</div>
</div>
);
5 years ago
}
4 years ago
5 years ago
}