diff --git a/embark-ui/src/components/Console.js b/embark-ui/src/components/Console.js
index ba1af26d9..2a9fb6966 100644
--- a/embark-ui/src/components/Console.js
+++ b/embark-ui/src/components/Console.js
@@ -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) => (
diff --git a/embark-ui/src/reducers/index.js b/embark-ui/src/reducers/index.js
index fdae3e833..cc94a0bc0 100644
--- a/embark-ui/src/reducers/index.js
+++ b/embark-ui/src/reducers/index.js
@@ -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) {
diff --git a/lib/modules/console/suggestions.js b/lib/modules/console/suggestions.js
index d7b734775..fc6a87156 100644
--- a/lib/modules/console/suggestions.js
+++ b/lib/modules/console/suggestions.js
@@ -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"}]
}