mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
Strategies should also have description #34
This commit is contained in:
parent
f47c78c545
commit
954f6c76ad
@ -1,9 +1,13 @@
|
|||||||
var strategies = [
|
var strategies = [
|
||||||
{name: "default"},
|
|
||||||
{
|
{
|
||||||
name: "activeForUsers",
|
name: "default",
|
||||||
|
description: "Default on or off Strategy."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "usersWithEmail",
|
||||||
|
description: "Active for users defined in the comma-separated emails-parameter.",
|
||||||
parametersTemplate: {
|
parametersTemplate: {
|
||||||
userNames: "String"
|
emails: "String"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
45
public/js/components/form/TextInput.jsx
Normal file
45
public/js/components/form/TextInput.jsx
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
var React = require('react');
|
||||||
|
|
||||||
|
var TextInput = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
name: React.PropTypes.string.isRequired,
|
||||||
|
label: React.PropTypes.string.isRequired,
|
||||||
|
id: React.PropTypes.string.isRequired,
|
||||||
|
placeholder: React.PropTypes.string,
|
||||||
|
value: React.PropTypes.string,
|
||||||
|
required: React.PropTypes.bool
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultProps: function() {
|
||||||
|
return {
|
||||||
|
required: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
|
||||||
|
getValue: function() {
|
||||||
|
return this.refs.input.getDOMNode().value.trim();
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
return (
|
||||||
|
<div className="formelement">
|
||||||
|
<label htmlFor="strategy_name" className="t4">{this.props.label}</label>
|
||||||
|
<div className="input">
|
||||||
|
<input type="text"
|
||||||
|
id={this.props.id}
|
||||||
|
name={this.props.name}
|
||||||
|
defaultValue={this.props.value}
|
||||||
|
placeholder={this.props.placeholder}
|
||||||
|
ref="input" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = TextInput;
|
@ -8,8 +8,9 @@ var Strategy = React.createClass({
|
|||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div className="line mal">
|
<div className="line mal">
|
||||||
<div className="unit r-size1of3">
|
<div className="unit">
|
||||||
{this.props.strategy.name}
|
<strong>{this.props.strategy.name}</strong><br />
|
||||||
|
<em>{this.props.strategy.description}</em>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
var React = require('react');
|
var React = require('react');
|
||||||
|
var TextInput = require('../form/TextInput');
|
||||||
|
|
||||||
var StrategyForm = React.createClass({
|
var StrategyForm = React.createClass({
|
||||||
|
|
||||||
@ -18,7 +19,8 @@ var StrategyForm = React.createClass({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var strategy = {};
|
var strategy = {};
|
||||||
strategy.name = this.refs.strategy_name.getDOMNode().value.trim();
|
strategy.name = this.refs.name.getValue();
|
||||||
|
strategy.description = this.refs.description.getValue();
|
||||||
strategy.parametersTemplate = {};
|
strategy.parametersTemplate = {};
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
@ -55,23 +57,24 @@ var StrategyForm = React.createClass({
|
|||||||
<form onSubmit={this.onSubmit}>
|
<form onSubmit={this.onSubmit}>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Create strategy</legend>
|
<legend>Create strategy</legend>
|
||||||
<div className="formelement">
|
|
||||||
<label htmlFor="strategy_name" className="t4">Name</label>
|
<TextInput
|
||||||
<div className="input">
|
id="name"
|
||||||
<input
|
|
||||||
id="trategy_name"
|
|
||||||
ref="strategy_name"
|
|
||||||
type="text"
|
|
||||||
name="name"
|
name="name"
|
||||||
placeholder="Strategy name"
|
label="Name"
|
||||||
/>
|
ref="name"
|
||||||
</div>
|
placeholder="Strategy name" />
|
||||||
</div>
|
|
||||||
|
<TextInput
|
||||||
|
id="description"
|
||||||
|
name="description"
|
||||||
|
label="Description"
|
||||||
|
ref="description"
|
||||||
|
placeholder="Please write a short descriptio" />
|
||||||
|
|
||||||
{this.renderParameters()}
|
{this.renderParameters()}
|
||||||
{this.renderRemoveLink()}
|
{this.renderRemoveLink()}
|
||||||
|
|
||||||
|
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<input type="submit" value="Save" className="primary mrs" />
|
<input type="submit" value="Save" className="primary mrs" />
|
||||||
<button onClick={this.props.handleCancelNewStrategy} className="mrs">Cancel</button>
|
<button onClick={this.props.handleCancelNewStrategy} className="mrs">Cancel</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user