mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
Minor refactoring
This commit is contained in:
parent
278a8da162
commit
7963829e61
@ -68,8 +68,8 @@ var Feature = React.createClass({
|
|||||||
{this.props.feature.strategy}
|
{this.props.feature.strategy}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td className="rightify">
|
<td>
|
||||||
<input type='button' value='Edit' onClick={this.toggleEditMode}/>
|
<input className="mrs mbs" type='button' value='Edit' onClick={this.toggleEditMode}/>
|
||||||
<input type='button' value='History' onClick={this.toggleHistory} />
|
<input type='button' value='History' onClick={this.toggleHistory} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -11,23 +11,11 @@ var FeatureForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleStrategyResponse: function(response) {
|
handleStrategyResponse: function(response) {
|
||||||
var strategyNames = response.strategies.map(function(strategy) {
|
var strategyNames = response.strategies.map(function(s) { return s.name; });
|
||||||
return strategy.name;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState({strategyOptions: strategyNames});
|
this.setState({strategyOptions: strategyNames});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var currentStrategy = this.props.feature ? this.props.feature.strategy : "";
|
|
||||||
var strategyNodes = this.state.strategyOptions.map(function(name) {
|
|
||||||
return (
|
|
||||||
<option value={name} selected={name === currentStrategy}>
|
|
||||||
{name}
|
|
||||||
</option>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
var feature = this.props.feature || {
|
var feature = this.props.feature || {
|
||||||
name: '',
|
name: '',
|
||||||
strategy: 'default',
|
strategy: 'default',
|
||||||
@ -64,7 +52,7 @@ var FeatureForm = React.createClass({
|
|||||||
ref="strategy"
|
ref="strategy"
|
||||||
className=""
|
className=""
|
||||||
defaultValue={feature.strategy}>
|
defaultValue={feature.strategy}>
|
||||||
{strategyNodes}
|
{this.renderStrategyOptions()}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -82,6 +70,18 @@ var FeatureForm = React.createClass({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderStrategyOptions: function() {
|
||||||
|
var currentStrategy = this.props.feature ? this.props.feature.strategy : "";
|
||||||
|
|
||||||
|
return this.state.strategyOptions.map(function(name) {
|
||||||
|
return (
|
||||||
|
<option key={name} value={name} selected={name === currentStrategy}>
|
||||||
|
{name}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
saveFeature: function(e) {
|
saveFeature: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ var FeatureForm = React.createClass({
|
|||||||
description: this.refs.description.getDOMNode().value,
|
description: this.refs.description.getDOMNode().value,
|
||||||
strategy: this.refs.strategy.getDOMNode().value,
|
strategy: this.refs.strategy.getDOMNode().value,
|
||||||
enabled: this.refs.enabled.getDOMNode().checked
|
enabled: this.refs.enabled.getDOMNode().checked
|
||||||
}
|
};
|
||||||
|
|
||||||
this.props.onSubmit(feature);
|
this.props.onSubmit(feature);
|
||||||
},
|
},
|
||||||
|
@ -35,6 +35,12 @@ var StrategyForm = React.createClass({
|
|||||||
this.props.onSave(strategy);
|
this.props.onSave(strategy);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onCancel: function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
this.props.onCancelNewStrategy();
|
||||||
|
},
|
||||||
|
|
||||||
onAddParam: function(event) {
|
onAddParam: function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var id = this.state.parameters.length + 1;
|
var id = this.state.parameters.length + 1;
|
||||||
@ -70,14 +76,14 @@ var StrategyForm = React.createClass({
|
|||||||
name="description"
|
name="description"
|
||||||
label="Description"
|
label="Description"
|
||||||
ref="description"
|
ref="description"
|
||||||
placeholder="Please write a short descriptio" />
|
placeholder="Please write a short description" />
|
||||||
|
|
||||||
{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.onCancel} className="mrs">Cancel</button>
|
||||||
{this.renderAddLink()}
|
{this.renderAddLink()}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
Loading…
Reference in New Issue
Block a user