diff --git a/public/js/components/strategy/StrategiesComponent.jsx b/public/js/components/strategy/StrategiesComponent.jsx
index 9fc29a97f0..0df00d17de 100644
--- a/public/js/components/strategy/StrategiesComponent.jsx
+++ b/public/js/components/strategy/StrategiesComponent.jsx
@@ -14,9 +14,16 @@ var StrategiesComponent = React.createClass({
},
componentDidMount: function () {
- strategyStore.getStrategies().then(function(res) {
- this.setState({strategies: res.strategies});
- }.bind(this), this.initError);
+ this.fetchStrategies();
+ },
+
+ fetchStrategies: function(res) {
+ strategyStore.getStrategies()
+ .then(function(res) {
+ this.setState({strategies: res.strategies})
+ }.bind(this))
+ .catch(this.initError);
+
},
initError: function() {
@@ -57,6 +64,12 @@ var StrategiesComponent = React.createClass({
.catch(this.onError);
},
+ onRemove: function(strategy) {
+ strategyStore.removeStrategy(strategy)
+ .then(this.fetchStrategies)
+ .catch(this.onError);
+ },
+
render: function() {
return (
@@ -66,7 +79,7 @@ var StrategiesComponent = React.createClass({
-
+
);
},
diff --git a/public/js/components/strategy/Strategy.jsx b/public/js/components/strategy/Strategy.jsx
index 096a2f099c..b8c383b2e6 100644
--- a/public/js/components/strategy/Strategy.jsx
+++ b/public/js/components/strategy/Strategy.jsx
@@ -5,12 +5,20 @@ var Strategy = React.createClass({
strategy: React.PropTypes.object.isRequired
},
+ onRemove: function(event) {
+ event.preventDefault();
+ if (confirm("Are you sure you want to delete strategy '"+this.props.strategy.name+"'?")) {
+ this.props.onRemove(this.props.strategy);
+ }
+ },
+
render: function() {
return (
-
{this.props.strategy.name}
-
{this.props.strategy.description}
+
{this.props.strategy.name}
+
(remove)
+
{this.props.strategy.description}
);
diff --git a/public/js/components/strategy/StrategyList.jsx b/public/js/components/strategy/StrategyList.jsx
index 261efbe88e..bf148e26fb 100644
--- a/public/js/components/strategy/StrategyList.jsx
+++ b/public/js/components/strategy/StrategyList.jsx
@@ -8,8 +8,8 @@ var StrategyList = React.createClass({
render: function() {
var strategyNodes = this.props.strategies.map(function(strategy) {
- return ;
- });
+ return ;
+ }.bind(this));
return (
{strategyNodes}
);
diff --git a/public/js/stores/StrategyStore.js b/public/js/stores/StrategyStore.js
index 80674d9e38..09388e6e34 100644
--- a/public/js/stores/StrategyStore.js
+++ b/public/js/stores/StrategyStore.js
@@ -14,6 +14,14 @@ var StrategyStore = {
});
},
+ removeStrategy: function (strategy) {
+ return reqwest({
+ url: 'strategies/'+strategy.name,
+ method: 'delete',
+ type: TYPE
+ });
+ },
+
getStrategies: function () {
return reqwest({
url: 'strategies',