gab-social/app/javascript/gabsocial/pages/group_page.js

91 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-02-28 15:20:47 +00:00
import { Fragment } from 'react'
2020-04-11 23:29:19 +01:00
import { defineMessages, injectIntl } from 'react-intl'
2020-02-28 15:20:47 +00:00
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
import { fetchGroup } from '../actions/groups'
2020-04-11 23:29:19 +01:00
import PageTitle from '../features/ui/util/page_title'
2020-02-28 15:20:47 +00:00
import GroupInfoPanel from '../components/panel/group_info_panel'
import GroupLayout from '../layouts/group_layout'
import WhoToFollowPanel from '../components/panel/who_to_follow_panel'
2020-02-29 15:42:47 +00:00
import GroupSidebarPanel from '../components/panel/groups_panel'
2020-02-28 15:20:47 +00:00
import LinkFooter from '../components/link_footer'
import TimelineComposeBlock from '../components/timeline_compose_block'
import Divider from '../components/divider'
2019-07-15 14:47:05 +01:00
2020-04-11 23:29:19 +01:00
const messages = defineMessages({
group: { id: 'group', defaultMessage: 'Group' },
})
2019-07-15 14:47:05 +01:00
const mapStateToProps = (state, { params: { id } }) => ({
group: state.getIn(['groups', id]),
relationships: state.getIn(['group_relationships', id]),
2020-02-28 15:20:47 +00:00
})
2019-07-15 14:47:05 +01:00
2020-04-11 23:29:19 +01:00
const mapDispatchToProps = () => ({
fetchGroup,
})
2020-02-25 16:04:44 +00:00
export default
2020-04-11 23:29:19 +01:00
@injectIntl
@connect(mapStateToProps, mapDispatchToProps)
2019-07-15 14:47:05 +01:00
class GroupPage extends ImmutablePureComponent {
2020-02-28 15:20:47 +00:00
static propTypes = {
2020-04-11 23:29:19 +01:00
intl: PropTypes.object.isRequired,
2020-02-28 15:20:47 +00:00
group: ImmutablePropTypes.map,
2020-04-11 23:29:19 +01:00
chilren: PropTypes.node.isRequired,
2019-07-15 14:47:05 +01:00
relationships: ImmutablePropTypes.map,
2020-04-11 23:29:19 +01:00
fetchGroup: PropTypes.func.isRequired,
2020-03-12 16:09:15 +00:00
}
2020-04-11 23:29:19 +01:00
componentDidMount() {
this.props.fetchGroup(this.props.params.id)
2019-07-15 14:47:05 +01:00
}
2020-02-28 15:20:47 +00:00
render() {
2020-04-11 23:29:19 +01:00
const {
intl,
children,
group,
relationships,
} = this.props
2020-02-28 15:20:47 +00:00
2020-04-11 23:29:19 +01:00
const groupTitle = !!group ? group.get('title') : ''
2019-07-15 14:47:05 +01:00
return (
2020-02-28 15:20:47 +00:00
<GroupLayout
2020-04-11 23:29:19 +01:00
showBackBtn
2020-05-03 06:22:49 +01:00
title={intl.formatMessage(messages.group)}
2020-02-29 15:42:47 +00:00
group={group}
relationships={relationships}
2020-02-28 15:20:47 +00:00
actions={[
2020-05-07 05:03:34 +01:00
// : todo :
// {
// icon: 'ellipsis',
// onClick: null,
// },
2020-02-28 15:20:47 +00:00
]}
layout={(
<Fragment>
2020-02-29 15:42:47 +00:00
<GroupInfoPanel group={group} />
2020-02-28 15:20:47 +00:00
<WhoToFollowPanel />
2020-04-28 06:33:58 +01:00
<GroupSidebarPanel isSlim />
2020-02-28 15:20:47 +00:00
<LinkFooter />
</Fragment>
)}
>
2020-04-11 23:29:19 +01:00
<PageTitle path={[groupTitle, intl.formatMessage(messages.group)]} />
2020-02-28 15:20:47 +00:00
{
!!relationships && relationships.get('member') &&
<Fragment>
<TimelineComposeBlock size={46} group={group} autoFocus />
<Divider />
</Fragment>
}
2020-04-11 23:29:19 +01:00
{children}
2020-02-28 15:20:47 +00:00
</GroupLayout>
2019-07-15 14:47:05 +01:00
)
}
}