parent
5997bb47a8
commit
974d712fbe
@ -0,0 +1,32 @@ |
|||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin'; |
||||||
|
import { FormattedMessage } from 'react-intl'; |
||||||
|
import Toggle from 'react-toggle'; |
||||||
|
import Collapsable from '../../../components/collapsable'; |
||||||
|
|
||||||
|
const UnlistedToggle = React.createClass({ |
||||||
|
|
||||||
|
propTypes: { |
||||||
|
isPrivate: React.PropTypes.bool, |
||||||
|
isUnlisted: React.PropTypes.bool, |
||||||
|
isReplyToOther: React.PropTypes.bool, |
||||||
|
onChangeListability: React.PropTypes.func.isRequired |
||||||
|
}, |
||||||
|
|
||||||
|
mixins: [PureRenderMixin], |
||||||
|
|
||||||
|
render () { |
||||||
|
const { isPrivate, isUnlisted, isReplyToOther, onChangeListability } = this.props; |
||||||
|
|
||||||
|
return ( |
||||||
|
<Collapsable isVisible={!(isPrivate || isReplyToOther)} fullHeight={39.5}> |
||||||
|
<label className='compose-form__label'> |
||||||
|
<Toggle checked={isUnlisted} onChange={onChangeListability} /> |
||||||
|
<span className='compose-form__label__text'><FormattedMessage id='compose_form.unlisted' defaultMessage='Do not display on public timelines' /></span> |
||||||
|
</label> |
||||||
|
</Collapsable> |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
export default UnlistedToggle; |
@ -0,0 +1,24 @@ |
|||||||
|
import { connect } from 'react-redux'; |
||||||
|
import { cancelReplyCompose } from '../../../actions/compose'; |
||||||
|
import { makeGetStatus } from '../../../selectors'; |
||||||
|
import ReplyIndicator from '../components/reply_indicator'; |
||||||
|
|
||||||
|
const makeMapStateToProps = () => { |
||||||
|
const getStatus = makeGetStatus(); |
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => ({ |
||||||
|
status: getStatus(state, state.getIn(['compose', 'in_reply_to'])), |
||||||
|
}); |
||||||
|
|
||||||
|
return mapStateToProps; |
||||||
|
}; |
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({ |
||||||
|
|
||||||
|
onCancel () { |
||||||
|
dispatch(cancelReplyCompose()); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
export default connect(makeMapStateToProps, mapDispatchToProps)(ReplyIndicator); |
@ -0,0 +1,31 @@ |
|||||||
|
import { connect } from 'react-redux'; |
||||||
|
import UnlistedToggle from '../components/unlisted_toggle'; |
||||||
|
import { makeGetStatus } from '../../../selectors'; |
||||||
|
import { changeComposeListability } from '../../../actions/compose'; |
||||||
|
|
||||||
|
const makeMapStateToProps = () => { |
||||||
|
const getStatus = makeGetStatus(); |
||||||
|
|
||||||
|
const mapStateToProps = state => { |
||||||
|
const status = getStatus(state, state.getIn(['compose', 'in_reply_to'])); |
||||||
|
const me = state.getIn(['compose', 'me']); |
||||||
|
|
||||||
|
return { |
||||||
|
isPrivate: state.getIn(['compose', 'private']), |
||||||
|
isUnlisted: state.getIn(['compose', 'unlisted']), |
||||||
|
isReplyToOther: status ? status.getIn(['account', 'id']) !== me : false |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
return mapStateToProps; |
||||||
|
}; |
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({ |
||||||
|
|
||||||
|
onChangeListability (e) { |
||||||
|
dispatch(changeComposeListability(e.target.checked)); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
export default connect(makeMapStateToProps, mapDispatchToProps)(UnlistedToggle); |
Loading…
Reference in new issue