From 1050755d052eea728e98089ca3ef855d899d6f69 Mon Sep 17 00:00:00 2001 From: Rob Cresswell Date: Wed, 10 Aug 2016 11:30:20 +0100 Subject: [PATCH] Add ANGULAR_FEATURES setting dict We should unify the angular features (new panels, workflows, etc.) in a single setting. This also makes it a little cleaner to read, simply using the 'truthiness' of a key rather than string comparisons. I haven't moved the 'swift_panel' setting, as that panel will be removed in the O cycle anway, so it seems pointless to move a setting causing potential issues for a single cycle. Change-Id: Ia5702ff523355ae895e14cc3d49c895128478944 --- doc/source/topics/settings.rst | 29 +++++++++++-------- .../dashboards/admin/images/urls.py | 2 +- .../dashboards/project/images/images/urls.py | 2 +- .../dashboards/project/images/urls.py | 2 +- ...10_integration_tests_deprecated.py.example | 3 +- openstack_dashboard/settings.py | 6 +++- openstack_dashboard/test/settings.py | 5 +++- .../angular-features-d677356f161322d6.yaml | 4 +++ .../image-panel-switch-38e9d3716451f9e3.yaml | 9 +++--- 9 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 releasenotes/notes/angular-features-d677356f161322d6.yaml diff --git a/doc/source/topics/settings.rst b/doc/source/topics/settings.rst index 460a403204..24fbbd0ec9 100755 --- a/doc/source/topics/settings.rst +++ b/doc/source/topics/settings.rst @@ -180,18 +180,6 @@ A dictionary containing classes of exceptions which Horizon's centralized exception handling should be aware of. Based on these exception categories, Horizon will handle the exception and display a message to the user. -``images_panel`` ------------ - -.. versionadded:: 10.0.0(Newton) - -Default: ``legacy`` - -There are currently two panel types that may be specified: ``legacy`` and -``angular``. ``legacy`` will display the Python-based (server-side) Images -panel and ``angular`` will display the Angular-based (client-side) Images -panel. - ``modal_backdrop`` ------------------ @@ -434,6 +422,23 @@ This example sorts flavors by vcpus in descending order:: 'reverse': True, } +.. _angular_features: + +``ANGULAR_FEATURES`` +-------------------- + +.. versionadded:: 10.0.0(Newton) + +Default:: + + { + 'images_panel': False + } + +A dictionary of currently available AngularJS features. This allows simple +toggling of legacy or rewritten features, such as new panels, workflows etc. + + .. _available_themes: ``AVAILABLE_THEMES`` diff --git a/openstack_dashboard/dashboards/admin/images/urls.py b/openstack_dashboard/dashboards/admin/images/urls.py index d19b970669..2c187cc764 100644 --- a/openstack_dashboard/dashboards/admin/images/urls.py +++ b/openstack_dashboard/dashboards/admin/images/urls.py @@ -21,7 +21,7 @@ from django.conf.urls import url from openstack_dashboard.dashboards.admin.images import views -if settings.HORIZON_CONFIG['images_panel'] == 'angular': +if settings.ANGULAR_FEATURES['images_panel']: # New angular images urlpatterns = [ url(r'^$', views.AngularIndexView.as_view(), name='index'), diff --git a/openstack_dashboard/dashboards/project/images/images/urls.py b/openstack_dashboard/dashboards/project/images/images/urls.py index 8d01d1a1b5..3f9bb78b14 100644 --- a/openstack_dashboard/dashboards/project/images/images/urls.py +++ b/openstack_dashboard/dashboards/project/images/images/urls.py @@ -23,7 +23,7 @@ from openstack_dashboard.dashboards.project.images.images import views from openstack_dashboard.dashboards.project.images import views as imgviews -if settings.HORIZON_CONFIG['images_panel'] == 'angular': +if settings.ANGULAR_FEATURES['images_panel']: urlpatterns = [ url(r'^(?P[^/]+)/$', imgviews.AngularIndexView.as_view(), name='detail'), diff --git a/openstack_dashboard/dashboards/project/images/urls.py b/openstack_dashboard/dashboards/project/images/urls.py index fd9e574c99..51a4504ec2 100644 --- a/openstack_dashboard/dashboards/project/images/urls.py +++ b/openstack_dashboard/dashboards/project/images/urls.py @@ -27,7 +27,7 @@ from openstack_dashboard.dashboards.project.images.snapshots \ from openstack_dashboard.dashboards.project.images import views -if settings.HORIZON_CONFIG['images_panel'] == 'angular': +if settings.ANGULAR_FEATURES['images_panel']: # New angular images urlpatterns = [ url(r'^$', views.AngularIndexView.as_view(), name='index'), diff --git a/openstack_dashboard/local/local_settings.d/_2010_integration_tests_deprecated.py.example b/openstack_dashboard/local/local_settings.d/_2010_integration_tests_deprecated.py.example index e87458a56a..87c9e6718b 100644 --- a/openstack_dashboard/local/local_settings.d/_2010_integration_tests_deprecated.py.example +++ b/openstack_dashboard/local/local_settings.d/_2010_integration_tests_deprecated.py.example @@ -2,5 +2,4 @@ # wanting to only test legacy panels. Since 'local' modules are evaluated # after settings.py, these configurations will override the default settings. -HORIZON_CONFIG.update({"images_panel": "legacy"}) -HORIZON_CONFIG.update({"flavors_panel": "legacy"}) +ANGULAR_FEATURES.update({"images_panel": False}) \ No newline at end of file diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 64dbab27df..558e46081d 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -79,7 +79,6 @@ HORIZON_CONFIG = { 'js_spec_files': [], 'external_templates': [], 'plugins': [], - 'images_panel': 'legacy', 'integration_tests_support': INTEGRATION_TESTS_SUPPORT } @@ -298,6 +297,11 @@ CSRF_COOKIE_AGE = None COMPRESS_OFFLINE_CONTEXT = 'horizon.themes.offline_context' +# Dictionary of currently available angular features +ANGULAR_FEATURES = { + 'images_panel': False, +} + # Notice all customizable configurations should be above this line try: from local.local_settings import * # noqa diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py index cecabc2571..40866b72ee 100644 --- a/openstack_dashboard/test/settings.py +++ b/openstack_dashboard/test/settings.py @@ -96,7 +96,10 @@ HORIZON_CONFIG = { 'unauthorized': exceptions.UNAUTHORIZED}, 'angular_modules': [], 'js_files': [], - 'images_panel': 'legacy', +} + +ANGULAR_FEATURES = { + 'images_panel': False # Use the legacy panel so unit tests are still run } # Load the pluggable dashboard settings diff --git a/releasenotes/notes/angular-features-d677356f161322d6.yaml b/releasenotes/notes/angular-features-d677356f161322d6.yaml new file mode 100644 index 0000000000..46e0153ca7 --- /dev/null +++ b/releasenotes/notes/angular-features-d677356f161322d6.yaml @@ -0,0 +1,4 @@ +--- +features: + - Added a new ``ANGULAR FEATURES`` dictionary to the settings. + This allows simple toggling of new AngularJS features. diff --git a/releasenotes/notes/image-panel-switch-38e9d3716451f9e3.yaml b/releasenotes/notes/image-panel-switch-38e9d3716451f9e3.yaml index a52a50e082..0220102b31 100644 --- a/releasenotes/notes/image-panel-switch-38e9d3716451f9e3.yaml +++ b/releasenotes/notes/image-panel-switch-38e9d3716451f9e3.yaml @@ -1,11 +1,12 @@ --- prelude: > - The Image panel now may be configured to use + The Images panel now may be configured to use either the legacy or Angular code. features: - - HORIZON_CONFIG now allows for a key 'images_panel' to be - specified as 'legacy' or 'angular' indicating the type of - panel to use. + - the ``ANGULAR_FEATURES`` setting now allows for a key + ``images_panel``. If set to ``True``, then the Angular + Images panel will be used, while the Python version will + be used if set to ``False``. - Integration tests for Image features may also be toggled in openstack_dashboard/test/integration_tests/horizon.conf using the 'panel_type' feature, either set to 'legacy' or