1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-frontend/public/js/stores/FeatureToggleActions.js

75 lines
1.8 KiB
JavaScript
Raw Normal View History

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) => {
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) => {
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 => {
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 => {
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 => {
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 => {
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;