Add FeaturesController for *.js and context for *.jsx

[MAILPOET-2008]
This commit is contained in:
Jan Jakeš
2019-05-08 11:08:00 +02:00
committed by M. Shull
parent 343ad0008c
commit 1b091f144b
3 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
import React from 'react';
import MailPoet from 'mailpoet';
export default React.createContext(MailPoet.FeaturesController);

View File

@@ -0,0 +1,7 @@
const FeaturesController = (config) => ({
isSupported: (feature) => {
return config[feature] || false;
},
});
export default FeaturesController;

View File

@@ -1,5 +1,9 @@
import FeaturesController from 'features_controller';
// A placeholder for MailPoet object
var MailPoet = {};
var MailPoet = {
FeaturesController: FeaturesController(window.mailpoet_feature_flags),
};
// Expose MailPoet globally
window.MailPoet = MailPoet;