From 0e4cb11ab6772be274c54de11f6b5861ab971113 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Fri, 12 Oct 2018 11:53:49 +0200 Subject: [PATCH] refactor(components/Communications): move component to Utilities --- embark-ui/src/components/Communication.js | 137 ++++++++++-------- embark-ui/src/components/Converter.js | 4 +- embark-ui/src/components/ExplorerLayout.js | 8 +- embark-ui/src/components/Layout.js | 6 +- embark-ui/src/components/UtilsLayout.js | 4 + .../src/containers/CommunicationContainer.js | 10 +- 6 files changed, 95 insertions(+), 74 deletions(-) diff --git a/embark-ui/src/components/Communication.js b/embark-ui/src/components/Communication.js index 3ecc897fb..ca93bd43a 100644 --- a/embark-ui/src/components/Communication.js +++ b/embark-ui/src/components/Communication.js @@ -1,6 +1,18 @@ import PropTypes from "prop-types"; import React, {Component} from 'react'; -import {Button, Form, Card, Grid, List} from 'tabler-react'; +import { + Button, + Card, + CardBody, + CardHeader, + Col, + FormGroup, + Input, + Row, + Label, + ListGroup, + ListGroupItem +} from 'reactstrap'; class Communication extends Component { constructor(props) { @@ -32,66 +44,77 @@ class Communication extends Component { render() { return ( - -

Listen To channel

- - - this.handleChange(e, 'listenTo')}/> - - - + + + + + Listen to channel + + + + + this.handleChange(e, 'listenTo')} /> + + - {this.props.subscriptions && this.props.subscriptions.length > 0 && -
-

Subscribed channels:

- - {this.props.subscriptions.map((item, i) => {item})} - -
- } + {this.props.subscriptions && this.props.subscriptions.length > 0 && + +

Subscribed channels:

+ + {this.props.subscriptions.map((item, i) => {item})} + +
+ } - {this.props.channels && Boolean(Object.keys(this.props.channels).length) && - -

Messages received:

+ {this.props.channels && Boolean(Object.keys(this.props.channels).length) && + +

Messages received:

- - {Object.keys(this.props.channels).map((channelName, i) => { - return ( - - - {this.props.channels[channelName].map((data, f) => { - return

{data.message}

; - })} -
-
-
); - })} -
-
- } + + {Object.keys(this.props.channels).map((channelName, i) => { + return ( + + + {channelName} + + + {this.props.channels[channelName].map((data, f) => { + return

{data.message}

; + })} +
+
+ ); + })} +
+
+ } +
+
+ + + Send message + + + + + this.handleChange(e, 'channel')}/> + + + + this.handleChange(e, 'message')}/> + + -

Send Message

- - - - this.handleChange(e, 'channel')}/> - - - this.handleChange(e, 'message')}/> - - - - -
+ + + + ); } } diff --git a/embark-ui/src/components/Converter.js b/embark-ui/src/components/Converter.js index ee420d4c5..4d5a30015 100644 --- a/embark-ui/src/components/Converter.js +++ b/embark-ui/src/components/Converter.js @@ -37,7 +37,7 @@ class Converter extends React.Component { render() { return( - + Ether Converter @@ -71,4 +71,4 @@ Converter.propTypes = { updateBaseEther: PropTypes.func }; -export default Converter; \ No newline at end of file +export default Converter; diff --git a/embark-ui/src/components/ExplorerLayout.js b/embark-ui/src/components/ExplorerLayout.js index a3df79d45..2b085595c 100644 --- a/embark-ui/src/components/ExplorerLayout.js +++ b/embark-ui/src/components/ExplorerLayout.js @@ -12,15 +12,11 @@ import BlocksContainer from '../containers/BlocksContainer'; import BlockContainer from '../containers/BlockContainer'; import TransactionsContainer from '../containers/TransactionsContainer'; import TransactionContainer from '../containers/TransactionContainer'; -import CommunicationContainer from '../containers/CommunicationContainer'; -import EnsContainer from '../containers/EnsContainer'; const groupItems = [ {to: "/embark/explorer/accounts", icon: "users", value: "Accounts"}, {to: "/embark/explorer/blocks", icon: "book-open", value: "Blocks"}, - {to: "/embark/explorer/transactions", icon: "activity", value: "Transactions"}, - {to: "/embark/explorer/communication", icon: "phone-call", value: "Communication"}, - {to: "/embark/explorer/ens", icon: "disc", value: "ENS"} + {to: "/embark/explorer/transactions", icon: "activity", value: "Transactions"} ]; const className = "d-flex align-items-center"; @@ -53,8 +49,6 @@ const ExplorerLayout = () => ( - - diff --git a/embark-ui/src/components/Layout.js b/embark-ui/src/components/Layout.js index 639f2548d..a6eaaccbf 100644 --- a/embark-ui/src/components/Layout.js +++ b/embark-ui/src/components/Layout.js @@ -27,13 +27,13 @@ const sidebarNavItems = {items: [ {url: "/embark/explorer/accounts", icon: "fa fa-users", name: "Accounts"}, {url: "/embark/explorer/blocks", icon: "fa fa-stop", name: "Blocks"}, {url: "/embark/explorer/transactions", icon: "fa fa-tree", name: "Transactions"}, - {url: "/embark/explorer/communication", icon: "fa fa-phone", name: "Communication"}, - {url: "/embark/explorer/ens", icon: "fa fa-circle", name: "ENS"} ]}, {name: "Fiddle", url: "/embark/fiddle", icon: "fa fa-codepen"}, {name: "Documentation", url: "/embark/documentation", icon: "fa fa-book"}, {name: "Utils", url: "/embark/utilities/converter", icon: "fa fa-cog", children: [ - {url: "/embark/utilities/converter", icon: "fa fa-plug", name: "Converter"} + {url: "/embark/utilities/converter", icon: "fa fa-plug", name: "Converter"}, + {url: "/embark/utilities/communication", icon: "fa fa-phone", name: "Communication"}, + {url: "/embark/utilities/ens", icon: "fa fa-circle", name: "ENS"} ]}, ]}; diff --git a/embark-ui/src/components/UtilsLayout.js b/embark-ui/src/components/UtilsLayout.js index 531fe8055..021e06165 100644 --- a/embark-ui/src/components/UtilsLayout.js +++ b/embark-ui/src/components/UtilsLayout.js @@ -2,10 +2,14 @@ import React from 'react'; import {Route, Switch} from 'react-router-dom'; import ConverterContainer from '../containers/ConverterContainer'; +import CommunicationContainer from '../containers/CommunicationContainer'; +import EnsContainer from '../containers/EnsContainer'; const UtilsLayout = () => ( + + ); diff --git a/embark-ui/src/containers/CommunicationContainer.js b/embark-ui/src/containers/CommunicationContainer.js index 85cf9a97a..31a03f8b2 100644 --- a/embark-ui/src/containers/CommunicationContainer.js +++ b/embark-ui/src/containers/CommunicationContainer.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 } from 'reactstrap'; import {messageSend, messageListen} from "../actions"; import Communication from "../components/Communication"; import {getMessages, getMessageChannels, isOldWeb3, isWeb3Enabled} from "../reducers/selectors"; @@ -16,7 +16,7 @@ class CommunicationContainer extends Component { } web3DisabledWarning() { - return The node you are using does not support Whisper; + return The node you are using does not support Whisper; } web3Enabled() { @@ -24,7 +24,7 @@ class CommunicationContainer extends Component { } web3OldWarning() { - return The node uses an unsupported version of Whisper; + return The node uses an unsupported version of Whisper; } showCommunication() { @@ -36,9 +36,9 @@ class CommunicationContainer extends Component { render() { return ( - + {this.props.isWeb3Enabled ? this.web3Enabled() : this.web3DisabledWarning()} - + ); } }