93 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-02-19 18:57:07 -05:00
import { Fragment } from 'react'
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
2020-04-16 02:00:43 -04:00
import { defineMessages, injectIntl } from 'react-intl'
2020-03-24 23:08:43 -04:00
import { openModal } from '../actions/modal'
2020-04-28 01:33:58 -04:00
import {
MODAL_LIST_EDITOR,
// MODAL_LIST_TIMELINE_SETTINGS,
} from '../constants'
2020-04-11 18:29:19 -04:00
import PageTitle from '../features/ui/util/page_title'
2020-02-19 18:57:07 -05:00
import LinkFooter from '../components/link_footer'
2020-02-24 16:56:07 -05:00
import DefaultLayout from '../layouts/default_layout'
2020-02-19 18:57:07 -05:00
import ListDetailsPanel from '../components/panel/list_details_panel'
2020-03-24 23:08:43 -04:00
import WhoToFollowPanel from '../components/panel/who_to_follow_panel'
import TrendsPanel from '../components/panel/trends_panel'
2020-02-19 18:57:07 -05:00
2020-04-16 02:00:43 -04:00
const messages = defineMessages({
list: { id: 'list', defaultMessage: 'List' },
})
2020-02-19 18:57:07 -05:00
const mapStateToProps = (state, props) => ({
list: state.getIn(['lists', props.params.id]),
2020-03-24 23:08:43 -04:00
})
2020-04-28 01:33:58 -04:00
const mapDispatchToProps = (dispatch) => ({
onOpenListEditModal(list) {
if (!list) return
const listId = list.get('id')
2020-05-03 01:22:49 -04:00
dispatch(openModal(MODAL_LIST_EDITOR, { id: listId }))
2020-03-24 23:08:43 -04:00
},
2020-04-28 01:33:58 -04:00
// : todo :
// onOpenListTimelineSettingsModal() {
// dispatch(openModal(MODAL_LIST_TIMELINE_SETTINGS))
// },
2020-03-24 23:08:43 -04:00
})
2020-02-19 18:57:07 -05:00
2020-02-25 11:04:44 -05:00
export default
2020-04-16 02:00:43 -04:00
@injectIntl
2020-03-24 23:08:43 -04:00
@connect(mapStateToProps, mapDispatchToProps)
2020-02-19 18:57:07 -05:00
class ListPage extends ImmutablePureComponent {
static propTypes = {
2020-04-16 02:00:43 -04:00
intl: PropTypes.object.isRequired,
2020-02-19 18:57:07 -05:00
list: ImmutablePropTypes.map,
2020-04-16 02:00:43 -04:00
children: PropTypes.node.isRequired,
2020-03-24 23:08:43 -04:00
onOpenListEditModal: PropTypes.func.isRequired,
2020-04-28 01:33:58 -04:00
// onOpenListTimelineSettingsModal: PropTypes.func.isRequired,
2020-03-24 23:08:43 -04:00
}
2020-03-12 12:09:15 -04:00
2020-04-28 01:33:58 -04:00
handleOnOpenListEditModal = () => {
this.props.onOpenListEditModal(this.props.list)
}
2020-02-19 18:57:07 -05:00
render() {
2020-03-24 23:08:43 -04:00
const {
2020-04-16 02:00:43 -04:00
intl,
2020-03-24 23:08:43 -04:00
children,
list,
onOpenListEditModal,
2020-04-28 01:33:58 -04:00
// onOpenListTimelineSettingsModal
2020-03-24 23:08:43 -04:00
} = this.props
2020-02-19 18:57:07 -05:00
2020-03-24 23:08:43 -04:00
const title = !!list ? list.get('title') : ''
2020-02-19 18:57:07 -05:00
return (
<DefaultLayout
2020-04-28 01:33:58 -04:00
showBackBtn
2020-05-03 01:22:49 -04:00
title={intl.formatMessage(messages.list)}
2020-02-19 18:57:07 -05:00
actions={[
2020-03-24 23:08:43 -04:00
{
2020-04-28 01:33:58 -04:00
icon: 'cog',
onClick: this.handleOnOpenListEditModal,
2020-02-19 18:57:07 -05:00
},
2020-04-28 01:33:58 -04:00
// {
// icon: 'ellipsis',
// onClick: onOpenListTimelineSettingsModal,
// },
2020-02-19 18:57:07 -05:00
]}
layout={(
<Fragment>
2020-04-28 01:33:58 -04:00
<ListDetailsPanel list={list} onEdit={this.handleOnOpenListEditModal} />
2020-03-24 23:08:43 -04:00
<TrendsPanel />
<WhoToFollowPanel />
2020-02-19 18:57:07 -05:00
<LinkFooter />
</Fragment>
)}
>
2020-04-16 02:00:43 -04:00
<PageTitle path={[title, intl.formatMessage(messages.list)]} />
2020-02-19 18:57:07 -05:00
{ children }
</DefaultLayout>
)
}
}