1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

Refactored all ``handleFoo` to `onFoo``

based on feedback from @jari
This commit is contained in:
Ivar Østhus 2014-11-03 21:37:40 +01:00 committed by Ivar Conradi Østhus
parent dd75e69ac6
commit 9a0a461edb
5 changed files with 30 additions and 31 deletions

View File

@ -17,8 +17,7 @@ var ErrorMessages = React.createClass({
<div className="bd"> <div className="bd">
<div className="media centerify"> <div className="media centerify">
<div className="imgExt"> <div className="imgExt">
<a <a onClick={this.props.onClearErrors}
onClick={this.props.onClearErrors}
className="icon-kryss1 linkblock sharp"> className="icon-kryss1 linkblock sharp">
</a> </a>
</div> </div>

View File

@ -21,7 +21,7 @@ var TabView = React.createClass({
return {activeTab: activeTab}; return {activeTab: activeTab};
}, },
handleChangeTab: function(tabPane) { onChangeTab: function(tabPane) {
this.setState({activeTab: tabPane}); this.setState({activeTab: tabPane});
}, },
@ -30,7 +30,7 @@ var TabView = React.createClass({
return ( return (
<li key={tabPane.name} className={tabPane.name===this.state.activeTab.name ? "active": ""}> <li key={tabPane.name} className={tabPane.name===this.state.activeTab.name ? "active": ""}>
<a href={"#" + tabPane.name} <a href={"#" + tabPane.name}
onClick={this.handleChangeTab.bind(this, tabPane)}>{tabPane.name} onClick={this.onChangeTab.bind(this, tabPane)}>{tabPane.name}
</a> </a>
</li> </li>
); );

View File

@ -27,7 +27,7 @@ var TextInput = React.createClass({
render: function() { render: function() {
return ( return (
<div className="formelement"> <div className="formelement required">
<label htmlFor="strategy_name" className="t4">{this.props.label}</label> <label htmlFor="strategy_name" className="t4">{this.props.label}</label>
<div className="input"> <div className="input">
<input type="text" <input type="text"

View File

@ -20,27 +20,27 @@ var StrategiesComponent = React.createClass({
}, },
initError: function() { initError: function() {
this.handleError("Could not load inital strategies from server"); this.onError("Could not load inital strategies from server");
}, },
clearErrors: function() { clearErrors: function() {
this.setState({errors: []}); this.setState({errors: []});
}, },
handleError: function(error) { onError: function(error) {
var errors = this.state.errors.concat([error]); var errors = this.state.errors.concat([error]);
this.setState({errors: errors}); this.setState({errors: errors});
}, },
handleNewStrategy: function() { onNewStrategy: function() {
this.setState({createView: true}); this.setState({createView: true});
}, },
handleCancelNewStrategy: function() { onCancelNewStrategy: function() {
this.setState({createView: false}); this.setState({createView: false});
}, },
handleSave: function(strategy) { onSave: function(strategy) {
var strategies = this.state.strategies.concat([strategy]); var strategies = this.state.strategies.concat([strategy]);
this.setState({ this.setState({
createView: false, createView: false,
@ -64,12 +64,12 @@ var StrategiesComponent = React.createClass({
}, },
renderCreateView: function() { renderCreateView: function() {
return (<StrategyForm handleCancelNewStrategy={this.handleCancelNewStrategy} handleSave={this.handleSave} />) return (<StrategyForm onCancelNewStrategy={this.onCancelNewStrategy} onSave={this.onSave} />)
}, },
renderCreateButton: function() { renderCreateButton: function() {
return ( return (
<button className="mal" onClick={this.handleNewStrategy}>Create strategy</button> <button className="mal" onClick={this.onNewStrategy}>Create strategy</button>
); );
} }
}); });

View File

@ -32,17 +32,17 @@ var StrategyForm = React.createClass({
} }
}); });
this.props.handleSave(strategy); this.props.onSave(strategy);
}, },
handleAddParam: function(event) { onAddParam: function(event) {
event.preventDefault(); event.preventDefault();
var id = this.state.parameters.length + 1; var id = this.state.parameters.length + 1;
var params = this.state.parameters.concat([{id:id, name: "param_" + id, label: "Parameter " +id}]); var params = this.state.parameters.concat([{id:id, name: "param_" + id, label: "Parameter " +id}]);
this.setState({parameters: params}); this.setState({parameters: params});
}, },
handleRemoveParam: function(event) { onRemoveParam: function(event) {
event.preventDefault(); event.preventDefault();
var id = this.state.parameters.length + 1; var id = this.state.parameters.length + 1;
var params = this.state.parameters.slice(0, -1); var params = this.state.parameters.slice(0, -1);
@ -118,14 +118,14 @@ var StrategyForm = React.createClass({
renderAddLink: function() { renderAddLink: function() {
if(this.state.parameters.length < this.props.maxParams) { if(this.state.parameters.length < this.props.maxParams) {
return <a href="#add" onClick={this.handleAddParam}>+ Add required parameter</a>; return <a href="#add" onClick={this.onAddParam}>+ Add required parameter</a>;
} }
}, },
renderRemoveLink: function() { renderRemoveLink: function() {
if(this.state.parameters.length > 0) { if(this.state.parameters.length > 0) {
return ( return (
<div className="formelement mtn"> <div className="formelement mtn">
<a href="#add" className="negative" onClick={this.handleRemoveParam}>- Remove parameter</a> <a href="#add" className="negative" onClick={this.onRemoveParam}>- Remove parameter</a>
</div> </div>
); );
} }