Add setting for user menu links

* User menu links can be specified in the settings page
* Defaults to the standard Open RC links (bug and help links are
  not modified in this patch)
* Url, name and icon can all be specified

Change-Id: I3cbcfbf06ede18d468d4c611ad6005cb74f1b284
Closes-Bug: 1736048
This commit is contained in:
Amelia Cordwell 2017-12-04 14:37:56 +13:00
parent 091121b10f
commit 924239073e
4 changed files with 76 additions and 12 deletions

View File

@ -897,6 +897,45 @@ Default: ``"theme"``
This setting tells Horizon in which cookie key to store the currently This setting tells Horizon in which cookie key to store the currently
set theme. The cookie expiration is currently set to a year. set theme. The cookie expiration is currently set to a year.
USER_MENU_LINKS
-----------------
.. versionadded:: 13.0.0(Queens)
Default::
[
{'name': _('OpenStack RC File v2'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrcv2',
'external': False,
},
{'name': _('OpenStack RC File v3'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrc',
'external': False,
}
]
This setting controls the additional links on the user drop down menu.
A list of dictionaries defining all of the links should be provided. This
defaults to the standard OpenStack RC files.
Each dictionary should contain these values:
name
The name of the link
url
Either the reversible Django url name or an absolute url
external
True for absolute URLs, False for django urls.
icon_classes
A list of classes for the icon next to the link. If 'None' or
an empty list is provided a download icon will show
WEBROOT WEBROOT
------- -------

View File

@ -86,6 +86,15 @@ def openstack(request):
# Adding webroot access # Adding webroot access
context['WEBROOT'] = getattr(settings, "WEBROOT", "/") context['WEBROOT'] = getattr(settings, "WEBROOT", "/")
user_menu_links = getattr(settings, "USER_MENU_LINKS", [])
if not getattr(settings, "SHOW_V2_KEYSTONE_RC", True):
user_menu_links = [
link for link in user_menu_links
if 'horizon:project:api_access:openrcv2' != link['url']]
context['USER_MENU_LINKS'] = user_menu_links
# Adding profiler support flag # Adding profiler support flag
profiler_settings = getattr(settings, 'OPENSTACK_PROFILER', {}) profiler_settings = getattr(settings, 'OPENSTACK_PROFILER', {})
profiler_enabled = profiler_settings.get('enabled', False) profiler_enabled = profiler_settings.get('enabled', False)
@ -97,7 +106,6 @@ def openstack(request):
hmac_keys, parent_id=index_view_id) hmac_keys, parent_id=index_view_id)
context['JS_CATALOG'] = get_js_catalog(conf) context['JS_CATALOG'] = get_js_catalog(conf)
context['SHOW_KEYSTONE_V2_RC'] = settings.SHOW_KEYSTONE_V2_RC
return context return context

View File

@ -291,6 +291,17 @@ SECURITY_GROUP_RULES = {
ADD_INSTALLED_APPS = [] ADD_INSTALLED_APPS = []
USER_MENU_LINKS = [
{'name': _('OpenStack RC File v2'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrcv2'
},
{'name': _('OpenStack RC File v3'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrc'
}
]
# Deprecated Theme Settings # Deprecated Theme Settings
CUSTOM_THEME_PATH = None CUSTOM_THEME_PATH = None
DEFAULT_THEME_PATH = None DEFAULT_THEME_PATH = None

View File

@ -34,20 +34,26 @@
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% if SHOW_KEYSTONE_V2_RC %}
{% for link in USER_MENU_LINKS %}
<li> <li>
<a href="{% url 'horizon:project:api_access:openrcv2' %}"> {% if link.external %}
<span class="fa fa-download"></span> <a href="{{ link.url }}">
{% trans "OpenStack RC File v2" %} {% else %}
<a href="{% url link.url %}">
{% endif %}
{% if link.icon_classes %}
<span class="fa {{ link.icon_classes | join:" "}}"></span>
{% else %}
<span class="fa fa-download"></span>
{% endif %}
{{ link.name }}
</a> </a>
</li> </li>
{% endif %} {% endfor %}
<li>
<a href="{% url 'horizon:project:api_access:openrc' %}">
<span class="fa fa-download"></span>
{% trans "OpenStack RC File v3" %}
</a>
</li>
{% themes as available_themes %} {% themes as available_themes %}
{% if available_themes and available_themes|length > 1 %} {% if available_themes and available_themes|length > 1 %}
<li class="divider"></li> <li class="divider"></li>