2020-08-07 23:59:39 +01:00
|
|
|
import { Fragment } from 'react'
|
2020-04-02 04:17:21 +01:00
|
|
|
import { me } from '../initial_state'
|
2020-04-11 23:29:19 +01:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import PageTitle from '../features/ui/util/page_title'
|
2020-02-22 23:26:23 +00:00
|
|
|
import LinkFooter from '../components/link_footer'
|
2020-08-07 23:59:39 +01:00
|
|
|
import Text from '../components/text'
|
2020-02-22 23:26:23 +00:00
|
|
|
import GroupsPanel from '../components/panel/groups_panel'
|
2020-02-24 21:56:07 +00:00
|
|
|
import DefaultLayout from '../layouts/default_layout'
|
2020-08-07 23:59:39 +01:00
|
|
|
import GroupsCollection from '../features/groups_collection'
|
2020-02-22 23:26:23 +00:00
|
|
|
|
2020-04-11 23:29:19 +01:00
|
|
|
const messages = defineMessages({
|
|
|
|
groups: { id: 'groups', defaultMessage: 'Groups' },
|
2020-08-06 06:13:19 +01:00
|
|
|
new: { id: 'new', defaultMessage: 'Recently Added Groups' },
|
|
|
|
featured: { id: 'featured', defaultMessage: 'Featured Groups' },
|
|
|
|
myGroupsTimeline: { id: 'my_groups_timeline', defaultMessage: 'Timeline' },
|
2020-04-11 23:29:19 +01:00
|
|
|
myGroups: { id: 'my_groups', defaultMessage: 'My Groups' },
|
|
|
|
admin: { id: 'admin', defaultMessage: 'Admin' },
|
|
|
|
})
|
2020-04-02 04:17:21 +01:00
|
|
|
|
2020-04-11 23:29:19 +01:00
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
isPro: state.getIn(['accounts', me, 'is_pro']),
|
|
|
|
})
|
2020-03-25 03:08:43 +00:00
|
|
|
|
|
|
|
export default
|
2020-04-11 23:29:19 +01:00
|
|
|
@injectIntl
|
2020-08-06 06:13:19 +01:00
|
|
|
@connect(mapStateToProps)
|
2020-03-25 03:08:43 +00:00
|
|
|
class GroupsPage extends PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
2020-08-07 23:59:39 +01:00
|
|
|
activeTab: PropTypes.string.isRequired,
|
2020-04-11 23:29:19 +01:00
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
children: PropTypes.node.isRequired,
|
2020-04-02 04:17:21 +01:00
|
|
|
isPro: PropTypes.bool,
|
2020-05-07 05:03:34 +01:00
|
|
|
}
|
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
render() {
|
2020-04-11 23:29:19 +01:00
|
|
|
const {
|
2020-08-07 23:59:39 +01:00
|
|
|
activeTab,
|
2020-04-11 23:29:19 +01:00
|
|
|
intl,
|
|
|
|
children,
|
|
|
|
isPro,
|
|
|
|
} = this.props
|
2020-02-22 23:26:23 +00:00
|
|
|
|
2020-08-07 23:59:39 +01:00
|
|
|
const dontShowChildren = (activeTab === 'timeline' && !me)
|
|
|
|
|
2020-08-06 06:13:19 +01:00
|
|
|
const actions = isPro ? [
|
2020-05-07 05:03:34 +01:00
|
|
|
{
|
|
|
|
icon: 'add',
|
2020-08-06 06:13:19 +01:00
|
|
|
to: '/groups/create',
|
2020-05-07 05:03:34 +01:00
|
|
|
},
|
2020-08-06 06:13:19 +01:00
|
|
|
] : []
|
|
|
|
|
2020-07-25 03:41:50 +01:00
|
|
|
const tabs = !!me ? [
|
2020-02-22 23:26:23 +00:00
|
|
|
{
|
2020-08-08 19:08:48 +01:00
|
|
|
title: intl.formatMessage(messages.myGroupsTimeline),
|
2020-04-08 02:06:59 +01:00
|
|
|
to: '/groups',
|
2020-02-22 23:26:23 +00:00
|
|
|
},
|
|
|
|
{
|
2020-04-11 23:29:19 +01:00
|
|
|
title: intl.formatMessage(messages.myGroups),
|
2020-04-08 02:06:59 +01:00
|
|
|
to: '/groups/browse/member',
|
2020-02-22 23:26:23 +00:00
|
|
|
},
|
2020-08-06 06:13:19 +01:00
|
|
|
{
|
|
|
|
title: intl.formatMessage(messages.featured),
|
|
|
|
to: '/groups/browse/featured',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: intl.formatMessage(messages.new),
|
|
|
|
to: '/groups/browse/new',
|
|
|
|
},
|
2020-07-25 03:41:50 +01:00
|
|
|
] : []
|
2020-04-02 04:17:21 +01:00
|
|
|
|
|
|
|
if (isPro) {
|
|
|
|
tabs.push({
|
2020-04-11 23:29:19 +01:00
|
|
|
title: intl.formatMessage(messages.admin),
|
2020-04-08 02:06:59 +01:00
|
|
|
to: '/groups/browse/admin',
|
2020-04-02 04:17:21 +01:00
|
|
|
})
|
|
|
|
}
|
2020-02-22 23:26:23 +00:00
|
|
|
|
2020-04-11 23:29:19 +01:00
|
|
|
const title = intl.formatMessage(messages.groups)
|
2020-08-07 23:59:39 +01:00
|
|
|
|
|
|
|
const layout = []
|
|
|
|
if (!!me) {
|
|
|
|
layout.push(<GroupsPanel key='groups-page-groups-panel' groupType='member' />)
|
|
|
|
}
|
|
|
|
layout.push(<LinkFooter key='groups-page-link-footer' />)
|
2020-04-11 23:29:19 +01:00
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
return (
|
|
|
|
<DefaultLayout
|
2020-04-11 23:29:19 +01:00
|
|
|
title={title}
|
2020-04-02 04:17:21 +01:00
|
|
|
actions={actions}
|
2020-04-28 06:33:58 +01:00
|
|
|
tabs={tabs}
|
2020-07-16 05:05:08 +01:00
|
|
|
page='groups'
|
2020-08-07 23:59:39 +01:00
|
|
|
layout={layout}
|
2020-02-22 23:26:23 +00:00
|
|
|
>
|
2020-04-11 23:29:19 +01:00
|
|
|
<PageTitle path={title} />
|
2020-08-07 23:59:39 +01:00
|
|
|
|
|
|
|
{ !dontShowChildren && children }
|
|
|
|
|
|
|
|
{
|
|
|
|
dontShowChildren &&
|
|
|
|
<GroupsCollection activeTab='featured' />
|
|
|
|
}
|
2020-02-22 23:26:23 +00:00
|
|
|
</DefaultLayout>
|
|
|
|
)
|
|
|
|
}
|
2020-04-08 02:06:59 +01:00
|
|
|
|
2020-08-06 06:13:19 +01:00
|
|
|
}
|