2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-02-19 23:57:07 +00:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
2020-04-16 07:00:43 +01:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
2020-03-25 03:08:43 +00:00
|
|
|
import { openModal } from '../actions/modal'
|
2020-04-28 06:33:58 +01:00
|
|
|
import {
|
|
|
|
MODAL_LIST_EDITOR,
|
|
|
|
} from '../constants'
|
2020-04-11 23:29:19 +01:00
|
|
|
import PageTitle from '../features/ui/util/page_title'
|
2020-02-24 21:56:07 +00:00
|
|
|
import DefaultLayout from '../layouts/default_layout'
|
2020-08-12 23:52:46 +01:00
|
|
|
import WrappedBundle from '../features/ui/util/wrapped_bundle'
|
|
|
|
import {
|
|
|
|
ListDetailsPanel,
|
|
|
|
LinkFooter,
|
|
|
|
TrendsPanel,
|
2020-09-01 17:54:01 +01:00
|
|
|
UserSuggestionsPanel,
|
2020-08-12 23:52:46 +01:00
|
|
|
} from '../features/ui/util/async_components'
|
2020-02-19 23:57:07 +00:00
|
|
|
|
|
|
|
class ListPage extends ImmutablePureComponent {
|
2020-03-12 16:09:15 +00:00
|
|
|
|
2020-08-14 18:45:59 +01:00
|
|
|
onOpenListEditModal = () => {
|
|
|
|
const { list } = this.props
|
|
|
|
|
|
|
|
if (!list) return
|
|
|
|
|
|
|
|
this.props.dispatch(openModal(MODAL_LIST_EDITOR, {
|
|
|
|
id: list.get('id'),
|
|
|
|
}))
|
2020-04-28 06:33:58 +01:00
|
|
|
}
|
|
|
|
|
2020-02-19 23:57:07 +00:00
|
|
|
render() {
|
2020-03-25 03:08:43 +00:00
|
|
|
const {
|
|
|
|
children,
|
2020-08-14 18:45:59 +01:00
|
|
|
intl,
|
2020-03-25 03:08:43 +00:00
|
|
|
list,
|
|
|
|
} = this.props
|
2020-02-19 23:57:07 +00:00
|
|
|
|
2020-08-14 18:45:59 +01:00
|
|
|
const listTitle = !!list ? list.get('title') : ''
|
|
|
|
const title = intl.formatMessage(messages.list)
|
2020-02-19 23:57:07 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<DefaultLayout
|
2020-04-28 06:33:58 +01:00
|
|
|
showBackBtn
|
2020-08-14 18:45:59 +01:00
|
|
|
title={title}
|
2020-07-16 05:05:08 +01:00
|
|
|
page='list'
|
2020-02-19 23:57:07 +00:00
|
|
|
actions={[
|
2020-03-25 03:08:43 +00:00
|
|
|
{
|
2020-04-28 06:33:58 +01:00
|
|
|
icon: 'cog',
|
2020-08-14 18:45:59 +01:00
|
|
|
onClick: this.onOpenListEditModal,
|
2020-02-19 23:57:07 +00:00
|
|
|
},
|
|
|
|
]}
|
2020-07-16 05:05:08 +01:00
|
|
|
layout={[
|
2020-08-12 23:52:46 +01:00
|
|
|
<WrappedBundle component={ListDetailsPanel} componentParams={{ list: list, onEdit: this.handleOnOpenListEditModal }} />,
|
|
|
|
TrendsPanel,
|
2020-09-01 17:54:01 +01:00
|
|
|
UserSuggestionsPanel,
|
2020-08-12 23:52:46 +01:00
|
|
|
LinkFooter,
|
2020-07-16 05:05:08 +01:00
|
|
|
]}
|
2020-02-19 23:57:07 +00:00
|
|
|
>
|
2020-08-14 18:45:59 +01:00
|
|
|
<PageTitle path={[listTitle, title]} />
|
2020-02-19 23:57:07 +00:00
|
|
|
{ children }
|
|
|
|
</DefaultLayout>
|
|
|
|
)
|
|
|
|
}
|
2020-08-14 18:45:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
list: { id: 'list', defaultMessage: 'List' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
list: state.getIn(['lists', props.params.id]),
|
|
|
|
})
|
|
|
|
|
|
|
|
ListPage.propTypes = {
|
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
list: ImmutablePropTypes.map,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps)(ListPage))
|