2020-02-22 23:26:23 +00:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
2020-03-04 22:26:01 +00:00
|
|
|
import { fetchGroups } from '../actions/groups'
|
2020-04-02 04:17:21 +01:00
|
|
|
import ColumnIndicator from '../components/column_indicator'
|
2020-03-25 03:08:43 +00:00
|
|
|
import ScrollableList from '../components/scrollable_list'
|
2020-03-04 22:26:01 +00:00
|
|
|
import GroupCollectionItem from '../components/group_collection_item'
|
2020-02-22 23:26:23 +00:00
|
|
|
|
|
|
|
const mapStateToProps = (state, { activeTab }) => ({
|
|
|
|
groupIds: state.getIn(['group_lists', activeTab]),
|
|
|
|
})
|
|
|
|
|
2020-02-25 16:04:44 +00:00
|
|
|
export default
|
|
|
|
@connect(mapStateToProps)
|
2020-02-22 23:26:23 +00:00
|
|
|
class GroupsCollection extends ImmutablePureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
activeTab: PropTypes.string.isRequired,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
groupIds: ImmutablePropTypes.list,
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillMount() {
|
|
|
|
this.props.dispatch(fetchGroups(this.props.activeTab))
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(oldProps) {
|
|
|
|
if (this.props.activeTab && this.props.activeTab !== oldProps.activeTab) {
|
|
|
|
this.props.dispatch(fetchGroups(this.props.activeTab))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { groupIds } = this.props
|
|
|
|
|
2020-04-02 04:17:21 +01:00
|
|
|
if (!groupIds) {
|
|
|
|
return <ColumnIndicator type='loading' />
|
|
|
|
}
|
2020-03-27 15:29:52 +00:00
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
return (
|
|
|
|
<div className={[_s.default, _s.flexRow, _s.flexWrap].join(' ')}>
|
2020-03-27 15:29:52 +00:00
|
|
|
{
|
|
|
|
groupIds.map((groupId, i) => (
|
|
|
|
<GroupCollectionItem key={`group-collection-item-${i}`} id={groupId} />
|
|
|
|
))
|
|
|
|
}
|
2020-02-22 23:26:23 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|