// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Parity. If not, see . import { observer } from 'mobx-react'; import React, { Component } from 'react'; import Contract from '../Contract'; import Dapp from '../Dapp'; import Store from '../store'; import styles from './application.css'; @observer export default class Application extends Component { store = new Store(); render () { return (
{ this.renderContracts(false) } { this.renderContracts(true) } { this.renderApps() } { this.renderContracts(false, true) } { this.renderApps(true) } { this.renderButtons() }
); } renderButton (text, clickHandler, disabled) { const onClick = (event) => { if (!disabled) { clickHandler(event); } }; return ( ); } renderButtons () { const { contractBadgereg, contractDappreg, isBadgeDeploying, isContractDeploying, isDappDeploying, haveAllBadges, haveAllContracts, haveAllDapps, registry } = this.store; const disableRegistry = registry.address || registry.isDeploying; const disableContracts = !registry.address || isContractDeploying || haveAllContracts; const disableDapps = !contractDappreg.address || isDappDeploying || haveAllDapps; const disableBadges = !registry.address || !contractBadgereg.address || isBadgeDeploying || haveAllBadges; return (
{ this.renderButton('registry', this.deployRegistry, disableRegistry) } { this.renderButton('contracts', this.deployContracts, disableContracts) } { this.renderButton('badges', this.deployBadges, disableBadges) } { this.renderButton('apps', this.deployApps, disableDapps) }
); } renderContracts (isBadges, isExternal) { const { badges, contracts, contractBadgereg, registry } = this.store; const regaddress = isBadges ? contractBadgereg.address : registry.address; return (

{ isExternal ? 'External ' : '' }{ isBadges ? 'Badges ' : 'Contracts ' }(registry { regaddress || 'unknown' })

{ isExternal || isBadges ? null : ( ) } { (isBadges ? badges : contracts) .filter((contract) => contract.isExternal === isExternal) .map((contract) => { return ( ); }) }
); } renderApps (isExternal) { const { apps, contractDappreg, contractGithubhint } = this.store; const isDisabled = !contractDappreg.isOnChain || !contractGithubhint.isOnChain; return (

{ isExternal ? 'External ' : '' }Applications (registry { contractDappreg.address ? contractDappreg.address : 'unknown' })

{ apps .filter((app) => app.isExternal === isExternal) .map((app) => { return ( ); }) }
); } deployApps = () => { return this.store.deployApps(); } deployBadges = () => { return this.store.deployBadges(); } deployContracts = () => { return this.store.deployContracts(); } deployRegistry = () => { return this.store.deployRegistry(); } }