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

82 lines
2.0 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 GroupLayout from '../layouts/group_layout'
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-05-09 03:17:19 +01:00
const mapDispatchToProps = (dispatch) => ({
onFetchGroup(groupId) {
dispatch(fetchGroup(groupId))
}
2020-04-11 23:29:19 +01:00
})
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-05-07 06:55:24 +01:00
children: PropTypes.node.isRequired,
2019-07-15 14:47:05 +01:00
relationships: ImmutablePropTypes.map,
2020-05-09 03:17:19 +01:00
onFetchGroup: PropTypes.func.isRequired,
2020-03-12 16:09:15 +00:00
}
2020-04-11 23:29:19 +01:00
componentDidMount() {
2020-05-09 03:17:19 +01:00
console.log("group page mounted:", this.props.params.id)
this.props.onFetchGroup(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
]}
>
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
)
}
}