Skip to content
Permalink
Browse files

Add secondary toot button

* 正確には3つ
  • Loading branch information...
yuzulabo committed Jun 1, 2019
1 parent a47a7eb commit 036f69fba1dd6daa618b059af18cf1014d069693
@@ -60,6 +60,7 @@ class ComposeForm extends ImmutablePureComponent {
onPickEmoji: PropTypes.func.isRequired,
showSearch: PropTypes.bool,
anyMedia: PropTypes.bool,
onChangeVisibility: PropTypes.func.isRequired,
};

static defaultProps = {
@@ -94,6 +95,11 @@ class ComposeForm extends ImmutablePureComponent {
this.props.onSubmit(this.context.router ? this.context.router.history : null);
}

handleSecondarySubmit = privacy => {
this.props.onChangeVisibility(privacy);
this.handleSubmit();
}

onSuggestionsClearRequested = () => {
this.props.onClearSuggestions();
}
@@ -176,6 +182,11 @@ class ComposeForm extends ImmutablePureComponent {
publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish);
}

const secondaryVisibilities = [
{ value: 'private', icon: 'lock' },
{ value: 'unlisted', icon: 'unlock' }
];

return (
<div className='compose-form'>
<WarningContainer />
@@ -235,6 +246,14 @@ class ComposeForm extends ImmutablePureComponent {
</div>

<div className='compose-form__publish'>
{secondaryVisibilities.map(privacy => (
<div className='compose-form__publish-button-wrapper' style={{ marginRight: '10px' }}>
<Button onClick={() => this.handleSecondarySubmit(privacy.value)} disabled={disabledButton} block>
<Icon id={privacy.icon} />
</Button>
</div>
))}

<div className='compose-form__publish-button-wrapper'><Button text={publishText} onClick={this.handleSubmit} disabled={disabledButton} block /></div>
</div>
</div>
@@ -9,6 +9,7 @@ import {
changeComposeSpoilerText,
insertEmojiCompose,
uploadCompose,
changeComposeVisibility,
} from '../../../actions/compose';

const mapStateToProps = state => ({
@@ -61,6 +62,10 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(insertEmojiCompose(position, data, needsSpace));
},

onChangeVisibility(value) {
dispatch(changeComposeVisibility(value));
},

});

export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);

0 comments on commit 036f69f

Please sign in to comment.
You can’t perform that action at this time.