54 Commits

Author SHA1 Message Date
Akihiro Motoki
ec970fd6e8 Handle partial dict setting
In Train cycle, we moved the definition of default values
to openstack_dashboard/defaults.py. The current code accesses
a dict member using []. It requires operators to define a dict
setting with a full member.

This commit allows to use dict-type settings with partial members.

A new function is introduced to retrieve a dict-type setting
considering default values defined in
{openstack_dashboard,horizon,openstack_auth}/defaults.py

Change-Id: I7ff0ad4bca698aef9c0eba370b0570200a14367a
Closes-Bug: #1843104
2019-09-26 14:31:17 +09:00
Akihiro Motoki
7c897b677c Move openstack_dashboard specific settings from horizon
Cookie-based settings related to openstack_dashboard are located
under horizon directory,, but they are not related to "horizon".
This commit moves them to "openstack_dashboard" directory.

Part of blueprint ini-based-configuration
Change-Id: Id48ececdbe819a95485e9a91dc5a1a163a5568c3
2019-09-12 15:05:56 +09:00
Zuul
7c5cabacec Merge "Workflow: Make steps pluggable via horizon plugin config" 2018-04-25 10:25:54 +00:00
Akihiro Motoki
e50a69d69f Workflow: Make steps pluggable via horizon plugin config
This commit enhances django workflow implementation to allow horizon
plugins to add workflow steps to a workflow in other repository like
the main horizon repo. New setting "EXTRA_STEPS" is introduced to
the horizon plugin 'enabled' file.
To this aim, the workflow class looks up HORIZON_CONFIG['extra_steps']
with its class full name and loads them as extra steps if any.
HORIZON_CONFIG['extra_steps'] are populated via horizon plugin settings.

This commit completes the blueprint.

blueprint horizon-plugin-tab-for-info-and-quotas

Change-Id: I347d113f47587932e4f583d3152e781ad1a4849f
2018-04-13 12:57:46 +00:00
Akihiro Motoki
11eb4e9d3e Fix W503 warnings
W503 line break before binary operator

Looking at the code base, it sounds okay to follow this check.

Change-Id: Id511e0104dc6de5b204021661d4a8776ca6d3658
2018-04-11 18:13:47 +09:00
irisayame
1f93e64a3d Add plugin xstatic modules support
This patch allows Horizon to accept additional xstatic modules
 in plugin dashboards. Related static files would be collected
 and included in every page.

Change-Id: Ie49a522b28aaf6e028c5b218968d68189dd7eef1
Closes-Bug: #1755339
2018-03-20 11:37:29 +09:00
Akihiro Motoki
a987c039cf 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
2018-03-12 21:04:22 +09:00
Radomir Dopieralski
dc0bce63a0 Fix collectstatic in case of theme customization
When doing theme customization with templates
collectstatic failes with a traceback

Change-Id: I0fdb80ddde1f73b657d445c75b55636d6f2e8d88
Closes-bug: #1744239
2018-02-07 19:32:42 +01:00
Akihiro Motoki
6c45c47e4b Drop unnecessary executable flags
This patch also adds checks for executable files in
pep8 job.

nose ignores executable files by default, so it is important
to ensure executable flag is not set for test files [1].
openstack_dashboard/test/test_plugins/panel_tests.py was not
tested actually and it was broken. This commit fixes it too.
[1] http://nose.readthedocs.io/en/latest/usage.html#cmdoption-exe

Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: I3a124fa2f9f0676b2b43a094e32e3d8b18fa6005
2017-12-27 21:32:48 +00:00
Ivan Udovichenko
d16f750b36 Raise detailed exception
This change allows to throw a detailed exception
in case if 'files' list has 'None' value:
"""
Exception occurred:
  File "/<<PKGBUILDDIR>>/openstack_dashboard/utils/\
    settings.py", line 263, in get_xstatic_dirs
    for file in files:
TypeError: 'NoneType' object is not iterable
"""

Closes-Bug: #1732567

Change-Id: Iaf6282819c26c12ca24d19ef7dee00a5c8586418
2017-11-29 23:52:02 +09:00
Tyler Smith
2e7dce8268 Adds extensible header functionality
This change is to introduce a flexible mechanism for projects to
add content to horizon's navbar.
- Introduces a new plugin file variable called ADD_HEADER_SECTIONS,
  which will take a list of views.  These are template views that
  will be used to render individual header sections.
- There is a new view in openstack_dashboard/views.py to cycle
  through these added views and combine them into the complete
  header to be added to the navbar.
- This view is queried by newly added javascript after page load.
  On response it is inserted into the page's navbar.
  If more than one header is present, the first will be shown in
  the navbar, while the rest are added to a drop-down menu.
- The currently displayed header can be changed by clicking on a
  new header in the drop-down; this is stored in a cookie to
  persist the selection between pages.
- Unit tests were modified/added to verify the new plugin entry
  can be parsed successfully and the main header view can parse
  a plugin's view successfully

Change-Id: I177b69ec4e78c17f827e540a7e669af1c29e8b59
Implements: blueprint extensible-header
Signed-off-by: Tyler Smith <tyler.smith@windriver.com>
2017-10-03 17:11:06 +00:00
Akihiro Motoki
68c57474e1 plugin framework: allow operators to override embeded enabled files
At now, the horizon plugin framework does not allow to override default panel
settings by same filename. The embeded enabled files are always processed,
so this leads to make operators difficult to change the order of panels
from the default. In the original design of the plugin mechanism,
we allow to override embeded enabled files by local/enabled files.
For more detail, see bug 1700325.

This commit changes import_dashboard_config to override an embeded enabled
file by specifying a enabled file in local/enabled with the same filename.

Closes-Bug: #1700325
Change-Id: Id6b15848206a684eca850a8f510a8ba1608bb7bf
2017-07-24 09:37:57 +09:00
Diana Whitten
c219a3efc6 Horizon Spinner/Loader should inherit from theme
The Horizon spinner was using a spinner generated and animated
entirely out of JavaScript. Since CSS3 provides animates and we have
access to icon fonts, doing everything with JavaScript is not
necessary and actually taxing on the browser. Plus, all of the
spinner options were being passed in and around with JavaScript,
including the colors.  This makes it supremely difficult to use the
theme to style the spinner.

The new spinner is just defined by a handful of templates now. There
are two clientside templates to support Legacy Horizon, and one
template in the Angular to support spinners going forward.  Legacy
Horizon had two forms of spinners, so it was broken up. Angular as
not yet made use of the inline spinner, but should follow the same
markup when it is made.

There are two types of spinners, inline spinners (those shown when a
dynamic tab content is loading) and modal spinners (various other
places).  These are consistent with each other for the 'default'
experience, but their experience can be entirely customized separate
from each other.  'material' has been augmented with loaders defined
within their design spec to show the power of this new feature.

horizon.templates.js was augmented with this refactor to support only
having to compile one tempalte at a time (instead of all of them) and
caching that template so that all of them can be recompiled later.
Also, horizon.loader.js was added to house template compilation code
that was repeated in several locations.

To test overwriting page modal spinner and inline-modal spinner
examples, please follow the instructions in _loading_inline_exmaple.html,
_loading_modal_example.html under
openstack_dashboard/themes/material/templates/horizon/client_side

Change-Id: I92bc786160e070d30691eeabd4f2a50d6e2bb395
Partially-implements: blueprint horizon-theme-css-reorg
Partially-Implements: blueprint bootstrap-html-standards
Closes-bug: #1570485
2017-04-21 11:15:52 -07:00
Gábor Antal
34a3aa0ba8 Handle log message interpolation by the logger
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I51f50935f1eeffe4960562d6309dfdf05814e595
Closes-Bug: #1596829
2017-03-31 20:59:16 +09:00
Béla Vancsics
2e738b23df Remove unused variable
TrivialFix

Change-Id: I2f5ab522f66015704238bcc4a58608edf17805a6
2017-03-08 09:05:56 +01:00
Rob Cresswell
e7ec65e55f Remove duplication from utils/settings.py
We dont need to specify a filename for those packages that already have
a MAIN defined.

Change-Id: I84e7edbad6b57a37374c1d8591e1ebaab02298b2
2017-02-02 11:01:40 +00:00
Cady_Chen
51fe944449 Replace six.iteritems(iter) with iter.items()
As mentioned in [1], we should avoid using six.iteritems(iter) to
achieve iterators. We can use iter.items() instead, as it will
return iterators in PY3 as well.

[1] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: Ieadd5fa69b3f6058c0641a5b96ef3e8e1e3f6cc2
2016-12-14 11:13:20 +08:00
Richard Jones
348069364c Re-work static_settings to clean up
This patch reduces duplication arbitrary directory choices for
xstatic package locations in the static directory.

It moves the xstatic configuration from the library into the
settings file, and the supporting functions move to
the openstack_dashboard.utils.settings module. Having the xstatic
module list in settings allows deployers to add new modules.

It standardises the paths the files are served from, reducing
potential conflicts.

It simplifies the interaction with the xstatic modules, and also uses
the new MAIN variable if present to determine the entry points used.

Since some of the xstatic packages were installed into special
snowflakes directories (not following a pattern) the references to
those (bootstrap_scss and font_awesome) have been fixed.

Change-Id: Ia5be0e96fff1a4ddd6058d6b030ddf96da4b46e7
2016-08-18 16:28:57 +03:00
Tyr Johanson
ea92e73582 Allow local/enabled panels to order relative to enabled panels
A dashboard enabled file in local/enabled is not able to appear before,
or inbetween any core panels.

The list of panels appears to be intended to be sorted by file name,
but all files in /enabled and always presented in the nav ahead of
any files from local/enabled, no matter the file name.

This appears to be a bug in util/settings.py that does an rsplit to
separate file name from path, but accidentally uses the full list of
split items, instead of just the file name.

For example, a file with __name__ of
'openstack_dashboard.enabled._1040_project_volumes_panel' splits into
['openstack_dashboard.enabled', '_1040_project_volumes_panel']. When
this list is fed to cmp(), it will always come before a panel in
local/enabled such as
['openstack_dashboard.local.enabled', '_0001_my_new_panel']

Change-Id: Ic169ccf0db1e04ec42fe999df6648117ce9efe84
Closes-Bug: 1567047
2016-04-06 13:36:05 -06:00
Thomas Goirand
8d1ec57045 [Django 1.9] Stop using django.utils.importlib
Horizon still uses django.utils.importlib which is removed from Django
1.9. We should use:
from importlib import import_module

instead of:
from django.utils.importlib import import_module

Change-Id: I422e14546468cb9c5627e746023948aab107a338
Closes-Bug: #1534522
Partially-Implements: blueprint drop-dj17
Co-Authored-By: Rob Cresswell <robert.cresswell@outlook.com>
2016-01-26 11:19:23 +00:00
Thai Tran
b56d278582 Support javascript translation for plugin
It's not possible for plugins to contribute translations to the javascript
message catalog. Right now our files are hardcoded to allow only
contributions from horizon and openstack_dashboard. This patch fixes
the issue.

Change-Id: Idde2fc6ac0bf7f762a595cf139ed5184dad64540
Closes-Bug: #1523930
2016-01-11 13:46:05 -08:00
Justin
aa4d3e603d Support angular workflow extension as a feature plugin
This patch does three things:
1) It adds the extensible service which can be used to allow plugins
to customize various containers by adding and removing items such as
workflow steps, table actions, and form fields.

2) It adds support for a "feature" plugin that can be used to add
angular modules that can then be used to customize various panels.
The feature plugin is different from a typical plugin in that it does
not add a dashboard or panel, it only adds angular modules, JS files,
HTML templates, spec files, styles, etc.

3) It updates the workflow service to make each workflow extensible
and adds IDs to the launch instance workflow steps so that this
workflow instance is now extensible.

An example feature plugin is available here:
https://drive.google.com/open?id=0Bye7buoZvOxFOXJvMTNNUTdNNUk

Documentation will be provided by this commit:
  https://review.openstack.org/244407

Implements: blueprint angular-workflow-plugin
Change-Id: I8b426b1644c26b1af063d570da19a75ac8c97c27
2015-11-13 21:18:05 +00:00
Victor Stinner
070bde3e21 Replace dict.iteritems() with six.iteritems(dict)
The iteritems() method of Python 2 dictionaries was renamed to items()
on Python 3. The overhead of creating a temporary list for items() on
Python 2 is negligible.

Replace also dict.itervalues() with six.itervalues(dict) in
horizon/test/utils.py.

Partial-Implements: blueprint porting-python3
Change-Id: Ib2d62236be2620c4626099ce80e6c8a9397a4533
2015-07-24 12:20:56 +02:00
Shaoquan Chen
41b1b42dc0 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
2015-07-01 14:14:03 +01:00
Thai Tran
60294f6aa6 Provides a mechanism for adding scss for pluggable dashboards
Users can add custom scss via the ADD_SCSS_FILES in enabled file.
Keeping the dashboard.scss for now, will remove in later patches.

Tests provided in a follow-on patch:
https://review.openstack.org/#/c/195781/

Co-Authored-By: Shaoquan Chen <sean.chen2@hp.com>
Implements: blueprint pluggable-scss
Change-Id: I34c7dd2a69eb194a0b28275baba49bdea3348f70
2015-06-26 00:57:28 +00:00
Richard Jones
742cb8a679 ngReorg - move dashboard controllers from horizon
This change moves the controller ImageFormCtrl and
hzNamespaceResourceTypeFormController from horizon (the framework)
to openstack_dashboard (the application) where they belong.

Co-Authored-By: Tyr Johanson <tyr@hp.com>
Change-Id: I2309f0867c2f657a6065003475dcb10448f907bc
Partial-Bug: #1458697
2015-06-06 04:31:34 +00:00
Jenkins
c3d1c14aaf Merge "Fix replacement of exception category list" 2015-03-28 05:14:07 +00:00
Radomir Dopieralski
ce3fea4921 Allow adding to INSTALLED_APPS from local_settings.py
Defines a new option, ADD_INSTALLED_APPS, which gets prepended
to the beginning of INSTALLED_APPS.

Change-Id: I956835c3e18edee9e223a607005b47a5c5977687
Closes-bug: #1343342
2015-02-17 08:46:56 +01:00
Shaoquan Chen
49af820365 Extending Horizon's plug-in architecture to Jasmine
Horizon has a well-defined plug-in architecture, but the
architecture doesn't cover Horizon's Jasmine spec runner.
This patch fills the gap.

This patch also
- defines a new field `js_spec_file` in HORIZON_CONFIG in settings.
- fix a bug openstack_dashboard/utils/settings.py where using python set
  to collect js files, which will cause the order of the js file lost.
  Change is made to use list to respect the js files order.
- update doc/source/topics/settings.rst to include the newly added field.

Change-Id: Idc122e8b1f917cdd344aa8f4b48fd80a6bdddb70
Close-Bug: 1421778
2015-02-13 19:03:43 +00:00
Paul Karikh
69d73ee9c4 Fix replacement of exception category list
Make config of ADD_EXCEPTIONS plugin append to the
exception category list and not replace it.

Change-Id: Ib52012bc93311ac019312b0f92b5fcb8842de53d
Co-Authored-By: Eric Peterson <eric.peterson1@twcable.com>
Closes-Bug: #1404032
2015-02-03 16:32:37 +03:00
Akihiro Motoki
26da6ed48c Fix E127 errors in remaining openstack_dashboard/
E127 continuation line over-indented for visual indent

Also fixes E127 introduces by other reviews
after other E127 fixes were merged.

Closes-Bug: #1375931
Change-Id: I0a09f1c2f74c707fc8a347f0ea5975bf2679976e
2014-10-15 13:50:07 +09:00
Akihiro Motoki
75bc2e6aa8 Remove and deprecate dashboards config from settings file
Dashboards are now configured via the pluggable dashboard/panel
mechanism and the order can be specified in the pluggable config.
On the other hand, we have HORIZON "dashboards" and its tuple order
overrides the order specified in the pluggable config.
It is confusing to be able to configure the order of dashboards
in two places, and we no longer need to have "dashboards" config
parameter in settings.py and a sample local_settings.py.

* If HORIZON_CONFIG contains "dashboards" and update_dashboards
  is called, a deprecation warning will be displayed. It is useful
  to warn operators to change OpenStack Dashboard settings.

* HORIZON_CONFIG "dashboard" parameter itself still works and
  there is no chnage in the behavior, so it is a safe change
  and have no upgrade impact.

* This change also removes default_dashboard from settings because
  it can be configured via pluggable dashboard config too.

After removing "dashboards" config, the order of the dashboards
are now controlled by the order of openstack_dashboard/enabled and
"Identity" dashboard is displayed before "Settings" dashboard
in the navigation menu.

Closes-Bug: #1366270

Change-Id: Ifa35128691c4fa4843b3c3c051682392e59905a6
2014-10-01 15:42:28 +09:00
lin-hua-cheng
f9432c46c0 Preserve dashboard order configured from settings
Change-Id: Ia9f8f6672d2e2904ee38c7b456285665650034e3
Closes-bug: #1372748
2014-09-22 21:40:02 -07:00
Gary W. Smith
1fd3706e56 Permit 'exceptions' to be omitted from HORIZON_CONFIG
Without this change, if HORIZON_CONFIG is defined in local_settings.py
and does not have an 'exceptions' entry, then horizon throws and
exception and fails to start.

Change-Id: I74f244974982d1c56ac36bdcc032d5acb2a0b274
Closes-Bug: #1368361
2014-09-12 10:57:23 -07:00
Akihiro Motoki
5d39ff1d0d Honor dashboard DISABLED over horizon settings
Change-Id: I3324cdfb46ff2843dee01e00cdf9e46cbd827a70
Closes-Bug: #1350346
2014-08-04 07:43:58 +09:00
Radomir Dopieralski
0eca7449cc Fix Flake8 style warnings in openstack_dashboard/
Warnings H904, H307 and H405 are new or considerably changed, and will
be fixed in a separate patch.

Closes-bug: #1349820
Partial-bug: #1347472

Change-Id: I4fd28990dacf16f03a4eaa6074ef59c37f1a2c14
2014-07-30 14:13:24 +02:00
Eric Peterson
19b23df0ef preserving dashboard order for update_dashboards call
the call to update_dashboards() can rewrite the existing order
of dashboards, especially a simple plugin is writen to just
add a panel to an existing dashboard

Change-Id: I67a8c58f4b367262c2d6d0df9d78ec4a5d7b944b
Closes-bug: #1342999
2014-07-28 14:43:12 +00:00
Rob Raymond
0f5a7b33dc Allow panel plugins to use ADD_EXCEPTIONS and UPDATE_HORIZON_CONFIG
This change allows panel plugins tell horizon which exceptions to treat as recoverable.
Previously only dashboard plugins were allowed to register exceptions.
Since there are now more settings that are common than specific to pluggable use case,
the doc was restructured to describe in general pluggable settings and then describe
the specific use cases.

Change-Id: I013ece33ae2b979e92be9c7ba50182025a1ecb91
Closes-bug: #1332688
2014-07-01 10:44:15 -06:00
Jenkins
79a6d4dd10 Merge "replace dict.iteritems() with six.iteritems(dict)" 2014-06-20 02:25:29 +00:00
Jenkins
90474517de Merge "Allow extensions to add Angular modules" 2014-05-30 11:45:02 +00:00
Rob Raymond
b3aec6b1d3 Allow extensions to add Angular modules
This change allows extension plugins to make use of AngularJS without
changing horizon template or javascript files.
Horizon bootstraps AngularJS once when a page loads with a list
of modules. An extension can register a list of modules and a list
of javascript files that contain these modules.

Implements blueprint: plugins-angular
Change-Id: I4a76363dd4a631cc0d2fc2c902c2f5cac0f073f2
2014-05-28 15:58:39 -06:00
Christian Berendt
6458dccb6f replace dict.iteritems() with six.iteritems(dict)
According to https://wiki.openstack.org/wiki/Python3 dict.iteritems()
should be replaced with six.iteritems(dict).

Change-Id: Ia2dcabbd071e1fcdf111ba83573785989a77aef0
2014-05-26 12:06:58 +02:00
Jenkins
7890f9052c Merge "Remove extraneous vim configuration comments" 2014-05-13 21:59:39 +00:00
Jenkins
28ae28b59f Merge "Allow static files to be exposed for any plugin" 2014-05-08 02:57:44 +00:00
Jenkins
873596905a Merge "Preventing __builtins__ from being in HORIZON_CONFIG" 2014-05-08 00:36:41 +00:00
He Yongli
e790ac070e Remove extraneous vim configuration comments
Remove vim setting:
comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4

at the top of source code files, except for files in
openstack/common.

Change-Id: I9a5c6b17c6ef7ecec601f4503dfc7b31fc72e90a
Close-bug: #1229324
2014-05-06 15:30:10 +08:00
Chad Roberts
0f5c57f72f Preventing __builtins__ from being in HORIZON_CONFIG
When we use the 'enabled' mechanism to add panels,
__builtins__ is also getting added to HORIZON_CONFIG.
Since that is undesirable, it is now prevented
by stripping it out before it gets added.

Change-Id: I3dc772210de8da9810795368df9bf1123388624d
Closes-Bug:  bug 1312180
2014-04-28 15:21:10 -04:00
Radomir Dopieralski
2d6d3e76af Allow changing any horizon settings from the plugin config files
Sometimes we want our pluggable dashboard to change more than just
the selected handful of options in the HORIZON_CONFIG. This patch
lets the configuration files for the plugins add and modify any
horizon settings.

Change-Id: I25aec577733631d1e2057bde0b12f1e50c56b05b
Closes-bug: #1302387
2014-04-22 12:06:22 +02:00
Rob Raymond
47a1181f0d Allow static files to be exposed for any plugin
Change the parsing of plugin configuration files to allow
a new Django application to be added. This enables the static file
finder to find the plugin's static files when they are referenced.
Previously only plugins that defined a new dashboard could do this.

Change-Id: I69bd8f24fa0855174a05203eabe7c932246dda21
Closes-Bug: #1309183
2014-04-21 08:44:00 -06:00
lin-hua-cheng
e1080cbe05 Plugin-based panel group configuration
Panels can be added through plugin configuration, but it is broken
if the user can only use existing panel groups. This adds the
capability to create an empty panel group that can be used by panel
configuration to add itself to the group.

Change-Id: I28d6072fc05b3a4ef5a41cd68337a7864c560525
Closes-Bug: #1287981
2014-03-29 01:05:03 +09:00