2016-12-05 22:37:11 +01:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { Grid, Cell } from 'react-mdl';
|
|
|
|
|
2016-12-10 13:49:22 +01:00
|
|
|
import { AppsLinkList, TogglesLinkList, HeaderTitle } from '../common';
|
2016-12-05 22:37:11 +01:00
|
|
|
|
2016-12-09 22:09:43 +01:00
|
|
|
class ShowStrategyComponent extends Component {
|
2016-12-05 22:37:11 +01:00
|
|
|
componentDidMount () {
|
|
|
|
if (!this.props.strategy) {
|
|
|
|
this.props.fetchStrategies();
|
|
|
|
};
|
2016-12-09 22:09:43 +01:00
|
|
|
if (!this.props.applications || this.props.applications.length === 0) {
|
|
|
|
this.props.fetchApplications();
|
|
|
|
}
|
2016-12-10 13:49:22 +01:00
|
|
|
if (!this.props.toggles || this.props.toggles.length === 0) {
|
|
|
|
this.props.fetchFeatureToggles();
|
|
|
|
}
|
2016-12-05 22:37:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
renderParameters (parametersTemplate) {
|
|
|
|
if (parametersTemplate) {
|
|
|
|
return Object.keys(parametersTemplate).map((name, i) => (
|
|
|
|
<li key={`${name}-${i}`}><strong>{name}</strong> ({parametersTemplate[name]})</li>
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
return <li>(no params)</li>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2016-12-09 22:09:43 +01:00
|
|
|
const {
|
|
|
|
strategy,
|
|
|
|
strategyName,
|
|
|
|
applications,
|
2016-12-10 13:49:22 +01:00
|
|
|
toggles,
|
2016-12-09 22:09:43 +01:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (!strategy) {
|
|
|
|
return <div>Cannot find Strategy "{strategyName}".</div>;
|
2016-12-05 22:37:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
|
|
|
name,
|
|
|
|
description,
|
|
|
|
parametersTemplate = {},
|
2016-12-09 22:09:43 +01:00
|
|
|
} = strategy;
|
2016-12-05 22:37:11 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2016-12-10 12:35:28 +01:00
|
|
|
<HeaderTitle title={name} subtitle={description} />
|
2016-12-05 22:37:11 +01:00
|
|
|
<Grid>
|
2016-12-10 13:49:22 +01:00
|
|
|
<Cell col={4}>
|
2016-12-05 22:37:11 +01:00
|
|
|
<h6>Parameters</h6>
|
2016-12-09 22:09:43 +01:00
|
|
|
<hr />
|
2016-12-05 22:37:11 +01:00
|
|
|
<ol className="demo-list-item mdl-list">
|
|
|
|
{this.renderParameters(parametersTemplate)}
|
|
|
|
</ol>
|
|
|
|
</Cell>
|
|
|
|
|
2016-12-10 13:49:22 +01:00
|
|
|
<Cell col={4}>
|
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
|
|
|
|
|
|
|
<Cell col={4}>
|
|
|
|
<h6>Toggles using this strategy</h6>
|
|
|
|
<hr />
|
|
|
|
<TogglesLinkList toggles={toggles} />
|
|
|
|
</Cell>
|
2016-12-05 22:37:11 +01:00
|
|
|
</Grid>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default ShowStrategyComponent;
|