Added action buttons to emptyMessage in AccountTimeline, ListsDirectory
• Added: - action buttons to emptyMessage in AccountTimeline, ListsDirectory
This commit is contained in:
parent
6db1cf421b
commit
86dd626a8e
@ -5,8 +5,12 @@ import ImmutablePropTypes from 'react-immutable-proptypes'
|
|||||||
import ImmutablePureComponent from 'react-immutable-pure-component'
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
||||||
import { List as ImmutableList } from 'immutable'
|
import { List as ImmutableList } from 'immutable'
|
||||||
import { injectIntl, defineMessages } from 'react-intl'
|
import { injectIntl, defineMessages } from 'react-intl'
|
||||||
|
import { MODAL_COMPOSE } from '../constants'
|
||||||
import { expandAccountFeaturedTimeline, expandAccountTimeline } from '../actions/timelines'
|
import { expandAccountFeaturedTimeline, expandAccountTimeline } from '../actions/timelines'
|
||||||
|
import { openModal } from '../actions/modal'
|
||||||
import StatusList from '../components/status_list'
|
import StatusList from '../components/status_list'
|
||||||
|
import Text from '../components/text'
|
||||||
|
import Button from '../components/button'
|
||||||
|
|
||||||
class AccountTimeline extends ImmutablePureComponent {
|
class AccountTimeline extends ImmutablePureComponent {
|
||||||
|
|
||||||
@ -32,7 +36,7 @@ class AccountTimeline extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = maxId => {
|
handleLoadMore = (maxId) => {
|
||||||
if (this.props.accountId && this.props.accountId !== -1) {
|
if (this.props.accountId && this.props.accountId !== -1) {
|
||||||
this.props.dispatch(expandAccountTimeline(this.props.accountId, {
|
this.props.dispatch(expandAccountTimeline(this.props.accountId, {
|
||||||
maxId,
|
maxId,
|
||||||
@ -41,15 +45,35 @@ class AccountTimeline extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleOnOpenComposeModal = () => {
|
||||||
|
this.props.dispatch(openModal(MODAL_COMPOSE))
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
statusIds,
|
statusIds,
|
||||||
featuredStatusIds,
|
featuredStatusIds,
|
||||||
isLoading,
|
isLoading,
|
||||||
hasMore,
|
hasMore,
|
||||||
intl
|
intl,
|
||||||
|
isMe,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
|
const emptyMessage = (
|
||||||
|
<div className={[_s.d, _s.w100PC, _s.aiCenter, _s.jcCenter].join(' ')}>
|
||||||
|
<Text>{intl.formatMessage(messages.empty)}</Text>
|
||||||
|
{
|
||||||
|
isMe &&
|
||||||
|
<Button
|
||||||
|
className={[_s.d, _s.mt15].join(' ')}
|
||||||
|
onClick={this.handleOnOpenComposeModal}
|
||||||
|
>
|
||||||
|
Create a gab
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StatusList
|
<StatusList
|
||||||
scrollKey='account_timeline'
|
scrollKey='account_timeline'
|
||||||
@ -58,7 +82,7 @@ class AccountTimeline extends ImmutablePureComponent {
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={intl.formatMessage(messages.empty)}
|
emptyMessage={emptyMessage}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -94,6 +118,7 @@ AccountTimeline.propTypes = {
|
|||||||
hasMore: PropTypes.bool,
|
hasMore: PropTypes.bool,
|
||||||
commentsOnly: PropTypes.bool,
|
commentsOnly: PropTypes.bool,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
|
isMe: PropTypes.bool.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectIntl(connect(mapStateToProps)(AccountTimeline))
|
export default injectIntl(connect(mapStateToProps)(AccountTimeline))
|
@ -6,7 +6,11 @@ import ImmutablePropTypes from 'react-immutable-proptypes'
|
|||||||
import { defineMessages, injectIntl } from 'react-intl'
|
import { defineMessages, injectIntl } from 'react-intl'
|
||||||
import { getOrderedLists } from '../selectors'
|
import { getOrderedLists } from '../selectors'
|
||||||
import { fetchLists } from '../actions/lists'
|
import { fetchLists } from '../actions/lists'
|
||||||
|
import { openModal } from '../actions/modal'
|
||||||
|
import { MODAL_LIST_CREATE } from '../constants'
|
||||||
import List from '../components/list'
|
import List from '../components/list'
|
||||||
|
import Text from '../components/text'
|
||||||
|
import Button from '../components/button'
|
||||||
|
|
||||||
class ListsDirectory extends ImmutablePureComponent {
|
class ListsDirectory extends ImmutablePureComponent {
|
||||||
|
|
||||||
@ -20,11 +24,25 @@ class ListsDirectory extends ImmutablePureComponent {
|
|||||||
.catch(() => this.setState({ fetched: true }))
|
.catch(() => this.setState({ fetched: true }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleOnOpenListCreateModal = () => {
|
||||||
|
this.props.onOpenListCreateModal()
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { intl, lists } = this.props
|
const { intl, lists } = this.props
|
||||||
const { fetched } = this.state
|
const { fetched } = this.state
|
||||||
|
|
||||||
const emptyMessage = intl.formatMessage(messages.empty)
|
const emptyMessage = (
|
||||||
|
<div className={[_s.d, _s.w100PC, _s.aiCenter, _s.jcCenter].join(' ')}>
|
||||||
|
<Text>{intl.formatMessage(messages.empty)}</Text>
|
||||||
|
<Button
|
||||||
|
className={[_s.d, _s.mt15].join(' ')}
|
||||||
|
onClick={this.handleOnOpenListCreateModal}
|
||||||
|
>
|
||||||
|
Create a List
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
const listItems = lists.map(list => ({
|
const listItems = lists.map(list => ({
|
||||||
to: `/lists/${list.get('id')}`,
|
to: `/lists/${list.get('id')}`,
|
||||||
@ -48,18 +66,20 @@ const messages = defineMessages({
|
|||||||
empty: { id: 'empty_column.lists', defaultMessage: 'You don\'t have any lists yet. When you create one, it will show up here.' },
|
empty: { id: 'empty_column.lists', defaultMessage: 'You don\'t have any lists yet. When you create one, it will show up here.' },
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
|
||||||
lists: getOrderedLists(state),
|
|
||||||
})
|
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
onFetchLists: () => dispatch(fetchLists()),
|
onFetchLists: () => dispatch(fetchLists()),
|
||||||
|
onOpenListCreateModal: () => dispatch(openModal(MODAL_LIST_CREATE)),
|
||||||
|
})
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => ({
|
||||||
|
lists: getOrderedLists(state),
|
||||||
})
|
})
|
||||||
|
|
||||||
ListsDirectory.propTypes = {
|
ListsDirectory.propTypes = {
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
lists: ImmutablePropTypes.list,
|
lists: ImmutablePropTypes.list,
|
||||||
onFetchLists: PropTypes.func.isRequired,
|
onFetchLists: PropTypes.func.isRequired,
|
||||||
|
onOpenListCreateModal: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ListsDirectory))
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ListsDirectory))
|
@ -25,6 +25,7 @@ class ProfilePage extends ImmutablePureComponent {
|
|||||||
unavailable,
|
unavailable,
|
||||||
noSidebar,
|
noSidebar,
|
||||||
isBlocked,
|
isBlocked,
|
||||||
|
isMe,
|
||||||
params: { username },
|
params: { username },
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ class ProfilePage extends ImmutablePureComponent {
|
|||||||
!unavailable &&
|
!unavailable &&
|
||||||
React.cloneElement(children, {
|
React.cloneElement(children, {
|
||||||
account,
|
account,
|
||||||
|
isMe,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -68,10 +70,12 @@ const mapStateToProps = (state, { params: { username } }) => {
|
|||||||
const isFollowing = state.getIn(['relationships', accountId, 'following'], false)
|
const isFollowing = state.getIn(['relationships', accountId, 'following'], false)
|
||||||
|
|
||||||
const unavailable = (me === accountId) ? false : (isBlocked || (isLocked && !isFollowing))
|
const unavailable = (me === accountId) ? false : (isBlocked || (isLocked && !isFollowing))
|
||||||
|
const isMe = me === accountId
|
||||||
|
|
||||||
const getAccount = makeGetAccount()
|
const getAccount = makeGetAccount()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
isMe,
|
||||||
isBlocked,
|
isBlocked,
|
||||||
unavailable,
|
unavailable,
|
||||||
account: accountId !== -1 ? getAccount(state, accountId) : null,
|
account: accountId !== -1 ? getAccount(state, accountId) : null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user