From 9b727fcbb22b6a81b072c3e6ef3a4b4a68331182 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Mon, 14 Nov 2016 15:42:42 +0100 Subject: [PATCH] fix history button in vm infra page --- app/controllers/mixins/vm_show_mixin.rb | 2 +- app/controllers/vm_common.rb | 29 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/controllers/mixins/vm_show_mixin.rb b/app/controllers/mixins/vm_show_mixin.rb index 539cabf25ed..9b29219a38e 100644 --- a/app/controllers/mixins/vm_show_mixin.rb +++ b/app/controllers/mixins/vm_show_mixin.rb @@ -75,7 +75,7 @@ def set_active_elements(feature) self.x_active_tree ||= feature.tree_list_name self.x_active_accord ||= feature.accord_name end - get_node_info(@sb[@sb[:active_accord]].present? ? @sb[@sb[:active_accord]] : x_node) + get_node_info(x_node_right_cell) end def set_active_elements_authorized_user(tree_name, accord_name, add_nodes, klass, id) diff --git a/app/controllers/vm_common.rb b/app/controllers/vm_common.rb index 687dbb934d6..b7c100cff66 100644 --- a/app/controllers/vm_common.rb +++ b/app/controllers/vm_common.rb @@ -1655,6 +1655,11 @@ def action_type(type, amount) end end + # return correct node to right cell + def x_node_right_cell + @sb[@sb[:active_accord]].present? ? @sb[@sb[:active_accord]] : x_node + end + # set partial name and cell header for edit screens def set_right_cell_vars name = @record.try(:name).to_s @@ -1743,7 +1748,10 @@ def set_right_cell_vars partial = "layouts/performance" header = _("Capacity & Utilization data for %{vm_or_template} \"%{name}\"") % {:vm_or_template => ui_lookup(:table => table), :name => name} - x_history_add_item(:id => x_node, :text => header, :button => params[:pressed], :display => params[:display]) + x_history_add_item(:id => x_node_right_cell, + :text => header, + :button => params[:pressed], + :display => params[:display]) action = nil when "policy_sim" if params[:action] == "policies" @@ -1789,7 +1797,9 @@ def set_right_cell_vars partial = "layouts/tl_show" header = _("Timelines for %{virtual_machine} \"%{name}\"") % {:virtual_machine => ui_lookup(:table => table), :name => name} - x_history_add_item(:id => x_node, :text => header, :button => params[:pressed]) + x_history_add_item(:id => x_node_right_cell, + :text => header, + :button => params[:pressed]) action = nil else # now take care of links on summary screen @@ -1809,7 +1819,10 @@ def set_right_cell_vars :item_name => @item.kind_of?(ScanHistory) ? @item.started_on.to_s : @item.name, :action => action_type(@sb[:action], 1) } - x_history_add_item(:id => x_node, :text => header, :action => @sb[:action], :item => @item.id) + x_history_add_item(:id => x_node_right_cell, + :text => header, + :action => @sb[:action], + :item => @item.id) else header = _("\"%{action}\" for %{vm_or_template} \"%{name}\"") % { :vm_or_template => ui_lookup(:table => table), @@ -1817,9 +1830,13 @@ def set_right_cell_vars :action => action_type(@sb[:action], 2) } if @display && @display != "main" - x_history_add_item(:id => x_node, :text => header, :display => @display) - else - x_history_add_item(:id => x_node, :text => header, :action => @sb[:action]) if @sb[:action] != "drift_history" + x_history_add_item(:id => x_node_right_cell, + :text => header, + :display => @display) + elsif @sb[:action] != "drift_history" + x_history_add_item(:id => x_node_right_cell, + :text => header, + :action => @sb[:action]) end end action = nil