- Add code for placing the features information on the frontend
- Add a Features service for examining feature flags on the frontend - Add a directive (quay-requires) that matches feature flags and, if any one does not match, removes the element from the DOM - Add a directive (quay-show) that injects the features into the scope so that expressions of the form "Features.BILLING || something" work out of the box to show/hide the element - Add a directive (quay-classes) that allows for setting of CSS classes on an element based on feature expression(s) such as {"!BILLING": "active"} (e.g. the BILLING flag is set to false, add the class "active".
This commit is contained in:
parent
4f4112b18d
commit
c374e8146a
6 changed files with 185 additions and 13 deletions
|
@ -1,8 +1,14 @@
|
|||
_FEATURES = {}
|
||||
|
||||
def import_features(config_dict):
|
||||
for feature, feature_val in config_dict.items():
|
||||
if feature.startswith('FEATURE_'):
|
||||
feature_name = feature[8:]
|
||||
globals()[feature_name] = FeatureNameValue(feature_name, feature_val)
|
||||
_FEATURES[feature_name] = globals()[feature_name] = FeatureNameValue(feature_name, feature_val)
|
||||
|
||||
|
||||
def get_features():
|
||||
return {key: _FEATURES[key].value for key in _FEATURES}
|
||||
|
||||
|
||||
class FeatureNameValue(object):
|
||||
|
@ -14,7 +20,7 @@ class FeatureNameValue(object):
|
|||
return '%s => %s' % (self.name, self.value)
|
||||
|
||||
def __repr__(self):
|
||||
return self.value
|
||||
return str(self.value)
|
||||
|
||||
def __cmp__(self, other):
|
||||
return self.value.__cmp__(other)
|
||||
|
|
Reference in a new issue