Apply auto-file-discovery to plugins
When AUTO_DISCOVER_STATIC_FILES enabled in a plugin dashboard, static files including JavaScript files and static angular html templates will be automatically discovered. Change-Id: I7a88983f2604b71431b5b18c97a5c22c37961141 Partially-Implements: blueprint auto-js-file-finding
This commit is contained in:
parent
c6c0352982
commit
41b1b42dc0
@ -1218,6 +1218,23 @@ A list of scss files to be included in the compressed set of files that are
|
||||
loaded on every page. We recommend one scss file per dashboard, use @import if
|
||||
you need to include additional scss files for panels.
|
||||
|
||||
``AUTO_DISCOVER_STATIC_FILES``
|
||||
------------------------------
|
||||
|
||||
.. versionadded:: 2015.2(Liberty)
|
||||
|
||||
If set to ``True``, JavaScript files and static angular html template files will be
|
||||
automatically discovered from the `static` folder in each apps listed in ADD_INSTALLED_APPS.
|
||||
|
||||
JavaScript source files will be ordered based on naming convention: files with extension
|
||||
`.module.js` listed first, followed by other JavaScript source files.
|
||||
|
||||
JavaScript files for testing will also be ordered based on naming convention: files with extension
|
||||
`.mock.js` listed first, followed by files with extension `.spec.js`.
|
||||
|
||||
If ADD_JS_FILES and/or ADD_JS_SPEC_FILES are also specified, files manually listed there will be
|
||||
appended to the auto-discovered files.
|
||||
|
||||
``DISABLED``
|
||||
------------
|
||||
|
||||
|
@ -24,15 +24,7 @@ ADD_ANGULAR_MODULES = [
|
||||
'hz.dashboard.identity',
|
||||
]
|
||||
|
||||
ADD_JS_FILES = [
|
||||
'dashboard/identity/identity.module.js',
|
||||
'dashboard/identity/users/users.module.js',
|
||||
]
|
||||
|
||||
ADD_JS_SPEC_FILES = [
|
||||
'dashboard/identity/identity.module.spec.js',
|
||||
'dashboard/identity/users/users.module.spec.js',
|
||||
]
|
||||
AUTO_DISCOVER_STATIC_FILES = True
|
||||
|
||||
ADD_SCSS_FILES = [
|
||||
'dashboard/identity/identity.scss'
|
||||
|
@ -18,6 +18,8 @@ import pkgutil
|
||||
from django.utils import importlib
|
||||
import six
|
||||
|
||||
from horizon.utils import file_discovery as fd
|
||||
|
||||
|
||||
def import_submodules(module):
|
||||
"""Import all submodules and make them available in a dict."""
|
||||
@ -111,7 +113,16 @@ def update_dashboards(modules, horizon_config, installed_apps):
|
||||
if config.get('DASHBOARD'):
|
||||
disabled_dashboards.append(config.get('DASHBOARD'))
|
||||
continue
|
||||
apps.extend(config.get('ADD_INSTALLED_APPS', []))
|
||||
|
||||
_apps = config.get('ADD_INSTALLED_APPS', [])
|
||||
apps.extend(_apps)
|
||||
|
||||
if config.get('AUTO_DISCOVER_STATIC_FILES', False):
|
||||
for _app in _apps:
|
||||
module = importlib.import_module(_app)
|
||||
base_path = os.path.join(module.__path__[0], 'static/')
|
||||
fd.populate_horizon_config(horizon_config, base_path)
|
||||
|
||||
for category, exc_list in config.get('ADD_EXCEPTIONS', {}).iteritems():
|
||||
exceptions[category] = tuple(set(exceptions.get(category, ())
|
||||
+ exc_list))
|
||||
|
Loading…
Reference in New Issue
Block a user