- 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:
Joseph Schorr 2014-04-04 23:26:10 -04:00
parent 4f4112b18d
commit c374e8146a
6 changed files with 185 additions and 13 deletions

View file

@ -17,6 +17,8 @@ from endpoints.api.discovery import swagger_route_data
from werkzeug.routing import BaseConverter
from functools import wraps
import features
logger = logging.getLogger(__name__)
route_data = None
@ -109,12 +111,17 @@ def handle_dme(ex):
def random_string():
return 'REMOVEME'
random = SystemRandom()
return ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(8)])
def render_page_template(name, **kwargs):
resp = make_response(render_template(name, route_data=json.dumps(get_route_data()),
cache_buster=random_string(), **kwargs))
feature_set=json.dumps(features.get_features()),
cache_buster=random_string(),
**kwargs))
resp.headers['X-FRAME-OPTIONS'] = 'DENY'
return resp