From 3c0ff6f398e76151488df40249b9825a44ec10d0 Mon Sep 17 00:00:00 2001 From: Shaoquan Chen Date: Mon, 6 Jul 2015 13:14:14 -0700 Subject: [PATCH] Improving readability for Horizon top module structure This patch improves the readability on how Horizon's application level module `hz.app` is composited and how its dependency modules are organized. The dependency modules come from three sources: 1) Library modules - modules defined in third-party libraries, including angular's extensions 2) Horizon's built-in modules, including modules from `framework` components and modules from `openstack_dashboard` application core components. 3) Horizon's plug-in modules - modules from Horizon's extensions components via Horizon's plug-in mechanism. Horizon's built-in modules are managed as a couple of trees, then only the top modules of each tree should be listed in the Horizon's built-in modules. Change-Id: I989a0b5cc8b24f6b168629f4a8fa5e485dcf1a2d Closes-Bug: #1472098 --- .../templates/horizon/jasmine/jasmine.html | 2 +- openstack_dashboard/static/app/app.module.js | 46 ++++++++++++++++--- .../templates/horizon/_conf.html | 2 +- test-shim.js | 2 +- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/horizon/templates/horizon/jasmine/jasmine.html b/horizon/templates/horizon/jasmine/jasmine.html index c24ce3a031..ee0ab9a817 100644 --- a/horizon/templates/horizon/jasmine/jasmine.html +++ b/horizon/templates/horizon/jasmine/jasmine.html @@ -24,7 +24,7 @@ diff --git a/openstack_dashboard/static/app/app.module.js b/openstack_dashboard/static/app/app.module.js index c57d9f1d97..0cfd7b0dd8 100644 --- a/openstack_dashboard/static/app/app.module.js +++ b/openstack_dashboard/static/app/app.module.js @@ -12,18 +12,50 @@ * limitations under the License. */ -/*global angularModuleExtension*/ +/*global horizonPlugInModules*/ (function () { 'use strict'; + /** + * Library modules - modules defined in third-party libraries, including + * angular's extensions. + */ + var libraryModules = [ + 'ngCookies' + ]; + + /** + * Horizon's built-in modules, including modules from `framework` components + * and modules from `openstack_dashboard` application core components. + */ + var horizonBuiltInModules = [ + 'horizon.auth', + 'hz.dashboard', + 'horizon.framework', + 'horizon.openstack-service-api' + ]; + + /** + * @ngdoc overview + * @name horizon.app + * @description + * + * # horizon.app + * + * Horizon's application level module depends on modules from three + * sources: + * + * 1) Library modules. + * 2) Horizon's built-in modules. + * 3) Horizon's plug-in modules. + */ angular - .module('horizon.app', [ - 'horizon.auth', - 'horizon.openstack-service-api', - 'horizon.framework', - 'hz.dashboard', - 'ngCookies'].concat(angularModuleExtension)) + .module('horizon.app', [] + .concat(libraryModules) + .concat(horizonBuiltInModules) + .concat(horizonPlugInModules) + ) .constant('horizon.app.conf', { // Placeholders; updated by Django. diff --git a/openstack_dashboard/templates/horizon/_conf.html b/openstack_dashboard/templates/horizon/_conf.html index 77bce40f7c..3d42af67dd 100644 --- a/openstack_dashboard/templates/horizon/_conf.html +++ b/openstack_dashboard/templates/horizon/_conf.html @@ -19,7 +19,7 @@ horizon.datepickerLocale = '{{ DATEPICKER_LOCALE }}'; /* Load angular modules extensions list before we include angular/horizon.js */ - var angularModuleExtension = {{ HORIZON_CONFIG.angular_modules|default:"[]"|safe }}; + var horizonPlugInModules = {{ HORIZON_CONFIG.angular_modules|default:"[]"|safe }}; {% compress js %} diff --git a/test-shim.js b/test-shim.js index e8f185f665..81efe92b97 100644 --- a/test-shim.js +++ b/test-shim.js @@ -4,7 +4,7 @@ * Taken from default i18n file provided by Django. */ -var angularModuleExtension = []; +var horizonPlugInModules = []; (function (globals) {