[Registry dApp] Actions not available before selecting accounts (#3032)

* Removed hasAccount from actions, now in Application [RegDapp] (#2931)

* Linting issues
This commit is contained in:
Nicolas Gotchac
2016-11-01 14:40:50 +01:00
committed by Jaco Greeff
parent 19d5f93745
commit 297a09399d
6 changed files with 62 additions and 34 deletions

View File

@@ -20,6 +20,7 @@ import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
const muiTheme = getMuiTheme(lightBaseTheme);
import CircularProgress from 'material-ui/CircularProgress';
import { Card, CardText } from 'material-ui/Card';
import styles from './application.css';
import Accounts from '../Accounts';
import Events from '../Events';
@@ -57,9 +58,7 @@ export default class Application extends Component {
accounts, contacts,
contract, fee,
lookup,
events,
names,
records
events
} = this.props;
return (
@@ -71,8 +70,9 @@ export default class Application extends Component {
{ contract && fee ? (
<div>
<Lookup { ...lookup } accounts={ accounts.all } contacts={ contacts } actions={ actions.lookup } />
<Names { ...names } fee={ fee } actions={ actions.names } />
<Records { ...records } actions={ actions.records } />
{ this.renderActions() }
<Events { ...events } accounts={ accounts.all } contacts={ contacts } actions={ actions.events } />
<p className={ styles.address }>
The Registry is provided by the contract at <code>{ contract.address }.</code>
@@ -85,4 +85,34 @@ export default class Application extends Component {
);
}
renderActions () {
const {
actions,
accounts,
fee,
names,
records
} = this.props;
const hasAccount = !!accounts.selected;
if (!hasAccount) {
return (
<Card className={ styles.actions }>
<CardText>
Please select a valid account in order
to execute actions.
</CardText>
</Card>
);
}
return (
<div>
<Names { ...names } fee={ fee } actions={ actions.names } />
<Records { ...records } actions={ actions.records } />
</div>
);
}
}