73 lines
1.4 KiB
JavaScript
73 lines
1.4 KiB
JavaScript
|
import { defineMessages, injectIntl } from 'react-intl'
|
||
|
import { openPopover } from '../../../actions/popover'
|
||
|
import ComposeExtraButton from './compose_extra_button'
|
||
|
|
||
|
const messages = defineMessages({
|
||
|
visibility: { id: 'privacy.visibility', defaultMessage: 'Visibility' },
|
||
|
})
|
||
|
|
||
|
const mapStateToProps = (state) => ({
|
||
|
value: state.getIn(['compose', 'privacy']),
|
||
|
})
|
||
|
|
||
|
const mapDispatchToProps = (dispatch) => ({
|
||
|
onOpenPopover(targetRef) {
|
||
|
dispatch(openPopover('STATUS_VISIBILITY', {
|
||
|
targetRef,
|
||
|
}))
|
||
|
},
|
||
|
})
|
||
|
|
||
|
export default
|
||
|
@connect(mapStateToProps, mapDispatchToProps)
|
||
|
@injectIntl
|
||
|
class StatusVisibilityButton extends PureComponent {
|
||
|
|
||
|
static propTypes = {
|
||
|
onClick: PropTypes.func.isRequired,
|
||
|
intl: PropTypes.object.isRequired,
|
||
|
small: PropTypes.bool,
|
||
|
onOpenPopover: PropTypes.func.isRequired,
|
||
|
}
|
||
|
|
||
|
handleOnClick = () => {
|
||
|
this.props.onOpenPopover(this.button)
|
||
|
}
|
||
|
|
||
|
setButton = (n) => {
|
||
|
this.button = n
|
||
|
}
|
||
|
|
||
|
render() {
|
||
|
const {
|
||
|
intl,
|
||
|
small,
|
||
|
value
|
||
|
} = this.props
|
||
|
|
||
|
let icon;
|
||
|
switch (value) {
|
||
|
case 'unlisted':
|
||
|
icon = 'unlock'
|
||
|
break;
|
||
|
case 'private':
|
||
|
icon = 'lock'
|
||
|
break;
|
||
|
default:
|
||
|
icon = 'globe'
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<ComposeExtraButton
|
||
|
icon={icon}
|
||
|
title={intl.formatMessage(messages.visibility)}
|
||
|
onClick={this.handleOnClick}
|
||
|
small={small}
|
||
|
buttonRef={this.setButton}
|
||
|
/>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
}
|