mirror of https://github.com/embarklabs/embark.git
call right function when pressing enter in ens
This commit is contained in:
parent
6589101deb
commit
29a0d5c658
|
@ -43,6 +43,14 @@ class ENS extends React.Component {
|
||||||
this.setState({ [stateName]: e.target.value });
|
this.setState({ [stateName]: e.target.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEnter(e, func) {
|
||||||
|
if (e.key !== 'Enter') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
func.apply(this, [e]);
|
||||||
|
}
|
||||||
|
|
||||||
registerSubDomain(e) {
|
registerSubDomain(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const self = this;
|
const self = this;
|
||||||
|
@ -109,7 +117,7 @@ class ENS extends React.Component {
|
||||||
return (<React.Fragment>
|
return (<React.Fragment>
|
||||||
{this.state.globalError && <Alert bsStyle="danger">{this.state.globalError}</Alert>}
|
{this.state.globalError && <Alert bsStyle="danger">{this.state.globalError}</Alert>}
|
||||||
<h3>Resolve a name</h3>
|
<h3>Resolve a name</h3>
|
||||||
<Form inline>
|
<Form inline onKeyDown={(e) => this.checkEnter(e, this.resolveName)}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
{this.state.responseResolve &&
|
{this.state.responseResolve &&
|
||||||
<Alert className="alert-result" bsStyle={this.state.isResolveError ? 'danger' : 'success'}>
|
<Alert className="alert-result" bsStyle={this.state.isResolveError ? 'danger' : 'success'}>
|
||||||
|
@ -124,7 +132,7 @@ class ENS extends React.Component {
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<h3>Lookup an address</h3>
|
<h3>Lookup an address</h3>
|
||||||
<Form inline>
|
<Form inline onKeyDown={(e) => this.checkEnter(e, this.lookupAddress)}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
{this.state.responseLookup &&
|
{this.state.responseLookup &&
|
||||||
<Alert className="alert-result" bsStyle={this.state.isLookupError ? 'danger' : 'success'}>
|
<Alert className="alert-result" bsStyle={this.state.isLookupError ? 'danger' : 'success'}>
|
||||||
|
@ -139,7 +147,7 @@ class ENS extends React.Component {
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<h3>Register subdomain for embark</h3>
|
<h3>Register subdomain for embark</h3>
|
||||||
<Form inline>
|
<Form inline onKeyDown={(e) => this.checkEnter(e, this.registerSubDomain)}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
{this.state.responseRegister &&
|
{this.state.responseRegister &&
|
||||||
<Alert className="alert-result" bsStyle={this.state.isRegisterError ? 'danger' : 'success'}>
|
<Alert className="alert-result" bsStyle={this.state.isRegisterError ? 'danger' : 'success'}>
|
||||||
|
|
Loading…
Reference in New Issue