1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/component/strategies/list-component.jsx

51 lines
1.4 KiB
React
Raw Normal View History

2016-11-10 14:26:24 +01:00
import React, { Component } from 'react';
2016-12-04 11:56:41 +01:00
import { List, ListItem, ListItemContent, Icon, IconButton, Chip } from 'react-mdl';
2016-11-10 14:26:24 +01:00
import style from './strategies.scss';
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>
<h5>Strategies</h5>
<IconButton name="add" onClick={() => this.context.router.push('/strategies/create')} title="Add new strategy"/>
2016-11-10 14:26:24 +01:00
2016-12-04 11:56:41 +01:00
<hr />
<List>
{strategies.length > 0 ? strategies.map((strategy, i) => {
2016-11-10 14:26:24 +01:00
return (
2016-12-04 11:56:41 +01:00
<ListItem key={i}>
<ListItemContent><strong>{strategy.name}</strong> {strategy.description}</ListItemContent>
<IconButton name="delete" onClick={() => removeStrategy(strategy)} />
</ListItem>
2016-11-10 14:26:24 +01:00
);
2016-12-04 11:56:41 +01:00
}) : <ListItem>No entries</ListItem>}
2016-11-10 14:26:24 +01:00
</List>
2016-12-04 11:56:41 +01:00
</div>
2016-11-10 14:26:24 +01:00
);
}
}
export default StrategiesListComponent;