mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
c544f81fba
Will know tell the user if the toggle name is already in use by an active feature toggle or an archived toggle. Also brings lates unleash-frontend fix, which prevents an invalid form from submitting. closes: #290, #291
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = () => {
|
|
const _features = [];
|
|
const _archive = [];
|
|
return {
|
|
getFeature: name => {
|
|
const toggle = _features.find(f => f.name === name);
|
|
if (toggle) {
|
|
return Promise.resolve(toggle);
|
|
} else {
|
|
return Promise.reject();
|
|
}
|
|
},
|
|
hasFeature: name => {
|
|
const toggle = _features.find(f => f.name === name);
|
|
const archived = _archive.find(f => f.name === name);
|
|
if (toggle) {
|
|
return Promise.resolve({ name, archived: false });
|
|
} else if (archived) {
|
|
return Promise.resolve({ name, archived: true });
|
|
} else {
|
|
return Promise.reject();
|
|
}
|
|
},
|
|
getFeatures: () => Promise.resolve(_features),
|
|
addFeature: feature => _features.push(feature),
|
|
getArchivedFeatures: () => Promise.resolve(_archive),
|
|
addArchivedFeature: feature => _archive.push(feature),
|
|
};
|
|
};
|