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-08 06:12:01 +00:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl'
|
|
|
|
import { changeComposeSpoilerness } from '../../../actions/compose'
|
|
|
|
import ComposeExtraButton from './compose_extra_button'
|
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class SpoilerButton extends React.PureComponent {
|
2020-02-08 06:12:01 +00:00
|
|
|
|
|
|
|
handleClick = (e) => {
|
|
|
|
e.preventDefault()
|
|
|
|
this.props.onClick()
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2020-02-28 15:20:47 +00:00
|
|
|
const { active, intl, small } = this.props
|
2020-02-08 06:12:01 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ComposeExtraButton
|
|
|
|
title={intl.formatMessage(messages.title)}
|
|
|
|
icon='warning'
|
|
|
|
onClick={this.handleClick}
|
2020-02-28 15:20:47 +00:00
|
|
|
small={small}
|
2020-03-07 04:53:28 +00:00
|
|
|
active={active}
|
2020-12-10 16:51:45 +00:00
|
|
|
iconClassName={_s.cIconComposeSpoiler}
|
2020-02-08 06:12:01 +00:00
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-17 23:06:22 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' },
|
|
|
|
unmarked: { id: 'compose_form.spoiler.unmarked', defaultMessage: 'Text is not hidden' },
|
|
|
|
title: { id: 'compose_form.spoiler.title', defaultMessage: 'Warning' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
active: state.getIn(['compose', 'spoiler']),
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onClick () {
|
|
|
|
dispatch(changeComposeSpoilerness())
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
SpoilerButton.propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
small: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SpoilerButton))
|