about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/compose/containers/spoiler_button_container.jsx
blob: b1c80fe1963f841933647b8759d92d0811749e29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { connect } from 'react-redux';
import TextIconButton from '../components/text_icon_button';
import { changeComposeSpoilerness } from '../../../actions/compose';
import { injectIntl, defineMessages } from 'react-intl';

const messages = defineMessages({
  title: { id: 'compose_form.spoiler', defaultMessage: 'Hide text behind warning' }
});

const mapStateToProps = (state, { intl }) => ({
  label: 'CW',
  title: intl.formatMessage(messages.title),
  active: state.getIn(['compose', 'spoiler']),
  ariaControls: 'cw-spoiler-input'
});

const mapDispatchToProps = dispatch => ({

  onClick () {
    dispatch(changeComposeSpoilerness());
  }

});

export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));