mirror of https://github.com/embarklabs/embark.git
fix vairous bugs with submitting command; support more complex suggestions
This commit is contained in:
parent
06ac5315a5
commit
b2ef42df32
|
@ -25,8 +25,8 @@ class Console extends Component {
|
||||||
this.typeahead.getInstance().clear()
|
this.typeahead.getInstance().clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange(value) {
|
handleChange(value, cb) {
|
||||||
this.setState({value: value});
|
this.setState({value: value}, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(tab) {
|
toggle(tab) {
|
||||||
|
@ -89,7 +89,6 @@ class Console extends Component {
|
||||||
</Card.Body>
|
</Card.Body>
|
||||||
{this.props.isEmbark() && <Card.Footer>
|
{this.props.isEmbark() && <Card.Footer>
|
||||||
<AsyncTypeahead
|
<AsyncTypeahead
|
||||||
search={value}
|
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
emptyLabel={false}
|
emptyLabel={false}
|
||||||
labelKey="value"
|
labelKey="value"
|
||||||
|
@ -97,20 +96,25 @@ class Console extends Component {
|
||||||
emptyLabel={false}
|
emptyLabel={false}
|
||||||
maxResults={10}
|
maxResults={10}
|
||||||
isLoading={this.state.isLoading}
|
isLoading={this.state.isLoading}
|
||||||
defaultInputValue={value}
|
|
||||||
onInputChange={(text) => this.handleChange(text)}
|
onInputChange={(text) => this.handleChange(text)}
|
||||||
|
onChange={(text) => {
|
||||||
|
if (text && text[0]) {
|
||||||
|
this.handleChange(text[0].value)
|
||||||
|
}
|
||||||
|
}}
|
||||||
ref={(typeahead) => this.typeahead = typeahead}
|
ref={(typeahead) => this.typeahead = typeahead}
|
||||||
searchText={false}
|
searchText={false}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
|
this.handleChange(e.target.value, () => {
|
||||||
this.handleSubmit(e)
|
this.handleSubmit(e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onSearch={(value) => {
|
onSearch={(value) => {
|
||||||
console.dir(value);
|
|
||||||
this.setState({ isLoading: false, options: [{value: 'hello', command_type: "embark", description: "says hello back!"}, {value: 'SimpleStorage', command_type: "web3 object", description: ""}, {value: 'web3.eth.getAccounts', command_type: "web3", description: "get list of accounts"}] })
|
this.setState({ isLoading: false, options: [{value: 'hello', command_type: "embark", description: "says hello back!"}, {value: 'SimpleStorage', command_type: "web3 object", description: ""}, {value: 'web3.eth.getAccounts', command_type: "web3", description: "get list of accounts"}] })
|
||||||
}}
|
}}
|
||||||
filterBy={['value']}
|
filterBy={['value', 'description']}
|
||||||
maxHeight="200px"
|
maxHeight="200px"
|
||||||
placeholder="Type a command (e.g help)"
|
placeholder="Type a command (e.g help)"
|
||||||
options={this.state.options}
|
options={this.state.options}
|
||||||
|
@ -123,7 +127,6 @@ class Console extends Component {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</Card.Footer>}
|
</Card.Footer>}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
Loading…
Reference in New Issue