1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/component/application/application-edit-component.js

128 lines
4.7 KiB
JavaScript
Raw Normal View History

2016-12-09 14:02:36 +01:00
/* eslint react/no-multi-comp:off */
import React, { Component, PureComponent } from 'react';
2016-12-05 15:15:01 +01:00
import { Link } from 'react-router';
2016-12-09 14:02:36 +01:00
import { Grid, Cell, List, ListItem, ListItemContent, Textfield, Icon } from 'react-mdl';
2016-12-05 15:15:01 +01:00
2016-12-09 14:02:36 +01:00
class StatefulTextfield extends Component {
constructor (props) {
super(props);
this.state = { value: props.value };
this.setValue = function setValue (e) {
this.setState({ value: e.target.value });
}.bind(this);
}
render () {
return (<Textfield label={this.props.label}
floatingLabel
rows={this.props.rows}
value={this.state.value}
onChange={this.setValue}
onBlur={this.props.onBlur} />
);
}
}
class ClientStrategies extends PureComponent {
2016-12-05 15:15:01 +01:00
componentDidMount () {
this.props.fetchApplication(this.props.appName);
}
render () {
2016-12-05 15:15:01 +01:00
if (!this.props.application) {
return <div>Loading application info...</div>;
}
2016-12-09 14:02:36 +01:00
const {
application,
storeApplicationMetaData,
} = this.props;
2016-12-05 15:15:01 +01:00
const {
appName,
instances,
strategies,
seenToggles,
2016-12-09 22:11:05 +01:00
url,
description,
icon = 'apps',
color,
2016-12-09 14:02:36 +01:00
} = application;
2016-12-05 15:15:01 +01:00
return (
<div>
2016-12-09 22:11:05 +01:00
<h5><Icon name={icon} /> {appName}</h5>
{description && <p>{description} </p>}
2016-12-05 15:15:01 +01:00
<Grid>
2016-12-09 14:02:36 +01:00
<Cell col={3}>
<h6> Toggles</h6>
<hr />
<List>
{seenToggles.map((name, i) =>
<ListItem key={i}>
<ListItemContent icon="check box">
<Link to={`/features/edit/${name}`}>
{name}
</Link>
</ListItemContent>
</ListItem>)}
</List>
2016-12-05 15:15:01 +01:00
</Cell>
2016-12-09 14:02:36 +01:00
<Cell col={3}>
<h6>Implemented strategies</h6>
2016-12-09 14:02:36 +01:00
<hr />
<List>
{strategies.map((name, i) => (
2016-12-09 14:02:36 +01:00
<ListItem key={`${name}-${i}`}>
<ListItemContent icon="toc">
<Link to={`/strategies/view/${name}`}>
{name}
</Link>
</ListItemContent>
</ListItem>
))}
2016-12-09 14:02:36 +01:00
</List>
</Cell>
<Cell col={6}>
<h6>{instances.length} Instances connected</h6>
<hr />
<List>
{instances.map(({ instanceId, clientIp, lastSeen }, i) => (
<ListItem key={i} twoLine>
2016-12-09 22:11:05 +01:00
<ListItemContent
icon="timeline"
subtitle={
<span>{clientIp} last seen at <small>{new Date(lastSeen).toLocaleString('nb-NO')}</small></span>
}>
2016-12-09 14:02:36 +01:00
{instanceId}
</ListItemContent>
</ListItem>
))}
</List>
</Cell>
<Cell col={12}>
<h5>Edit app meta data</h5>
</Cell>
<Cell col={6}>
2016-12-09 22:11:05 +01:00
<StatefulTextfield
value={url} label="URL" onBlur={(e) => storeApplicationMetaData(appName, 'url', e.target.value)} /><br />
<StatefulTextfield
value={description}
label="Description" rows={5} onBlur={(e) => storeApplicationMetaData(appName, 'description', e.target.value)} />
2016-12-05 15:15:01 +01:00
</Cell>
2016-12-09 14:02:36 +01:00
<Cell col={6}>
2016-12-09 22:11:05 +01:00
<StatefulTextfield
value={icon} label="Select icon" onBlur={(e) => storeApplicationMetaData(appName, 'icon', e.target.value)} />
<StatefulTextfield
value={color} label="Select color" onBlur={(e) => storeApplicationMetaData(appName, 'color', e.target.value)} />
2016-12-05 15:15:01 +01:00
</Cell>
</Grid>
</div>
);
}
}
export default ClientStrategies;