fix options update; add sorting
This commit is contained in:
parent
ce19fd96c4
commit
1906b17c5d
|
@ -112,16 +112,12 @@ class Console extends Component {
|
|||
}
|
||||
}}
|
||||
onSearch={(value) => {
|
||||
console.dir("searching for " + value);
|
||||
this.props.postCommandSuggestions(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"}] })
|
||||
console.dir(this.props.command_suggestions)
|
||||
this.setState({ isLoading: false, options: this.props.command_suggestions })
|
||||
}}
|
||||
filterBy={['value', 'description']}
|
||||
maxHeight="200px"
|
||||
placeholder="Type a command (e.g help)"
|
||||
options={this.state.options}
|
||||
options={this.props.command_suggestions}
|
||||
placeholder="Choose a state..."
|
||||
renderMenuItemChildren={(option) => (
|
||||
<div>
|
||||
|
|
|
@ -43,6 +43,17 @@ const sorter = {
|
|||
if (b.name === EMBARK_PROCESS_NAME) return 1;
|
||||
return 0;
|
||||
},
|
||||
command_suggestions: function(a, b) {
|
||||
if (a.value.indexOf('.').length > 0) {
|
||||
let a_levels = a.value.split('.').length
|
||||
let b_levels = b.value.split('.').length
|
||||
let diff = b_levels - a_levels
|
||||
if (diff !== 0) return lengthDiff * -1
|
||||
}
|
||||
let lengthDiff = b.value.length - a.value.length;
|
||||
if (lengthDiff !== 0) return lengthDiff * -1
|
||||
return 0;
|
||||
},
|
||||
processLogs: function(a, b) {
|
||||
if (a.name !== b.name) {
|
||||
if(a.name < b.name) return -1;
|
||||
|
@ -83,8 +94,8 @@ const filtrer = {
|
|||
return index === self.findIndex((t) => t.className === contract.className);
|
||||
},
|
||||
command_suggestions: function(command, index, self) {
|
||||
return index === self.findIndex((f) => (
|
||||
command.value === f.value
|
||||
return index === self.findIndex((c) => (
|
||||
command.value === c.value
|
||||
));
|
||||
},
|
||||
accounts: function(account, index, self) {
|
||||
|
|
|
@ -15,6 +15,13 @@ class Suggestions {
|
|||
}
|
||||
|
||||
getSuggestions(cmd) {
|
||||
if (cmd === 'web3') {
|
||||
return [
|
||||
{value: 'web3.eth', command_type: "web3 object", description: "ethereum"},
|
||||
{value: 'web3.net', command_type: "web3 object", description: "network"},
|
||||
{value: 'web3.shh', command_type: "web3 object", description: "whisper"}
|
||||
]
|
||||
}
|
||||
console.dir("printing suggestions for " + cmd);
|
||||
return [{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"}]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue