fix proptypes warnings and fix indexes

This commit is contained in:
Jonathan Rainville 2018-11-06 15:55:57 -05:00
parent 2f4625c143
commit 24e3da65b2
2 changed files with 29 additions and 16 deletions

View File

@ -42,7 +42,7 @@ const LayoutContract = ({contract, children, cardTitle}) => (
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle> <CardTitle>
<span className={orderClassName(contract.address)}>{contract.index + 1}</span> <span className={orderClassName(contract.address)}>{contract.deployIndex + 1}</span>
{cardTitle} {cardTitle}
</CardTitle> </CardTitle>
</CardHeader> </CardHeader>
@ -55,7 +55,7 @@ const LayoutContract = ({contract, children, cardTitle}) => (
LayoutContract.propTypes = { LayoutContract.propTypes = {
contract: PropTypes.object, contract: PropTypes.object,
children: PropTypes.array, children: PropTypes.array,
cardTitle: PropTypes.string cardTitle: PropTypes.object
}; };
const DeploymentResult = ({deployment}) => { const DeploymentResult = ({deployment}) => {
@ -244,14 +244,14 @@ const ContractsHeader = ({deploymentPipeline, updateDeploymentPipeline}) => (
); );
ContractsHeader.propTypes = { ContractsHeader.propTypes = {
deploymentPipeline: PropTypes.object, deploymentPipeline: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
updateDeploymentPipeline: PropTypes.func updateDeploymentPipeline: PropTypes.func
}; };
const Contract = ({web3, contract, deploymentPipeline, web3Deploy, web3EstimateGas, web3Deployments, web3GasEstimates, toggleContractOverview}) => { const Contract = ({web3, contract, deploymentPipeline, web3Deploy, web3EstimateGas, web3Deployments, web3GasEstimates, toggleContractOverview}) => {
if (!contract.code && !contract.deploy) {
return <React.Fragment/>;
}
const deployment = web3Deployments[contract.className]; const deployment = web3Deployments[contract.className];
const gasEstimate = web3GasEstimates[contract.className]; const gasEstimate = web3GasEstimates[contract.className];
switch (deploymentPipeline) { switch (deploymentPipeline) {
@ -271,7 +271,10 @@ const Contract = ({web3, contract, deploymentPipeline, web3Deploy, web3EstimateG
Contract.propTypes = { Contract.propTypes = {
contract: PropTypes.object, contract: PropTypes.object,
deploymentPipeline: PropTypes.object, deploymentPipeline: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
toggleContractOverview: PropTypes.func, toggleContractOverview: PropTypes.func,
web3: PropTypes.object, web3: PropTypes.object,
web3Deploy: PropTypes.func, web3Deploy: PropTypes.func,
@ -303,12 +306,15 @@ class ContractsDeployment extends React.Component {
<Col> <Col>
<ContractsHeader deploymentPipeline={this.props.deploymentPipeline} <ContractsHeader deploymentPipeline={this.props.deploymentPipeline}
updateDeploymentPipeline={this.props.updateDeploymentPipeline}/> updateDeploymentPipeline={this.props.updateDeploymentPipeline}/>
{this.props.contracts.sort((a, b) => a.index - b.index).map(contract => ( {this.props.contracts.filter(contract => contract.code || contract.deploy)
<Contract key={contract.index} .sort((a, b) => a.index - b.index).map((contract, index) => {
contract.deployIndex = index;
return (<Contract key={contract.deployIndex}
contract={contract} contract={contract}
toggleContractOverview={(contract) => this.toggleContractOverview(contract)} toggleContractOverview={(contract) => this.toggleContractOverview(contract)}
{...this.props} /> {...this.props} />);
))} }
)}
</Col> </Col>
{this.isContractOverviewOpen() && {this.isContractOverviewOpen() &&
<Col xs={6} md={3}> <Col xs={6} md={3}>
@ -325,9 +331,13 @@ class ContractsDeployment extends React.Component {
} }
} }
ContractsDeployment.propTypes = { ContractsDeployment.propTypes = {
contracts: PropTypes.array, contracts: PropTypes.array,
deploymentPipeline: PropTypes.string, deploymentPipeline: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
updateDeploymentPipeline: PropTypes.func, updateDeploymentPipeline: PropTypes.func,
web3Deployments: PropTypes.object, web3Deployments: PropTypes.object,
web3GasEstimates: PropTypes.object, web3GasEstimates: PropTypes.object,

View File

@ -46,7 +46,10 @@ function mapStateToProps(state) {
DeploymentContainer.propTypes = { DeploymentContainer.propTypes = {
contracts: PropTypes.array, contracts: PropTypes.array,
deploymentPipeline: PropTypes.object, deploymentPipeline: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
fetchContracts: PropTypes.func, fetchContracts: PropTypes.func,
updateDeploymentPipeline: PropTypes.func, updateDeploymentPipeline: PropTypes.func,
web3: PropTypes.object, web3: PropTypes.object,