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
This commit is contained in:
parent
264ad3edd9
commit
4f9d5b186e
@ -321,6 +321,17 @@ This example sorts flavors by vcpus in descending order::
|
||||
'reverse': True,
|
||||
}
|
||||
|
||||
``DROPDOWN_MAX_ITEMS``
|
||||
----------------------
|
||||
|
||||
.. versionadded:: 2015.1(Kilo)
|
||||
|
||||
Default: ``30``
|
||||
|
||||
This setting sets the maximum number of items displayed in a dropdown.
|
||||
Dropdowns that limit based on this value need to support a way to observe
|
||||
the entire list.
|
||||
|
||||
``IMAGES_LIST_FILTER_TENANTS``
|
||||
------------------------------
|
||||
|
||||
|
@ -25,6 +25,27 @@ from openstack_dashboard import api
|
||||
from openstack_dashboard import policy
|
||||
|
||||
|
||||
class RescopeTokenToProject(tables.LinkAction):
|
||||
name = "rescope"
|
||||
verbose_name = _("Set as Active Project")
|
||||
url = "switch_tenants"
|
||||
|
||||
def allowed(self, request, project):
|
||||
# allow rescoping token to any project the user has a role on,
|
||||
# authorized_tenants, and that they are not currently scoped to
|
||||
return next((True for proj in request.user.authorized_tenants
|
||||
if proj.id == project.id and
|
||||
project.id != request.user.project_id), False)
|
||||
|
||||
def get_link_url(self, project):
|
||||
# redirects to the switch_tenants url which then will redirect
|
||||
# back to this page
|
||||
dash_url = reverse("horizon:identity:projects:index")
|
||||
base_url = reverse(self.url, args=[project.id])
|
||||
param = urlencode({"next": dash_url})
|
||||
return "?".join([base_url, param])
|
||||
|
||||
|
||||
class UpdateMembersLink(tables.LinkAction):
|
||||
name = "users"
|
||||
verbose_name = _("Modify Users")
|
||||
@ -211,7 +232,8 @@ class TenantsTable(tables.DataTable):
|
||||
verbose_name = _("Projects")
|
||||
row_class = UpdateRow
|
||||
row_actions = (UpdateMembersLink, UpdateGroupsLink, UpdateProject,
|
||||
UsageLink, ModifyQuotas, DeleteTenantsAction)
|
||||
UsageLink, ModifyQuotas, DeleteTenantsAction,
|
||||
RescopeTokenToProject)
|
||||
table_actions = (TenantFilterAction, CreateProject,
|
||||
DeleteTenantsAction)
|
||||
pagination_param = "tenant_marker"
|
||||
|
@ -248,6 +248,9 @@ IMAGE_RESERVED_CUSTOM_PROPERTIES = []
|
||||
API_RESULT_LIMIT = 1000
|
||||
API_RESULT_PAGE_SIZE = 20
|
||||
|
||||
# Specify a maximum number of items to display in a dropdown.
|
||||
DROPDOWN_MAX_ITEMS = 30
|
||||
|
||||
# The timezone of the server. This should correspond with the timezone
|
||||
# of your entire OpenStack installation, and hopefully be in UTC.
|
||||
TIME_ZONE = "UTC"
|
||||
|
@ -15,9 +15,9 @@
|
||||
{% show_project_list %}
|
||||
{% show_region_list %}
|
||||
</div>
|
||||
<div class="footer disabled">
|
||||
<div class="footer">
|
||||
<span class="glyphicon glyphicon-cog"></span>
|
||||
{% trans "Filter selections" %}
|
||||
<a href="{% url 'horizon:identity:projects:index' %}">{% trans "More Projects" %}</a>
|
||||
</div>
|
||||
</div><!-- end of dropdown-menu -->
|
||||
</div><!-- end of context-selection -->
|
||||
|
@ -63,11 +63,14 @@ def show_domain_list(context):
|
||||
@register.inclusion_tag('context_selection/_project_list.html',
|
||||
takes_context=True)
|
||||
def show_project_list(context):
|
||||
max_proj = getattr(settings,
|
||||
'DROPDOWN_MAX_ITEMS',
|
||||
30)
|
||||
if 'request' not in context:
|
||||
return {}
|
||||
request = context['request']
|
||||
context = {'projects': sorted(context['authorized_tenants'],
|
||||
key=lambda project: project.name),
|
||||
key=lambda project: project.name)[:max_proj],
|
||||
'project_id': request.user.project_id,
|
||||
'request': request}
|
||||
return context
|
||||
|
Loading…
Reference in New Issue
Block a user