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

99 lines
2.8 KiB
JavaScript
Raw Normal View History

2020-02-28 15:20:47 +00:00
import { Fragment } from 'react'
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
import { fetchGroup } from '../actions/groups'
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
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-02-25 16:04:44 +00:00
export default
@connect(mapStateToProps)
2019-07-15 14:47:05 +01:00
class GroupPage extends ImmutablePureComponent {
2020-02-28 15:20:47 +00:00
static propTypes = {
group: ImmutablePropTypes.map,
2019-07-15 14:47:05 +01:00
relationships: ImmutablePropTypes.map,
dispatch: PropTypes.func.isRequired,
2020-02-28 15:20:47 +00:00
}
2020-03-12 16:09:15 +00:00
componentDidMount() {
const { group } = this.props
const groupTitle = !group ? '...' : group.get('title')
document.title = `Group / ${groupTitle} - Gab`
}
2019-07-15 14:47:05 +01:00
componentWillMount() {
2020-02-28 15:20:47 +00:00
const { params: { id }, dispatch } = this.props
2019-07-15 14:47:05 +01:00
2020-02-28 15:20:47 +00:00
dispatch(fetchGroup(id))
2019-07-15 14:47:05 +01:00
}
2020-02-28 15:20:47 +00:00
render() {
const { children, group, relationships } = this.props
// <div className="column-header__wrapper">
// <h1 className="column-header">
// <Link to={`/groups/${id}`} className={classNames('btn grouped active')}>
// {intl.formatMessage(messages.tabLatest)}
// </Link>
// <div className='column-header__buttons'>
// <button
// className={classNames('column-header__button', { 'active': !collapsed })}
// title={intl.formatMessage(collapsed ? messages.show : messages.hide)}
// aria-label={intl.formatMessage(collapsed ? messages.show : messages.hide)}
// aria-pressed={collapsed ? 'false' : 'true'}
// onClick={this.handleToggleClick}
// ><Icon id='sliders' /></button>
// </div>
// </h1>
// {!collapsed && <div className='column-header__collapsible'>
// <div className='column-header__collapsible-inner'>
// <div className='column-header__collapsible__extra'>
// <ColumnSettingsContainer />
// </div>
// </div>
// </div>}
// </div>
2019-07-15 14:47:05 +01:00
return (
2020-02-28 15:20:47 +00:00
<GroupLayout
2020-02-29 15:42:47 +00:00
group={group}
relationships={relationships}
2020-02-28 15:20:47 +00:00
actions={[
{
icon: 'ellipsis',
onClick: null,
},
]}
layout={(
<Fragment>
2020-02-29 15:42:47 +00:00
<GroupInfoPanel group={group} />
2020-02-28 15:20:47 +00:00
<WhoToFollowPanel />
2020-02-29 15:42:47 +00:00
<GroupSidebarPanel slim />
2020-02-28 15:20:47 +00:00
<LinkFooter />
</Fragment>
)}
showBackBtn
>
2020-02-28 15:20:47 +00:00
{
!!relationships && relationships.get('member') &&
<Fragment>
<TimelineComposeBlock size={46} group={group} autoFocus />
<Divider />
</Fragment>
}
{children}
2020-02-28 15:20:47 +00:00
</GroupLayout>
2019-07-15 14:47:05 +01:00
)
}
}