mirror of https://github.com/embarklabs/embark.git
refactor AsideContainer to remove duplication
This commit is contained in:
parent
f483230650
commit
19ad229dbb
|
@ -16,8 +16,3 @@
|
|||
width: 90%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#root .explorer-row .text-truncate {
|
||||
width: 90%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
|
|
@ -16,58 +16,54 @@ class TextEditorAsideContainer extends Component {
|
|||
this.props.fetchContracts();
|
||||
}
|
||||
|
||||
render() {
|
||||
switch(this.props.currentAsideTab) {
|
||||
renderContent(contract, index) {
|
||||
switch (this.props.currentAsideTab) {
|
||||
case 'browser':
|
||||
return <Preview />;
|
||||
return <Preview/>;
|
||||
case 'debugger':
|
||||
return this.props.contracts.map((contract, index) => {
|
||||
return (
|
||||
<Card key={'contract-' + index}>
|
||||
<CardBody>
|
||||
<h2>{contract.className} - Details</h2>
|
||||
<ContractDebuggerContainer key={index} contract={contract} />
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<React.Fragment>
|
||||
<h2>{contract.className} - Details</h2>
|
||||
<ContractDebuggerContainer key={index} contract={contract}/>
|
||||
</React.Fragment>
|
||||
);
|
||||
case 'detail':
|
||||
return this.props.contracts.map((contract, index) => {
|
||||
return (
|
||||
<Card key={'contract-' + index}>
|
||||
<CardBody>
|
||||
<h2>{contract.className} - Details</h2>
|
||||
<ContractDetail key={index} contract={contract} />
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<React.Fragment>
|
||||
<h2>{contract.className} - Details</h2>
|
||||
<ContractDetail key={index} contract={contract}/>
|
||||
</React.Fragment>
|
||||
);
|
||||
case 'logger':
|
||||
return this.props.contracts.map((contract, index) => {
|
||||
return (
|
||||
<Card key={'contract-' + index}>
|
||||
<CardBody>
|
||||
<h2>{contract.className} - Transactions</h2>
|
||||
<ContractLoggerContainer key={index} contract={contract} />)
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<React.Fragment>
|
||||
<h2>{contract.className} - Transactions</h2>
|
||||
<ContractLoggerContainer key={index} contract={contract}/>)
|
||||
</React.Fragment>
|
||||
);
|
||||
case 'overview':
|
||||
return this.props.contracts.map((contract, index) => {
|
||||
return (
|
||||
<Card key={'contract-' + index}>
|
||||
<CardBody>
|
||||
<h2>{contract.className} - Overview</h2>
|
||||
<ContractOverviewContainer key={index} contract={contract} />
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<React.Fragment>
|
||||
<h2>{contract.className} - Overview</h2>
|
||||
<ContractOverviewContainer key={index} contract={contract}/>
|
||||
</React.Fragment>
|
||||
);
|
||||
default:
|
||||
return <React.Fragment></React.Fragment>;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.props.contracts.map((contract, index) => {
|
||||
return (
|
||||
<Card key={'contract-' + index}>
|
||||
<CardBody>
|
||||
{this.renderContent(contract, index)}
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state, props) {
|
||||
|
@ -88,5 +84,5 @@ export default connect(
|
|||
mapStateToProps,
|
||||
{
|
||||
fetchContracts: contractsAction.request
|
||||
},
|
||||
}
|
||||
)(TextEditorAsideContainer);
|
||||
|
|
Loading…
Reference in New Issue