2016-11-10 14:26:24 +01:00
|
|
|
import React, { Component } from 'react';
|
2016-12-05 23:12:01 +01:00
|
|
|
import { Link } from 'react-router';
|
2016-12-04 11:56:41 +01:00
|
|
|
|
2016-12-05 23:12:01 +01:00
|
|
|
import { List, ListItem, ListItemContent, IconButton, Chip } from 'react-mdl';
|
2016-12-10 11:47:25 +01:00
|
|
|
import { HeaderTitle } from '../common';
|
2016-11-10 14:26:24 +01:00
|
|
|
|
|
|
|
class StrategiesListComponent extends Component {
|
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: React.PropTypes.object,
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
|
|
|
this.props.fetchStrategies();
|
|
|
|
}
|
|
|
|
|
|
|
|
getParameterMap ({ parametersTemplate }) {
|
|
|
|
return Object.keys(parametersTemplate || {}).map(k => (
|
|
|
|
<Chip key={k}><small>{k}</small></Chip>
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { strategies, removeStrategy } = this.props;
|
|
|
|
|
|
|
|
return (
|
2016-12-04 11:56:41 +01:00
|
|
|
<div>
|
2016-12-10 11:47:25 +01:00
|
|
|
<HeaderTitle title="Strategies" actions={<IconButton name="add" onClick={() => this.context.router.push('/strategies/create')} title="Add new strategy"/>} />
|
|
|
|
<List>
|
|
|
|
{strategies.length > 0 ? strategies.map((strategy, i) => {
|
|
|
|
return (
|
|
|
|
<ListItem key={i}>
|
|
|
|
<ListItemContent>
|
|
|
|
<Link to={`/strategies/view/${strategy.name}`}>
|
|
|
|
<strong>{strategy.name}</strong>
|
|
|
|
</Link>
|
|
|
|
<span> {strategy.description}</span></ListItemContent>
|
|
|
|
<IconButton name="delete" onClick={() => removeStrategy(strategy)} />
|
|
|
|
</ListItem>
|
|
|
|
);
|
|
|
|
}) : <ListItem>No entries</ListItem>}
|
|
|
|
</List>
|
2016-12-04 11:56:41 +01:00
|
|
|
</div>
|
2016-11-10 14:26:24 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default StrategiesListComponent;
|