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
1.8 KiB
JavaScript
Raw Normal View History

2016-12-05 22:37:11 +01:00
import React, { Component } from 'react';
import { Grid, Cell } from 'react-mdl';
import { AppsLinkList } from '../common';
2016-12-05 22:37:11 +01:00
class ShowStrategyComponent extends Component {
2016-12-05 22:37:11 +01:00
componentDidMount () {
if (!this.props.strategy) {
this.props.fetchStrategies();
};
if (!this.props.applications || this.props.applications.length === 0) {
this.props.fetchApplications();
}
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 () {
const {
strategy,
strategyName,
applications,
} = this.props;
if (!strategy) {
return <div>Cannot find Strategy "{strategyName}".</div>;
2016-12-05 22:37:11 +01:00
}
const {
name,
description,
parametersTemplate = {},
} = strategy;
2016-12-05 22:37:11 +01:00
return (
<div>
<h4>{name}</h4>
<p>{description}</p>
<Grid>
<Cell col={6}>
2016-12-05 22:37:11 +01:00
<h6>Parameters</h6>
<hr />
2016-12-05 22:37:11 +01:00
<ol className="demo-list-item mdl-list">
{this.renderParameters(parametersTemplate)}
</ol>
</Cell>
<Cell col={6}>
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>
</Grid>
</div>
);
}
}
export default ShowStrategyComponent;