Updated AccountActionButton to show "Edit Profile" for current user
• Updated: - AccountActionButton to show "Edit Profile" for current user
This commit is contained in:
parent
dd00db13bc
commit
be9d08d590
@ -22,6 +22,7 @@ const messages = defineMessages({
|
|||||||
blocked: { id: 'account.blocked', defaultMessage: 'Blocked' },
|
blocked: { id: 'account.blocked', defaultMessage: 'Blocked' },
|
||||||
followers: { id: 'account.followers', defaultMessage: 'Followers' },
|
followers: { id: 'account.followers', defaultMessage: 'Followers' },
|
||||||
follows: { id: 'account.follows', defaultMessage: 'Follows' },
|
follows: { id: 'account.follows', defaultMessage: 'Follows' },
|
||||||
|
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
@ -86,53 +87,62 @@ class AccountActionButton extends ImmutablePureComponent {
|
|||||||
|
|
||||||
if (!account) return null
|
if (!account) return null
|
||||||
|
|
||||||
// Wait until the relationship is loaded
|
const isMe = account.get('id') === me
|
||||||
if (!account.get('relationship')) return null
|
|
||||||
|
// Wait until the relationship is loaded unless me
|
||||||
// Don't show if is me
|
if (!account.get('relationship') && !isMe) return null
|
||||||
if (account.get('id') === me) return null
|
|
||||||
|
|
||||||
const isBlockedBy = account.getIn(['relationship', 'blocked_by'])
|
|
||||||
|
|
||||||
// Don't show
|
|
||||||
if (isBlockedBy) return null
|
|
||||||
|
|
||||||
let buttonText = ''
|
let buttonText = ''
|
||||||
let buttonOptions = {}
|
let buttonOptions = {}
|
||||||
|
|
||||||
const isRequested = account.getIn(['relationship', 'requested'])
|
if (isMe) {
|
||||||
const isBlocking = account.getIn(['relationship', 'blocking'])
|
buttonText = intl.formatMessage(messages.edit_profile)
|
||||||
const isFollowing = account.getIn(['relationship', 'following'])
|
|
||||||
|
|
||||||
if (isRequested) {
|
|
||||||
buttonText = intl.formatMessage(messages.requested)
|
|
||||||
buttonOptions = {
|
buttonOptions = {
|
||||||
onClick: this.handleFollow,
|
href: '/settings/profile',
|
||||||
color: 'primary',
|
|
||||||
backgroundColor: 'tertiary',
|
|
||||||
}
|
|
||||||
} else if (isBlocking) {
|
|
||||||
buttonText = intl.formatMessage(messages.blocked)
|
|
||||||
buttonOptions = {
|
|
||||||
onClick: this.handleBlock,
|
|
||||||
color: 'white',
|
|
||||||
backgroundColor: 'danger',
|
|
||||||
}
|
|
||||||
} else if (isFollowing) {
|
|
||||||
buttonText = intl.formatMessage(messages.following)
|
|
||||||
buttonOptions = {
|
|
||||||
onClick: this.handleFollow,
|
|
||||||
color: 'white',
|
|
||||||
backgroundColor: 'brand',
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
buttonText = intl.formatMessage(messages.follow)
|
|
||||||
buttonOptions = {
|
|
||||||
onClick: this.handleFollow,
|
|
||||||
color: 'brand',
|
color: 'brand',
|
||||||
backgroundColor: 'none',
|
backgroundColor: 'none',
|
||||||
isOutline: true,
|
isOutline: true,
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const isBlockedBy = account.getIn(['relationship', 'blocked_by'])
|
||||||
|
|
||||||
|
// Don't show
|
||||||
|
if (isBlockedBy) return null
|
||||||
|
|
||||||
|
const isRequested = account.getIn(['relationship', 'requested'])
|
||||||
|
const isBlocking = account.getIn(['relationship', 'blocking'])
|
||||||
|
const isFollowing = account.getIn(['relationship', 'following'])
|
||||||
|
|
||||||
|
if (isRequested) {
|
||||||
|
buttonText = intl.formatMessage(messages.requested)
|
||||||
|
buttonOptions = {
|
||||||
|
onClick: this.handleFollow,
|
||||||
|
color: 'primary',
|
||||||
|
backgroundColor: 'tertiary',
|
||||||
|
}
|
||||||
|
} else if (isBlocking) {
|
||||||
|
buttonText = intl.formatMessage(messages.blocked)
|
||||||
|
buttonOptions = {
|
||||||
|
onClick: this.handleBlock,
|
||||||
|
color: 'white',
|
||||||
|
backgroundColor: 'danger',
|
||||||
|
}
|
||||||
|
} else if (isFollowing) {
|
||||||
|
buttonText = intl.formatMessage(messages.following)
|
||||||
|
buttonOptions = {
|
||||||
|
onClick: this.handleFollow,
|
||||||
|
color: 'white',
|
||||||
|
backgroundColor: 'brand',
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buttonText = intl.formatMessage(messages.follow)
|
||||||
|
buttonOptions = {
|
||||||
|
onClick: this.handleFollow,
|
||||||
|
color: 'brand',
|
||||||
|
backgroundColor: 'none',
|
||||||
|
isOutline: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const textClassName = isSmall ? null : _s.px10
|
const textClassName = isSmall ? null : _s.px10
|
||||||
|
Loading…
Reference in New Issue
Block a user