summaryrefslogtreecommitdiff
path: root/frontend/src/components/app/sidebars/project/ScenarioListComponent.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-10 10:24:31 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:48:01 +0200
commit3b4e27320c479bd6ef48998f448ed070e8bd7511 (patch)
tree35ec6527e8d7a0b4093e18c8cb501c293a18b5eb /frontend/src/components/app/sidebars/project/ScenarioListComponent.js
parentb30906bbe0d5f343b337a80de1b4b70ebf288331 (diff)
parent8aa174e70c01631ae4e00a6d208966fcd77cf972 (diff)
Merge pull request #8 from atlarge-research/feature/portfolios-scenarios-frontend
Portfolios and scenarios on the frontend
Diffstat (limited to 'frontend/src/components/app/sidebars/project/ScenarioListComponent.js')
-rw-r--r--frontend/src/components/app/sidebars/project/ScenarioListComponent.js54
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