2016-06-18 21:53:18 +02:00
|
|
|
'use strict';
|
2016-06-18 21:55:46 +02:00
|
|
|
const Reflux = require('reflux');
|
2016-06-18 21:53:18 +02:00
|
|
|
const Server = require('./FeatureToggleServerFacade');
|
2015-03-16 21:27:56 +01:00
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
const FeatureToggleActions = Reflux.createActions({
|
|
|
|
init: { asyncResult: true },
|
|
|
|
initArchive: { asyncResult: true },
|
|
|
|
create: { asyncResult: true },
|
|
|
|
update: { asyncResult: true },
|
|
|
|
archive: { asyncResult: true },
|
2016-06-18 21:55:46 +02:00
|
|
|
revive: { asyncResult: true },
|
2015-03-16 21:27:56 +01:00
|
|
|
});
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
FeatureToggleActions.init.listen(function () {
|
2016-06-18 21:53:18 +02:00
|
|
|
Server.getFeatures((error, features) => {
|
2016-04-24 22:41:37 +02:00
|
|
|
if (error) {
|
|
|
|
this.failed(error);
|
|
|
|
} else {
|
|
|
|
this.completed(features);
|
|
|
|
}
|
2016-06-18 21:53:18 +02:00
|
|
|
});
|
2015-03-17 22:52:10 +01:00
|
|
|
});
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
FeatureToggleActions.initArchive.listen(function () {
|
2016-06-18 21:53:18 +02:00
|
|
|
Server.getArchivedFeatures((error, archivedToggles) => {
|
2016-04-24 22:41:37 +02:00
|
|
|
if (error) {
|
|
|
|
this.failed(error);
|
|
|
|
} else {
|
|
|
|
this.completed(archivedToggles);
|
|
|
|
}
|
2016-06-18 21:53:18 +02:00
|
|
|
});
|
2015-03-17 22:52:10 +01:00
|
|
|
});
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
FeatureToggleActions.create.listen(function (feature) {
|
2016-06-18 21:53:18 +02:00
|
|
|
Server.createFeature(feature, error => {
|
2016-04-24 22:41:37 +02:00
|
|
|
if (error) {
|
|
|
|
this.failed(error);
|
|
|
|
} else {
|
|
|
|
this.completed(feature);
|
|
|
|
}
|
2016-06-18 21:53:18 +02:00
|
|
|
});
|
2015-03-16 21:27:56 +01:00
|
|
|
});
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
FeatureToggleActions.update.listen(function (feature) {
|
2016-06-18 21:53:18 +02:00
|
|
|
Server.updateFeature(feature, error => {
|
2016-04-24 22:41:37 +02:00
|
|
|
if (error) {
|
|
|
|
this.failed(error);
|
|
|
|
} else {
|
|
|
|
this.completed(feature);
|
|
|
|
}
|
2016-06-18 21:53:18 +02:00
|
|
|
});
|
2015-03-16 21:27:56 +01:00
|
|
|
});
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
FeatureToggleActions.archive.listen(function (feature) {
|
2016-06-18 21:53:18 +02:00
|
|
|
Server.archiveFeature(feature, error => {
|
2016-04-24 22:41:37 +02:00
|
|
|
if (error) {
|
|
|
|
this.failed(error);
|
|
|
|
} else {
|
|
|
|
this.completed(feature);
|
|
|
|
}
|
2016-06-18 21:53:18 +02:00
|
|
|
});
|
2015-03-16 21:27:56 +01:00
|
|
|
});
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
FeatureToggleActions.revive.listen(function (feature) {
|
2016-06-18 21:53:18 +02:00
|
|
|
Server.reviveFeature(feature, error => {
|
2016-04-24 22:41:37 +02:00
|
|
|
if (error) {
|
|
|
|
this.failed(error);
|
|
|
|
} else {
|
|
|
|
this.completed(feature);
|
|
|
|
}
|
2016-06-18 21:53:18 +02:00
|
|
|
});
|
2015-03-16 21:27:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = FeatureToggleActions;
|