mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-27 14:05:27 +00:00
fix(@cockpit/utils): Ensure whisper channels are at least 4 characters long
This check was already made when sending messages to whisper channel, however, we didn't perform the same check when subscribing to channels within cockpit.
This commit is contained in:
parent
322397f81c
commit
610d8f1baa
@ -22,6 +22,7 @@ class Communication extends Component {
|
||||
listenTo: '',
|
||||
channel: '',
|
||||
channelIsValid: false,
|
||||
listenToChannelIsValid: false,
|
||||
message: '',
|
||||
messageList: []
|
||||
};
|
||||
@ -32,8 +33,10 @@ class Communication extends Component {
|
||||
[name]: e.target.value
|
||||
});
|
||||
|
||||
if(name === "channel") {
|
||||
this.setState({channelIsValid: e.target.value.length >= 4});
|
||||
if (name === "channel") {
|
||||
this.setState({channelIsValid: this.isChannelValid(e.target.value)});
|
||||
} else if (name === "listenTo") {
|
||||
this.setState({listenToChannelIsValid: this.isChannelValid(e.target.value)});
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +74,7 @@ class Communication extends Component {
|
||||
onChange={e => this.handleChange(e, 'listenTo')}
|
||||
onKeyPress={e => this.handleEnter(e, this.listenToChannel.bind(this))} />
|
||||
</FormGroup>
|
||||
<Button color="primary" onClick={(e) => this.listenToChannel(e)}>Start Listening</Button>
|
||||
<Button disabled={!this.state.listenToChannelIsValid} color="primary" onClick={(e) => this.listenToChannel(e)}>Start Listening</Button>
|
||||
|
||||
{this.props.subscriptions && this.props.subscriptions.length > 0 &&
|
||||
<React.Fragment>
|
||||
@ -134,6 +137,10 @@ class Communication extends Component {
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
isChannelValid(channelName) {
|
||||
return channelName.length >= 4;
|
||||
}
|
||||
}
|
||||
|
||||
Communication.propTypes = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user