2017-08-28 21:30:12 +02:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
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 {
|
2017-07-10 23:38:44 +02:00
|
|
|
static propTypes = {
|
|
|
|
toggles: PropTypes.array,
|
|
|
|
applications: PropTypes.array,
|
|
|
|
strategy: PropTypes.object.isRequired,
|
2017-08-28 19:15:47 +02:00
|
|
|
};
|
2016-12-05 22:37:11 +01:00
|
|
|
|
2017-08-28 19:15:47 +02:00
|
|
|
renderParameters(params) {
|
2016-12-13 19:56:52 +01:00
|
|
|
if (params) {
|
|
|
|
return params.map(({ name, type, description, required }, i) => (
|
2017-08-28 21:40:44 +02:00
|
|
|
<ListItem twoLine key={`${name}-${i}`} title={required ? 'Required' : ''}>
|
|
|
|
<ListItemContent avatar={required ? 'add' : ' '} subtitle={description}>
|
2016-12-13 19:56:52 +01:00
|
|
|
{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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-28 19:15:47 +02:00
|
|
|
render() {
|
|
|
|
const { strategy, applications, toggles } = this.props;
|
2016-12-09 22:09:43 +01:00
|
|
|
|
2017-08-28 19:15:47 +02:00
|
|
|
const { parameters = [] } = strategy;
|
2016-12-05 22:37:11 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Grid>
|
2021-01-21 15:27:24 +01:00
|
|
|
{strategy.deprecated ? (
|
|
|
|
<Cell>
|
|
|
|
<h5 style={{ color: '#ff0000' }}>Deprecated</h5>
|
|
|
|
</Cell>
|
|
|
|
) : (
|
|
|
|
''
|
|
|
|
)}
|
2017-08-28 19:15:47 +02:00
|
|
|
<Cell col={12}>
|
2016-12-05 22:37:11 +01:00
|
|
|
<h6>Parameters</h6>
|
2016-12-09 22:09:43 +01:00
|
|
|
<hr />
|
2017-08-28 19:15:47 +02: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>
|
2016-12-09 22:09:43 +01:00
|
|
|
<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;
|