Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

feature(component): Show account balance and feedback when wallet balance is too low to create transaction #95

Merged
merged 32 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
89cc10f
Added admin's account balance to Admin Container
thefiend Jul 2, 2019
8d184cb
Removed vertical paddings
thefiend Jul 2, 2019
ec8b7a2
Added navbar to Admin Container and moved Admin Address, Account Bala…
thefiend Jul 2, 2019
8b4553f
Updated styles
thefiend Jul 2, 2019
4a0f075
Added refresh button to account balance
thefiend Jul 3, 2019
7ac2421
Updated logo alt name and changed Network to Wallet Provider
thefiend Jul 3, 2019
602af69
Merge branch 'fix/up-admin-page-ui' of https://github.com/OpenCerts/a…
thefiend Jul 8, 2019
07a404d
Amended max width of admin panel
thefiend Jul 8, 2019
bfae028
Merge branch 'master' of https://github.com/OpenCerts/admin-website i…
thefiend Jul 8, 2019
10d5f57
Fixed navbar mobile responsiveness
thefiend Jul 9, 2019
21b13e4
Updated to load account balance when a new block is found
thefiend Jul 9, 2019
e1b746c
Added check if wallet has sufficient balance before allowing transact…
thefiend Jul 9, 2019
5ca0404
Added toastify notification
thefiend Jul 10, 2019
83985df
Fix network selector on different screen sizes and added side spaces …
thefiend Jul 10, 2019
a4d2787
Aligned navigation bar items
thefiend Jul 10, 2019
e7c4938
Removed unneeded toast messages and updated toast to show only when a…
thefiend Jul 10, 2019
2b41236
Fixed linter issue
thefiend Jul 10, 2019
6018f23
Added transaction was rejected message
thefiend Jul 15, 2019
10b6b9e
Updated error message
thefiend Jul 16, 2019
9237d36
Updated network selector font size
thefiend Jul 16, 2019
01dcde2
Merge branch 'master' of https://github.com/OpenCerts/admin-website i…
thefiend Jul 16, 2019
43d885b
Updated order of error statement
thefiend Jul 16, 2019
f38e88c
Fixed linter issues
thefiend Jul 16, 2019
8db6096
Merge branch 'master' of https://github.com/OpenCerts/admin-website i…
thefiend Jul 29, 2019
ba7538d
Realigned navigation bar headers and removed accountBalance checking …
thefiend Aug 26, 2019
bfcd552
Removed admin address from front end and directly use in redux, remov…
thefiend Aug 26, 2019
d7db54e
Updated check for user denied transaction
thefiend Aug 27, 2019
d16b7e9
Changed initial accountBalance to undefined
thefiend Aug 27, 2019
ea740d2
Fixed account balance bug
thefiend Aug 28, 2019
dec0fff
Parsed account balance as number in front end
thefiend Aug 28, 2019
2020958
Added check for ledger user rejected transaction
thefiend Aug 29, 2019
1e764fc
Made error logic more readable
thefiend Aug 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"react-spinners": "^0.5.4",
"react-tabs": "^2.2.1",
"react-test-renderer": "^16.8.6",
"react-toastify": "^5.3.1",
"redux": "^3.6.0",
"redux-devtools-extension": "^2.13.2",
"redux-saga": "^0.16.0",
Expand Down
8 changes: 1 addition & 7 deletions pages/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import "@babel/polyfill";
import { connect } from "react-redux";
import AdminContainer from "../src/components/AdminContainer";

const AdminPage = props => (
<div className="min-vh-100 pv5">
<div className="mw9 mw8-ns center pa4 ph5-ns br3 pv5">
<AdminContainer {...props} />
</div>
</div>
);
const AdminPage = props => <AdminContainer {...props} />;

export default connect()(AdminPage);
185 changes: 111 additions & 74 deletions src/components/AdminContainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { ToastContainer } from "react-toastify";
/** @jsx jsx */
import { Global, css, jsx } from "@emotion/core";
import { Tab, Tabs, TabList, TabPanel } from "react-tabs";
Expand All @@ -14,6 +15,7 @@ import { isValidAddress } from "./utils";
import {
loadAdminAddress,
getAdminAddress,
getAccountBalance,
deployStore,
getStoreAddress,
updateStoreAddress,
Expand Down Expand Up @@ -98,7 +100,6 @@ class AdminContainer extends Component {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount() {
this.props.updateNetworkId();
this.props.loadAdminAddress();
}

// eslint-disable-next-line camelcase
Expand Down Expand Up @@ -135,6 +136,7 @@ class AdminContainer extends Component {
render() {
const {
adminAddress,
accountBalance,
storeAddress,
issuingCertificate,
issuedTx,
Expand All @@ -148,20 +150,19 @@ class AdminContainer extends Component {
return (
<React.Fragment>
{adminAddress ? (
<Panel>
{baseStyle}
<div className="flex">
<div className="w-50">
<h1 className="mt0">Admin</h1>
</div>
<div className="w-50">
<NetworkSelectorContainer />
</div>
</div>
<div className="flex bb pb3">
<div className="w-50">
<h3>
Current account{" "}
<React.Fragment>
<nav className="dt pa3 w-100 border-box pa3 ph5-ns bg-white shadow-1-ns flex-l flex-row-l">
yehjxraymond marked this conversation as resolved.
Show resolved Hide resolved
<a className="w-100 w-20-l" href="/" title="Home">
<img
src={"../../static/images/logo.svg"}
className="dtc v-mid mid-gray link dim pa3"
style={{ width: "200px" }}
alt="OpenCerts"
/>
</a>
<div className="w-100 w-40-l">
yehjxraymond marked this conversation as resolved.
Show resolved Hide resolved
<h3 className="ma0">
Current Account{" "}
<div
style={{ cursor: "pointer" }}
className="dib click-to-refresh"
Expand All @@ -180,71 +181,105 @@ class AdminContainer extends Component {
)}
</div>
</div>
<div className="w-50">
<h3>Store address</h3>
<HashColorInput
variant="rounded"
type="address"
value={this.state.localStoreAddress}
onChange={this.storeAddressOnChange}
placeholder="Enter existing (0x…), or deploy new instance"
/>
<div className="w-100 w-20-l">
<h3 className="ma0">Account Balance</h3>
<div className="pa2">
{accountBalance ? (
<div>{accountBalance} ETH</div>
) : (
<div className="red">Unable to load account balance.</div>
)}
</div>
</div>
<div className="w-100 w-20-l">
<h3 className="ma0">Wallet Provider</h3>
<NetworkSelectorContainer />
yehjxraymond marked this conversation as resolved.
Show resolved Hide resolved
</div>
</nav>
<ToastContainer autoClose={2000} />
<Panel style={{ maxWidth: "900px" }}>
{baseStyle}
<div className="flex">
<div className="w-100 w-50-ns">
<h1 className="mt0">Admin</h1>
</div>
</div>
</div>
<Tabs className="flex flex-row w-100">
<TabList className="flex flex-column w-30 list pa0">
<Tab className="tab pl3">
<h3>Deploy new instance</h3>
</Tab>
<Tab className="tab pl3">
<h3>Issue certificate batch</h3>
</Tab>
<Tab className="tab pl3">
<h3>Revoke certificate</h3>
</Tab>
</TabList>
<div className="w-70 pa4 pl5">
<TabPanel>
<StoreDeployBlock
adminAddress={adminAddress}
storeAddress={storeAddress}
handleStoreDeploy={this.handleStoreDeploy}
deploying={deploying}
networkId={networkId}
deployedTx={deployedTx}
<div className="flex bb pb3">
<div className="w-100 w-50-l">
<h3>Store address</h3>
<HashColorInput
variant="rounded"
type="address"
value={this.state.localStoreAddress}
onChange={this.storeAddressOnChange}
placeholder="Enter existing (0x…), or deploy new instance"
/>
</TabPanel>
<TabPanel>
{storeAddress ? (
<StoreIssueBlock
networkId={networkId}
issuedTx={issuedTx}
</div>
</div>
<Tabs className="flex flex-row w-100">
<TabList className="flex flex-column w-30 list pa0">
<Tab
className="tab pl3"
style={{ borderTopLeftRadius: "5px" }}
>
<h3>Deploy new instance</h3>
</Tab>
<Tab className="tab pl3">
<h3>Issue certificate batch</h3>
</Tab>
<Tab
className="tab pl3"
style={{ borderBottomLeftRadius: "5px" }}
>
<h3>Revoke certificate</h3>
</Tab>
</TabList>
<div className="w-70 pa4 pl5">
<TabPanel>
<StoreDeployBlock
adminAddress={adminAddress}
storeAddress={storeAddress}
handleCertificateIssue={this.handleCertificateIssue}
issuingCertificate={issuingCertificate}
/>
) : (
<div className="red">Enter a store address first.</div>
)}
</TabPanel>
<TabPanel>
{storeAddress ? (
<StoreRevokeBlock
accountBalance={accountBalance}
handleStoreDeploy={this.handleStoreDeploy}
deploying={deploying}
networkId={networkId}
revokingCertificate={revokingCertificate}
revokedTx={revokedTx}
adminAddress={adminAddress}
storeAddress={storeAddress}
handleCertificateRevoke={this.handleCertificateRevoke}
deployedTx={deployedTx}
/>
) : (
<div className="red">Enter a store address first.</div>
)}
</TabPanel>
</div>
</Tabs>
</Panel>
</TabPanel>
<TabPanel>
{storeAddress ? (
<StoreIssueBlock
networkId={networkId}
issuedTx={issuedTx}
adminAddress={adminAddress}
storeAddress={storeAddress}
accountBalance={accountBalance}
handleCertificateIssue={this.handleCertificateIssue}
issuingCertificate={issuingCertificate}
/>
) : (
<div className="red">Enter a store address first.</div>
)}
</TabPanel>
<TabPanel>
{storeAddress ? (
<StoreRevokeBlock
networkId={networkId}
revokingCertificate={revokingCertificate}
revokedTx={revokedTx}
adminAddress={adminAddress}
storeAddress={storeAddress}
accountBalance={accountBalance}
handleCertificateRevoke={this.handleCertificateRevoke}
/>
) : (
<div className="red">Enter a store address first.</div>
)}
</TabPanel>
</div>
</Tabs>
</Panel>
</React.Fragment>
) : (
<ErrorPage />
)}
Expand All @@ -256,6 +291,7 @@ class AdminContainer extends Component {
const mapStateToProps = store => ({
isLoading: getIsLoading(store),
adminAddress: getAdminAddress(store),
accountBalance: getAccountBalance(store),
storeAddress: getStoreAddress(store),
issuedTx: getIssuedTx(store),
revokingCertificate: getrevokingCertificate(store),
Expand Down Expand Up @@ -290,6 +326,7 @@ AdminContainer.propTypes = {
issueCertificate: PropTypes.func,
updateStoreAddress: PropTypes.func,
adminAddress: PropTypes.string,
accountBalance: PropTypes.string,
storeAddress: PropTypes.string,
setIsNotLoading: PropTypes.func,
issuingCertificate: PropTypes.bool,
Expand Down
12 changes: 12 additions & 0 deletions src/components/Meta.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Head from "next/head";

/** @jsx jsx */
import { Global, css, jsx } from "@emotion/core";
import { faintBlue } from "../styles/variables";
Expand All @@ -22,6 +23,17 @@ const Meta = () => (
rel="stylesheet"
type="text/css"
/>
<link
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro"
rel="stylesheet"
type="text/css"
/>
<link
href="
https://cdn.jsdelivr.net/npm/[email protected]/dist/ReactToastify.min.css"
rel="stylesheet"
type="text/css"
/>
</Head>
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js" />
<link
Expand Down
8 changes: 5 additions & 3 deletions src/components/NetworkSelectorContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { white } from "./../styles/variables";
const divBase = css`
border-radius: 50px;
padding: 0.2em 0.5em;
width: 13em;
`;

const selectorBase = css`
Expand All @@ -35,13 +36,13 @@ class AdminContainer extends Component {

render() {
const { INJECTED, LEDGER_MAIN, LEDGER_ROPSTEN } = NETWORK_TYPES;

const { network, style } = this.props;
return (
<div className="fr ba" css={css(divBase)}>
<div className="ba" style={style} css={css(divBase)}>
<select
css={css(selectorBase)}
className="pa2 provider-selector"
value={this.props.network}
value={network}
onChange={this.handleNetworkChange}
>
<option value={INJECTED}>Metamask</option>
Expand All @@ -68,6 +69,7 @@ export default connect(
)(AdminContainer);

AdminContainer.propTypes = {
style: PropTypes.object,
network: PropTypes.string,
customRpc: PropTypes.string,
updateWeb3: PropTypes.func
Expand Down
Loading