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/show-strategy-component.js

70 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-12-20 19:28:45 +01:00
import React, { PropTypes, PureComponent } from 'react';
2016-12-13 19:56:52 +01:00
import { Grid, Cell, List, ListItem, ListItemContent } from 'react-mdl';
2016-12-17 14:37:11 +01:00
import { AppsLinkList, TogglesLinkList } from '../common';
2016-12-05 22:37:11 +01:00
2016-12-17 14:37:11 +01:00
class ShowStrategyComponent extends PureComponent {
2016-12-20 19:28:45 +01:00
static propTypes () {
return {
toggles: PropTypes.array,
applications: PropTypes.array,
strategy: PropTypes.object.isRequired,
};
}
2016-12-05 22:37:11 +01:00
2016-12-13 19:56:52 +01:00
renderParameters (params) {
if (params) {
return params.map(({ name, type, description, required }, i) => (
<ListItem twoLine key={`${name}-${i}`} title={required ? 'Required' : ''}>
<ListItemContent avatar={required ? 'add' : ' '} subtitle={description}>
{name} <small>({type})</small>
</ListItemContent>
</ListItem>
2016-12-05 22:37:11 +01:00
));
} else {
2016-12-13 19:56:52 +01:00
return <ListItem>(no params)</ListItem>;
2016-12-05 22:37:11 +01:00
}
}
render () {
const {
strategy,
applications,
2016-12-10 13:49:22 +01:00
toggles,
} = this.props;
2016-12-05 22:37:11 +01:00
const {
2016-12-13 19:56:52 +01:00
parameters = [],
} = strategy;
2016-12-05 22:37:11 +01:00
return (
<div>
2016-12-17 20:10:50 +01:00
2016-12-05 22:37:11 +01:00
<Grid>
2016-12-17 21:41:23 +01:00
<Cell col={12} >
2016-12-05 22:37:11 +01:00
<h6>Parameters</h6>
<hr />
2016-12-13 19:56:52 +01:00
<List>
{this.renderParameters(parameters)}
</List>
2016-12-05 22:37:11 +01:00
</Cell>
2016-12-17 21:41:23 +01:00
<Cell col={6} tablet={12}>
2016-12-05 22:37:11 +01:00
<h6>Applications using this strategy</h6>
<hr />
<AppsLinkList apps={applications} />
2016-12-05 22:37:11 +01:00
</Cell>
2016-12-10 13:49:22 +01:00
2016-12-17 21:41:23 +01:00
<Cell col={6} tablet={12}>
2016-12-10 13:49:22 +01:00
<h6>Toggles using this strategy</h6>
<hr />
<TogglesLinkList toggles={toggles} />
</Cell>
2016-12-05 22:37:11 +01:00
</Grid>
</div>
);
}
}
export default ShowStrategyComponent;