From df3bce145d3ca72e5bb006c5b29c45978a0319b8 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Fri, 12 Oct 2018 12:23:02 +0200 Subject: [PATCH] refactor(components/Ens): move ENS components to Utilities --- embark-ui/src/components/EnsLookup.js | 32 +++++++++------ embark-ui/src/components/EnsRegister.js | 50 ++++++++++++++---------- embark-ui/src/components/EnsResolve.js | 30 ++++++++------ embark-ui/src/containers/EnsContainer.js | 20 +++++----- 4 files changed, 77 insertions(+), 55 deletions(-) diff --git a/embark-ui/src/components/EnsLookup.js b/embark-ui/src/components/EnsLookup.js index b8446b7f3..1fcf8c44f 100644 --- a/embark-ui/src/components/EnsLookup.js +++ b/embark-ui/src/components/EnsLookup.js @@ -1,10 +1,14 @@ import React, {Component} from 'react'; +import PropTypes from 'prop-types'; import { Alert, + FormGroup, + Input, Button, - Form -} from "tabler-react"; -import PropTypes from 'prop-types'; + Card, + CardHeader, + CardBody +} from 'reactstrap'; class EnsLookup extends Component { constructor(props) { @@ -28,24 +32,26 @@ class EnsLookup extends Component { showResult() { let ensRecord = this.props.ensRecords.find((record) => record.address === this.state.address); if (ensRecord) { - return The name is: {ensRecord.name}; + return The name is: {ensRecord.name}; } else { - return We could not find a name for this address; + return We could not find a name for this address; } } render(){ return ( - -

Lookup

- - - this.handleChange(e)}/> - + + + ENS Lookup + + + + this.handleChange(e)}/> + {this.state.showResult && this.showResult()} - -
+ + ); } } diff --git a/embark-ui/src/components/EnsRegister.js b/embark-ui/src/components/EnsRegister.js index 5024dc0a4..7e309fbdb 100644 --- a/embark-ui/src/components/EnsRegister.js +++ b/embark-ui/src/components/EnsRegister.js @@ -2,8 +2,14 @@ import React, {Component} from 'react'; import { Alert, Button, - Form, Grid -} from "tabler-react"; + FormGroup, + Input, + Row, + Col, + Card, + CardHeader, + CardBody +} from "reactstrap"; import PropTypes from 'prop-types'; class EnsRegister extends Component { @@ -31,33 +37,35 @@ class EnsRegister extends Component { showResult() { if (this.props.ensErrors) { - return An error happened: {this.props.ensErrors}; + return An error happened: {this.props.ensErrors}; } else { - return Successfully registered; + return Successfully registered; } } render(){ return ( - -

Register

- - - - - this.handleChange(e, "subdomain")}/> - - - - - this.handleChange(e, "address")}/> - - - + + + ENS Register + + + + + + this.handleChange(e, "subdomain")}/> + + + + + this.handleChange(e, "address")}/> + + + - {this.state.showResult && this.showResult()} -
+ + ); } } diff --git a/embark-ui/src/components/EnsResolve.js b/embark-ui/src/components/EnsResolve.js index 879bacbde..4d8c4b882 100644 --- a/embark-ui/src/components/EnsResolve.js +++ b/embark-ui/src/components/EnsResolve.js @@ -2,8 +2,12 @@ import React, {Component} from 'react'; import { Alert, Button, - Form -} from "tabler-react"; + FormGroup, + Input, + Card, + CardHeader, + CardBody +} from "reactstrap"; import PropTypes from 'prop-types'; class EnsResolve extends Component { @@ -28,24 +32,26 @@ class EnsResolve extends Component { showResult() { let ensRecord = this.props.ensRecords.find((record) => record.name === this.state.name); if (ensRecord) { - return The address is: {ensRecord.address}; + return The address is: {ensRecord.address}; } else { - return We could not find an address for this name; + return We could not find an address for this name; } } render(){ return ( - -

Resolve

- - - this.handleChange(e)}/> - + + + ENS Resolver + + + + this.handleChange(e)}/> + {this.state.showResult && this.showResult()} - -
+ + ); } } diff --git a/embark-ui/src/containers/EnsContainer.js b/embark-ui/src/containers/EnsContainer.js index 630991f85..68a7e0d6b 100644 --- a/embark-ui/src/containers/EnsContainer.js +++ b/embark-ui/src/containers/EnsContainer.js @@ -1,7 +1,7 @@ import PropTypes from "prop-types"; import React, {Component} from 'react'; import connect from "react-redux/es/connect/connect"; -import {Alert, Page} from "tabler-react"; +import {Alert, Row, Col} from 'reactstrap'; import {ensRecord, ensRecords} from "../actions"; import EnsRegister from "../components/EnsRegister"; import EnsLookup from "../components/EnsLookup"; @@ -12,23 +12,25 @@ class EnsContainer extends Component { showEns() { return ( - - - - - + + + + + + + ); } showWarning() { - return Please enable Ens in Embark first; + return Please enable Ens in Embark first; } render() { return ( - + {this.props.isEnsEnabled ? this.showEns() : this.showWarning()} - + ); } }