diff options
author | Akihiro Motoki <amotoki@gmail.com> | 2018-02-02 02:33:23 +0900 |
---|---|---|
committer | Akihiro Motoki <amotoki@gmail.com> | 2018-03-12 21:04:22 +0900 |
commit | a987c039cfa7943afd5bb9d1aef50c30b32ad8f4 (patch) | |
tree | 52995e07b178f8623ad6a4e70e080220f86c600c /openstack_dashboard/utils | |
parent | ec14dd91bdfacfa6b6e398b81b0a97480ff55015 (diff) | |
download | horizon-a987c039cfa7943afd5bb9d1aef50c30b32ad8f4.tar.gz |
TabGroup: Make tabs pluggable via horizon plugin config
This commit enhances django tab implementation to allow horizon plugins
to add tabs to a tab group in other repository like the main horizon repo.
New setting "EXTRA_TABS" is introduced to the horizon plugin 'enabled' file.
To this aim, the tab group class looks up HORIZON_CONFIG['extra_tabs']
with its class full name and loads them as extra tabs if any.
HORIZON_CONFIG['extra_tabs'] are populated via horizon plugin settings.
This commit moves update_settings in openstack_dashboard.test.helpers
to horizon as I would like to use it in a new horizon unit test.
blueprint horizon-plugin-tab-for-info-and-quotas
Closes-Bug: #1746754
Change-Id: Ice2469a90553754929826d14d20b4719bd1f62d3
Diffstat (limited to 'openstack_dashboard/utils')
-rw-r--r-- | openstack_dashboard/utils/settings.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py index 8b5925acd..145596d80 100644 --- a/openstack_dashboard/utils/settings.py +++ b/openstack_dashboard/utils/settings.py @@ -112,6 +112,7 @@ def update_dashboards(modules, horizon_config, installed_apps): scss_files = [] panel_customization = [] header_sections = [] + extra_tabs = {} update_horizon_config = {} for key, config in import_dashboard_config(modules): if config.get('DISABLED', False): @@ -154,6 +155,9 @@ def update_dashboards(modules, horizon_config, installed_apps): elif config.get('PANEL') or config.get('PANEL_GROUP'): config.pop("__builtins__", None) panel_customization.append(config) + _extra_tabs = config.get('EXTRA_TABS', {}).items() + for tab_key, tab_defs in _extra_tabs: + extra_tabs[tab_key] = extra_tabs.get(tab_key, tuple()) + tab_defs # Preserve the dashboard order specified in settings dashboards = ([d for d in config_dashboards if d not in disabled_dashboards] + @@ -169,6 +173,7 @@ def update_dashboards(modules, horizon_config, installed_apps): horizon_config.setdefault('js_files', []).extend(js_files) horizon_config.setdefault('js_spec_files', []).extend(js_spec_files) horizon_config.setdefault('scss_files', []).extend(scss_files) + horizon_config['extra_tabs'] = extra_tabs # apps contains reference to applications declared in the enabled folder # basically a list of applications that are internal and external plugins |