conflict in blocks

This commit is contained in:
Jonathan Rainville 2018-10-24 10:42:06 -04:00
parent 7eb87f1a25
commit 2ed2f9388b
4 changed files with 48 additions and 37 deletions

View File

@ -4,26 +4,24 @@ import {Row, Col, Card, CardHeader, CardBody} from 'reactstrap';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import CardTitleIdenticon from './CardTitleIdenticon'; import CardTitleIdenticon from './CardTitleIdenticon';
import LoadMore from "./LoadMore";
const Blocks = ({blocks}) => ( const Blocks = ({blocks, showLoadMore, loadMore}) => (
<Row> <Row>
<Col> <Col>
<h1>Blocks</h1> <Card>
{blocks.map(block => (
<Card key={block.number}>
<CardHeader> <CardHeader>
<h1>Blocks</h1>
</CardHeader>
<CardBody>
{blocks.map(block => (
<div className="explorer-row" key={block.number}>
<CardTitleIdenticon id={block.hash}>Block&nbsp; <CardTitleIdenticon id={block.hash}>Block&nbsp;
<Link to={`/embark/explorer/blocks/${block.number}`}> <Link className="align-top" to={`/embark/explorer/blocks/${block.number}`}>
{block.number} {block.number}
</Link> </Link>
</CardTitleIdenticon> </CardTitleIdenticon>
</CardHeader>
<CardBody>
<Row> <Row>
<Col>
<strong>Number</strong>
<div>{block.number}</div>
</Col>
<Col> <Col>
<strong>Mined On</strong> <strong>Mined On</strong>
<div>{new Date(block.timestamp * 1000).toLocaleString()}</div> <div>{new Date(block.timestamp * 1000).toLocaleString()}</div>
@ -37,15 +35,19 @@ const Blocks = ({blocks}) => (
<div>{block.transactions.length}</div> <div>{block.transactions.length}</div>
</Col> </Col>
</Row> </Row>
</div>
))}
{showLoadMore && <LoadMore loadMore={() => loadMore()} />}
</CardBody> </CardBody>
</Card> </Card>
))}
</Col> </Col>
</Row> </Row>
); );
Blocks.propTypes = { Blocks.propTypes = {
blocks: PropTypes.arrayOf(PropTypes.object) blocks: PropTypes.arrayOf(PropTypes.object),
showLoadMore: PropTypes.bool,
loadMore: PropTypes.func
}; };
export default Blocks; export default Blocks;

View File

@ -0,0 +1,9 @@
.explorer-row {
margin-bottom: 20px;
padding-bottom: 5px;
border-bottom: 1px solid #c8ced3;
}
.dark-theme .explorer-row {
border-bottom-color: #23282c;
}

View File

@ -8,6 +8,8 @@ import AccountsContainer from '../containers/AccountsContainer';
import BlocksContainer from '../containers/BlocksContainer'; import BlocksContainer from '../containers/BlocksContainer';
import TransactionsContainer from '../containers/TransactionsContainer'; import TransactionsContainer from '../containers/TransactionsContainer';
import './Explorer.css';
const ExplorerDashboardLayout = () => ( const ExplorerDashboardLayout = () => (
<React.Fragment> <React.Fragment>
<Row> <Row>

View File

@ -5,7 +5,6 @@ import PropTypes from 'prop-types';
import {blocks as blocksAction, initBlockHeader, stopBlockHeader} from '../actions'; import {blocks as blocksAction, initBlockHeader, stopBlockHeader} from '../actions';
import Blocks from '../components/Blocks'; import Blocks from '../components/Blocks';
import DataWrapper from "../components/DataWrapper"; import DataWrapper from "../components/DataWrapper";
import LoadMore from "../components/LoadMore";
import {getBlocks} from "../reducers/selectors"; import {getBlocks} from "../reducers/selectors";
class BlocksContainer extends Component { class BlocksContainer extends Component {
@ -34,9 +33,8 @@ class BlocksContainer extends Component {
return ( return (
<React.Fragment> <React.Fragment>
<DataWrapper shouldRender={this.props.blocks.length > 0} {...this.props} render={({blocks}) => ( <DataWrapper shouldRender={this.props.blocks.length > 0} {...this.props} render={({blocks}) => (
<Blocks blocks={blocks} /> <Blocks blocks={blocks} showLoadMore={(this.loadMoreFrom() >= 0)} loadMore={() => this.loadMore()} />
)} /> )} />
{(this.loadMoreFrom() >= 0) ? <LoadMore loadMore={() => this.loadMore()} /> : <React.Fragment />}
</React.Fragment> </React.Fragment>
); );
} }