diff options
| author | jc0b <j@jc0b.computer> | 2020-07-10 15:18:49 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:02 +0200 |
| commit | d8479e7e3744b8d1d31ac4d9f972e560eacd2cf8 (patch) | |
| tree | 79b7dfccec6e3cc1fce189b4605a37b354d676a2 /frontend/src/components/app/sidebars/project/PortfolioListComponent.js | |
| parent | 4befa57993831274ad7e6ca62f96aa582f81cc5d (diff) | |
| parent | 3b4e27320c479bd6ef48998f448ed070e8bd7511 (diff) | |
Merge branch 'master' of github.com:atlarge-research/opendc-dev
Diffstat (limited to 'frontend/src/components/app/sidebars/project/PortfolioListComponent.js')
| -rw-r--r-- | frontend/src/components/app/sidebars/project/PortfolioListComponent.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/frontend/src/components/app/sidebars/project/PortfolioListComponent.js b/frontend/src/components/app/sidebars/project/PortfolioListComponent.js new file mode 100644 index 00000000..a31f11cf --- /dev/null +++ b/frontend/src/components/app/sidebars/project/PortfolioListComponent.js @@ -0,0 +1,59 @@ +import PropTypes from 'prop-types' +import React from 'react' +import Shapes from '../../../../shapes' +import { Link } from 'react-router-dom' +import FontAwesome from 'react-fontawesome' +import ScenarioListContainer from '../../../../containers/app/sidebars/project/ScenarioListContainer' + +class PortfolioListComponent extends React.Component { + static propTypes = { + portfolios: PropTypes.arrayOf(Shapes.Portfolio), + currentProjectId: PropTypes.string.isRequired, + currentPortfolioId: PropTypes.string, + onNewPortfolio: PropTypes.func.isRequired, + onChoosePortfolio: PropTypes.func.isRequired, + onDeletePortfolio: PropTypes.func.isRequired, + } + + onDelete(id) { + this.props.onDeletePortfolio(id) + } + + render() { + return ( + <div className="pb-3"> + <h2> + Portfolios + <button className="btn btn-outline-primary float-right" onClick={this.props.onNewPortfolio.bind(this)}> + <FontAwesome name="plus"/> + </button> + </h2> + + {this.props.portfolios.map((portfolio, idx) => ( + <div key={portfolio._id}> + <div className="row mb-1"> + <div + className={'col-8 align-self-center ' + (portfolio._id === this.props.currentPortfolioId ? 'font-weight-bold' : '')}> + {portfolio.name} + </div> + <div className="col-4 text-right"> + <Link + className="btn btn-outline-primary mr-1 fa fa-play" + to={`/projects/${this.props.currentProjectId}/portfolios/${portfolio._id}`} + onClick={() => this.props.onChoosePortfolio(portfolio._id)} + /> + <span + className="btn btn-outline-danger fa fa-trash" + onClick={() => this.onDelete(portfolio._id)} + /> + </div> + </div> + <ScenarioListContainer portfolioId={portfolio._id}/> + </div> + ))} + </div> + ) + } +} + +export default PortfolioListComponent |
