Merge "Move all RC download buttons under a single menu"

This commit is contained in:
Jenkins 2017-04-26 21:05:33 +00:00 committed by Gerrit Code Review
commit 86028ea5a6
4 changed files with 31 additions and 15 deletions

View File

@ -175,8 +175,10 @@ horizon.datatables = {
var $this = $(this);
var $action_buttons = $this.find('.table_actions button[data-batch-action="true"]');
var $more_dropdown = $this.find('.table_actions_menu > a.dropdown-toggle');
if (disable_button === undefined) {
disable_button = $this.find(".table-row-multi-select").filter(":checked").length == 0;
if (disable_button === undefined) {
var checkboxes = $this.find(".table-row-multi-select");
var checked = checkboxes.filter(":checked");
disable_button = (checkboxes.length > 0 && checked.length == 0);
}
$action_buttons.toggleClass("disabled", disable_button);
$more_dropdown.toggleClass("disabled", disable_button);

View File

@ -908,6 +908,11 @@ class DataTableOptions(object):
from this list will take precedence over actions from the
``table_actions`` list.
.. attribute:: table_actions_menu_label
A label of a menu button for ``table_actions_menu``. The default is
"Actions" or "More Actions" depending on ``table_actions``.
.. attribute:: row_actions
A list similar to ``table_actions`` except tailored to appear for
@ -1048,6 +1053,9 @@ class DataTableOptions(object):
self.table_actions = getattr(options, 'table_actions', [])
self.row_actions = getattr(options, 'row_actions', [])
self.table_actions_menu = getattr(options, 'table_actions_menu', [])
self.table_actions_menu_label = getattr(options,
'table_actions_menu_label',
None)
self.cell_class = getattr(options, 'cell_class', Cell)
self.row_class = getattr(options, 'row_class', Row)
self.column_class = getattr(options, 'column_class', Column)
@ -1517,6 +1525,9 @@ class DataTable(object):
extra_context['table_actions_menu'].append(action)
elif action != extra_context.get('filter'):
extra_context['table_actions_buttons'].append(action)
if self._meta.table_actions_menu_label:
extra_context['table_actions_menu_label'] = \
self._meta.table_actions_menu_label
context = template.RequestContext(self.request, extra_context)
self.set_multiselect_column_visibility(len(bound_actions) > 0)
return table_actions_template.render(context)

View File

@ -49,9 +49,9 @@
<div class="table_actions_menu">
<a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
{% if table_actions_buttons|length > 0 %}
{% trans "More Actions" %}
{{ table_actions_menu_label|default:_("More Actions") }}
{% else %}
{% trans "Actions" %}
{{ table_actions_menu_label|default:_("Actions") }}
{% endif %}
<span class="fa fa-caret-down"></span>
</a>

View File

@ -34,8 +34,8 @@ def pretty_service_names(name):
class DownloadEC2(tables.LinkAction):
name = "download_ec2"
verbose_name = _("Download EC2 Credentials")
verbose_name_plural = _("Download EC2 Credentials")
verbose_name = _("EC2 Credentials")
verbose_name_plural = _("EC2 Credentials")
icon = "download"
url = "horizon:project:api_access:ec2"
policy_rules = (("compute", "os_compute_api:os-certificates:create"),)
@ -46,16 +46,16 @@ class DownloadEC2(tables.LinkAction):
class DownloadCloudsYaml(tables.LinkAction):
name = "download_clouds_yaml"
verbose_name = _("Download OpenStack clouds.yaml File")
verbose_name_plural = _("Download OpenStack clouds.yaml File")
verbose_name = _("OpenStack clouds.yaml File")
verbose_name_plural = _("OpenStack clouds.yaml File")
icon = "download"
url = "horizon:project:api_access:clouds.yaml"
class DownloadOpenRC(tables.LinkAction):
name = "download_openrc"
verbose_name = _("Download OpenStack RC File v3")
verbose_name_plural = _("Download OpenStack RC File v3")
verbose_name = _("OpenStack RC File (Identity API v3)")
verbose_name_plural = _("OpenStack RC File (Identity API v3)")
icon = "download"
url = "horizon:project:api_access:openrc"
@ -65,8 +65,8 @@ class DownloadOpenRC(tables.LinkAction):
class DownloadOpenRCv2(tables.LinkAction):
name = "download_openrc_v2"
verbose_name = _("Download OpenStack RC File v2.0")
verbose_name_plural = _("Download OpenStack RC File v2.0")
verbose_name = _("OpenStack RC File (Identity API v2.0)")
verbose_name_plural = _("OpenStack RC File (Identity API v2.0)")
icon = "download"
url = "horizon:project:api_access:openrcv2"
@ -113,6 +113,9 @@ class EndpointsTable(tables.DataTable):
name = "endpoints"
verbose_name = _("API Endpoints")
multi_select = False
table_actions = (DownloadCloudsYaml, DownloadOpenRCv2, DownloadOpenRC,
DownloadEC2,
ViewCredentials, RecreateCredentials)
table_actions = (ViewCredentials, RecreateCredentials)
table_actions_menu = (DownloadCloudsYaml,
DownloadOpenRCv2,
DownloadOpenRC,
DownloadEC2)
table_actions_menu_label = _('Download OpenStack RC File')