Merge "Fix incomplete pop-up message on delete Action"

This commit is contained in:
Zuul 2023-01-09 19:17:45 +00:00 committed by Gerrit Code Review
commit 3e01c4ba04
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,69 @@
From 25b0db5778a811c323e07958e03f33847eb7748d Mon Sep 17 00:00:00 2001
From: Enzo Candotti <enzo.candotti@windriver.com>
Date: Mon, 2 Jan 2023 13:24:07 -0300
Subject: [PATCH] Fix incomplete pop-up message on delete Action
When an Action table is created with a 'danger' action_type and a
single handler method for a single object, the 'selection' and
'help' parameters are empty. This causes the pop-up message to be
incomplete.
This patch fixes this behavior by displaying the message with
the selected objects only when one or more objects are selected.
Otherwise, it only asks for confirmation.
Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com>
---
horizon/static/horizon/js/horizon.tables.js | 21 +++++++++++++------
.../horizon/client_side/_confirm.html | 2 +-
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js
index 5f42784..b416f19 100644
--- a/horizon/static/horizon/js/horizon.tables.js
+++ b/horizon/static/horizon/js/horizon.tables.js
@@ -309,13 +309,22 @@ horizon.datatables.confirm = function(action) {
var title = interpolate(gettext("Confirm %s"), [action_string]);
// compose the action string using a template that can be overridden
- var template = horizon.templates.compiled_templates["#confirm_modal"],
- params = {
- selection: name_string,
- selection_list: name_array,
- help: help_text
- };
+ var template = horizon.templates.compiled_templates["#confirm_modal"]
+ if (name_string == "") {
+ params = {
+ selection_list: name_array,
+ help: 'This action cannot be undone.'
+ };
+
+ }
+ else {
+ params = {
+ selection: 'You have selected: ' + name_string + '.',
+ selection_list: name_array,
+ help: help_text
+ };
+ }
var body;
try {
body = $(template.render(params)).html();
diff --git a/horizon/templates/horizon/client_side/_confirm.html b/horizon/templates/horizon/client_side/_confirm.html
index f6642dd..31451f0 100644
--- a/horizon/templates/horizon/client_side/_confirm.html
+++ b/horizon/templates/horizon/client_side/_confirm.html
@@ -6,7 +6,7 @@
{% block template %}{% spaceless %}{% jstemplate %}
<div class="confirm-wrapper">
<span class="confirm-list" style="word-wrap: break-word; word-break: normal;">
- {% blocktrans %}You have selected: [[selection]]. {% endblocktrans %}
+ {% blocktrans %} [[selection]] {% endblocktrans %}
</span>
<span class="confirm-text">{% trans 'Please confirm your selection.'%} </span>
<span class="confirm-help">[[help]]</span>
--
2.25.1

View File

@ -1 +1,2 @@
0001-Use-policy_rules-for-user-role-assignment-and-group-tabs.patch
0002-Fix-incomplete-pop-up-message-on-delete-Action.patch