Commit Graph

28 Commits

Author SHA1 Message Date
Radomir Dopieralski 6c814b241d Add SYSTEM_SCOPE_SERVICES setting that hides panels
Since not all services are ready to use the system scope token,
we need a way to disable and enable the use of system scope
token on a per-service basis. This setting let us configure
which services should use the system scope token. By default
the list is empty and system scope token is not used at all.

Change-Id: I5e0cdc7288221571f183a37b800c19dc4cff5707
2022-03-10 15:13:21 +01:00
Radomir Dopieralski 34a0159d1a Add system scope support to context switcher
Change-Id: Idd2ec7ae6e978a358b4b3639e86cadae06c90976
2021-11-26 14:09:46 +01:00
Hervé Beraud 17d8ab6103 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Ic03754dcaaa4f1c0018294aa52bb05d956aa5d10
2020-06-03 10:45:18 +02:00
Ivan Kolodyazhny ee6fa9a245 Remove Keystone v2 related code
Kyestone V2 support was removed in Train, so it's safe to do such cleanup.

* Functions which just return horizon settings are dropped and
  the settings are referred directly now.
* The service catalog in the sample test data is updated to match
  the format of the keystone API v3.
* Related to the above change of the sample service catalog,
  openstack_dashboard.test.unit.api.test_keystone.ServiceAPITests is
  updated to specify the region name explicitly because 'RegionTwo'
  endpoint is no longer the second entry of the endpoint list in the
  keystone API v3.

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: Ib60f360c96341fa5c618595f4a9bfdfe7ec5ae83
2020-04-23 11:43:12 +09:00
Ivan Kolodyazhny d870b40583 Remove six usage from openstack_dashboard package
We don't support Python 2 anymore so we don't need this
compatibility library.

six.reraise usages are left as is until it'll be moved to some
base lib like oslo.utils to not re-implenent this method in
Horizon.

This patch also removes Python2-specific base test case methods
assertItemsEqual and assertNotRegexpMatches in flavor of new
Python 3 analogues.

Change-Id: I26a59176be9e9f213128e4945a58b9459334b626
2020-01-15 12:47:48 +02:00
Akihiro Motoki 2f1e1899d3 Define default settings explicitly (openstack_dashboard 5/5)
This commit mainly covers settings in the remaining files
under openstack_dashboard.

Note that HORIZON_CONFIG, horizon and openstack_auth are not covered.
They will be covered by follow-up patches.

Part of blueprint ini-based-configuration
Change-Id: Ibd70e030445a073d9a62da9867850f4893135a89
2019-07-08 18:20:32 +09:00
Akihiro Motoki 28b457bc62 UT: Detect template rendering errors
This commit enables template debug option to detect errors
in template rendering in unit tests.

Several errors in template rendering are found by enabling the
debug option and they are fixed in this commit.

Related-Bug: #1809983
Change-Id: I1a2d19f2eae62e16f02d3386abd65527bac4e7a0
2019-01-31 21:29:33 +09:00
Akihiro Motoki 826720ada3 django2: Replace assignment_tag with simple_tag
https://docs.djangoproject.com/en/2.0/releases/1.9/#assignment-tag

blueprint django2-support
Change-Id: Ib5021a4030fd9bc954365a352bdf4dccd049d28e
2018-02-17 01:36:54 +09:00
Diana Whitten 958e522d40 Added SELECTABLE_THEMES setting
Currently themes machinery works in such way that if we rely on
default theme in our branded theme, we have to include them both into
AVAILABLE_THEMES setting, otherwise default theme assets will be
unavailable and the branded theme assets compilation will fail. On
the other hand, mentioning them both leads to theme picker being
shown - which we would like to avoid (per marketing wish).

SELECTABLE_THEMES setting was added to allow limiting the user facing
themes by configuration.

Closes-bug: #1564543
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>

Change-Id: Ic00a9201d2d352685b1089a37a25987b75d6636d
2017-07-26 11:52:35 +01:00
Akihiro Motoki e6b78f92f2 Use flake8-import-order plugin
In reviews we usually check import grouping but it is boring.
By using flake8-import-order plugin, we can avoid this.
This flake8 plugin is already used in tempest.
It enforces loose checking so it sounds good to use.

Note that flake8-import-order version is pinned to avoid unexpected
breakage of pep8 job.

Change-Id: I8ccd05eb70350a2441cc2a4d1eafc09ee690b83b
2017-07-03 08:02:23 +00:00
Akihiro Motoki 35d2becdd6 Fix docstring warnings
Partial-Bug: #1411719
Partial-Bug: #1486222

Change-Id: I2d649295e7425ab73f09f3a5d91076350bf7ed7a
2016-09-24 20:44:48 +09:00
Yosef Hoffman da2e93578f Fix AttributeError in context_selection.py
When create a service with region = None,

File "/openstack_dashboard/templatetags/context_selection.py", line 100,
in <lambda>
AttributeError: 'NoneType' object has no attribute 'lower'

The problem code:

    sorted(request.user.available_services_regions,
           key=lambda x: x.lower())

To fix this, if region is NoneType, use '' as key to put it first in the
list.

Change-Id: Ide8eaeeee634bf1933ef263d3b27204c7711d167
Closes-Bug: #1581667
2016-08-17 04:00:38 -04:00
Jenkins c3f9e8beaa Merge "Fix project name refresh in project menu bar" 2016-08-03 04:43:57 +00:00
Bo Wang 0c91293a79 Pass page_url instead of whole request to render
only page url is required to be rendered in template.
move more logic code back to python.

Change-Id: I9f52d030f65084e760f37a439de02b73ef94497f
2016-05-31 10:34:52 +00:00
Vijay Katam f3825a5ff1 Fix project name refresh in project menu bar
When makes an inline update to a project name the name in the menu bar
does not get updated after reloading/refreshing the page. This happens
because the menu display is retrieved from a token in the session which
does not get updated until a switch to a different project is made.

This fix addresses this issue by retrieving project name from the request
context variable authorized_tenants which has updated information instead
of session.

Fix doc string to confirm to pep8. Update template tests to account for
tenant name in menu bar. Tests are not setting session variable for tenant
name so previosuly template did not render active tenant name, this fix
does not use session anymore so tests need to account for it.

Change-Id: Ia0d5b51699197904d1a578d188762ef39a4b67cf
Closes-Bug: 1519577
2016-05-19 14:02:53 -07:00
Bo Wang d9ebebb736 Make region list case-insensitive sorted
Function sorted() output the result as ASCII sequence in default.
sorted(['Region1', 'myregion']) will not change sequence.
Fix it for tenant list too.

Change-Id: I2e4e546ac70af1f758b618cf253f518a475b8392
Closes-Bug: #1439791
2016-03-16 16:52:18 +08:00
Diana Whitten c9de52d6bb Dynamic Themes
Horizon themes are now configurable at a user level, through the use
of cookies. The themes that can be set are configurable at a
deployment level through settings.py. Horizon can be configured to
run with multiple themes, and allow users to choose which themes
they wish to run.

Django Compressor:
In order to support dynamic themes, each theme configuration must
be pre-compiled through the Django compressor. By making use of its
built in COMPRESS_OFFLINE_CONTEXT, we now return a generator to
create each of the theme's necessary offline contexts.

Templates:
Horizon themes allowed template overrides via their 'templates'
subfolder.  In order to maintain this parity, a custom theme template
loader was created.  It is run before the other loads, and simply
looks for a Django template in the current theme (cookie driven)
before diverting to the previous template loaders.

Static Files:
Horizon themes allowed static overrides of the images in
'dashboard/img' folder.  A template tag, 'themable_asset' was created
to maintain this parity. Any asset that is wished to be made themable,
given that it is located in Horizon's 'static/dashboard' folder, can
now be made ot be themable.  By making this a template tag, this
gives the developers more granular control over what branders can
customize.

Angular and Plugins:
By far, the trickiest part of this task, Angular and Plugins are
dynamic in the files that they 'discover'.  SCSS is not flexible in
this manner at ALL.  SCSS disallows the importation of a variable
name.  To get around this, themes.scss was created as a Django
template.  This template is the top level import file for all styles
within Horizon, and therefore, allows ALL the scss files to share a
common namespace and thus, can use shared variables as well as extend
shared styles.

Other:
This change is fundamental, in that it changes the method by which
Horizon ingests its SCSS files.  Many problems existing in the
previous implementation, in an effort to make Horizon flexible, its
SCSS was made very inflexible.  This patch corrects those problems.

Change-Id: Ic48b4b5c1d1a41f1e01a8d52784c9d38d192c8f1
Implements: blueprint horizon-dynamic-theme
Closes-Bug: #1480427
2016-02-25 09:49:43 -08:00
Diana Whitten 97939292eb Horizon Context Selection should be to the right
An unintended result of a recent refactor left the context picker css
without any love. The refactor of the topbar needs to have style
parity to its previous incantation.

It was noted that the design for the current context selection is not
a good pattern to follow for responsive design.  The menu grows
horizontally, which will make it difficult to see on smaller screens
as well as when it is displayed in the now responsive topbar.  The
original design still applies to larger screens, but now on smaller
screens, the menu will fall back to a vertically growing responsive
menu.

The nav-header color has been changed, because it was also the same
color as the 'disabled' nav item state, which was confusing.

Refactoring of the some of the context_selection.py code was required
in order to support wrapping the menus in <li> tagss without needing
to change their corresponding HTML files.  Since the files can be
used as templatetag templates outside of _header.html, it was best to
keep them as stand alone <ul> lists.

Change-Id: I6e7c7b6fed08d215bcf83941da1bf90b40cd17b2
closes-bug: #1483910
partially implements bp: bootstrap-html-standards
2015-08-14 10:48:45 -07:00
Brian Tully 056151cc70 Add anti-ClickJack XFS hardening for old browsers
A Cross-Frame Scripting (XFS) vulnerability can allow an attacker to
load the vulnerable application inside an HTML iframe tag on a
malicious page. An attacker could use XFS to devise a Clickjacking
attack to conduct phishing, frame sniffing, social engineering or
Cross-Site Request Forgery attacks. Although many pages within Horizon
leverage the X-Frame-Options header with the recommended SAMEORIGIN
policy, some (still popular) older browsers don’t support this setting.
Namely, browsers older than IE 8 and Firefox 3.6.9 don’t recognize the
header and are thus vulnerable to an attack known as ClickJacking
unless an additional mitigating control is present.

To support legacy browsers, a suggested best practice is to add a
frame breaking script to the base/global template file.

Reference: http://tinyurl.com/anticlickjack

Change-Id: Ibd7acd0d7b4c4d58afcd59f025735bfc9e4c2957
Closes-Bug: 1461154
2015-07-02 12:57:35 -04:00
David Lyle 4f9d5b186e Replaces always disabled context selection link
In the context selection dropdown, there is currently an always disabled
link to do more advanced filtering. The original intent was to open a
modal to do more advanced context selection. With the use of RBAC in a
previous bp, the Identity->Projects panel is always accessible. This
panel provides the entire project list for the user. We can just use
this to provide the larger project list to select from.

Change-Id: I0d6674e75785206f3be48c8bf004a29906bb6860
Closes-Bug: #1382650
2014-10-20 15:50:12 -06:00
Akihiro Motoki 832a741c88 Fix E128 errors in remaining openstack_dashboard/
E128 continuation line under-indented for visual indent

Closes-Bug: #1375929
Change-Id: I2a72313d359bdfe2e2667eba5d3bf9744ec8f60a
2014-10-16 16:53:52 +09: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
Thiago Paiva e85f8d38c6 Show domain name in the change project dropdown
When the OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT is enabled, the
domain's UUID  is being shown in the dropdown to change project.
This patch corrects it to show the domain's name.

Change-Id: I7719d615f736f9d36c305a48f8b4caecb4d0c4ca
Closes-bug: 1378034
2014-10-06 14:51:22 -03:00
Sam Betts 302cfccb99 Sort networks and projects by name instead of UUID
Change-Id: I73b9f05303917300121ed99042cdd5004184261b
Closes-Bug: 1375206
2014-10-01 12:28:03 +01:00
Jenkins bd998fb609 Merge "Order regions in region list" 2014-09-15 13:20:55 +00:00
Cedric Brandily aac823ad95 Order tenants in tenant switch list
Currently tenants are displayed in random order in tenant switch list.
This change display them ordered.

Closes-Bug: #1368757
Change-Id: Ifc49b90b98d69254bf5e05206a334981c507a920
2014-09-12 15:11:08 +02:00
Cedric Brandily 21a15ee45e Order regions in region list
Currently regions are displayed in random order in region list. This
change display them ordered.

Closes-Bug: #1368752
Change-Id: I0029942c2762013812698a5197d2749cde9d4419
2014-09-12 15:06:18 +02:00
Thai Tran 7dd2aa8b4a Context selection for project and region
Providing the mechanism to easily switch between projects and regions.

Only shows domain info if OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT is set
to True in settings.

Will add domain switching for v3 once support for it is complete.
Will add advance filtering rules in follow up patch.

Co-Authored-By: David Lyle <david.lyle@hp.com>

Implements: blueprint context-selection

Change-Id: Ie6e81eebe822ab2394b07345d148a1c06a33a25f
2014-09-02 09:38:27 -06:00