blob: a31f11cff388837c9b1bdf4187b12ad345c65ddf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
|