diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-10 10:21:46 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:01 +0200 |
| commit | 8aa174e70c01631ae4e00a6d208966fcd77cf972 (patch) | |
| tree | 35ec6527e8d7a0b4093e18c8cb501c293a18b5eb /frontend/src/components/app/sidebars/project/ScenarioListComponent.js | |
| parent | 607e8c72d85bf79dcd9bf28df96b239e2764bc30 (diff) | |
Add implementation of portfolio and scenario UI structure
Diffstat (limited to 'frontend/src/components/app/sidebars/project/ScenarioListComponent.js')
| -rw-r--r-- | frontend/src/components/app/sidebars/project/ScenarioListComponent.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/frontend/src/components/app/sidebars/project/ScenarioListComponent.js b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js new file mode 100644 index 00000000..9d2e261e --- /dev/null +++ b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js @@ -0,0 +1,54 @@ +import PropTypes from 'prop-types' +import React from 'react' +import Shapes from '../../../../shapes' +import { Link } from 'react-router-dom' +import FontAwesome from 'react-fontawesome' + +class ScenarioListComponent extends React.Component { + static propTypes = { + scenarios: PropTypes.arrayOf(Shapes.Scenario), + portfolioId: PropTypes.string, + currentProjectId: PropTypes.string.isRequired, + currentScenarioId: PropTypes.string, + onNewScenario: PropTypes.func.isRequired, + onChooseScenario: PropTypes.func.isRequired, + onDeleteScenario: PropTypes.func.isRequired, + } + + onDelete(id) { + this.props.onDeleteScenario(id) + } + + render() { + return ( + <> + {this.props.scenarios.map((scenario, idx) => ( + <div key={scenario._id} className="row mb-1"> + <div className={'col-8 pl-5 align-self-center ' + (scenario._id === this.props.currentScenarioId ? 'font-weight-bold' : '')}> + {scenario.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/${scenario.portfolioId}/scenarios/${scenario._id}`} + onClick={() => this.props.onChooseScenario(scenario.portfolioId, scenario._id)} + /> + <span + className={'btn btn-outline-danger fa fa-trash ' + (idx === 0 ? 'disabled' : '')} + onClick={() => idx !== 0 ? this.onDelete(scenario._id) : undefined} + /> + </div> + </div> + ))} + <div className="pl-4 mb-2"> + <div className="btn btn-outline-primary" onClick={() => this.props.onNewScenario(this.props.portfolioId)}> + <FontAwesome name="plus" className="mr-1"/> + New scenario + </div> + </div> + </> + ) + } +} + +export default ScenarioListComponent |
