Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the Delete button for servers in a zone #2213

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/ops_controller/diagnostics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def reload_server_tree
def diagnostics_set_form_vars
active_node = x_node
if active_node && active_node.split('-').first == "z"
@record = @selected_zone = @selected_server = Zone.find_by_id(active_node.split('-').last)
@record = @selected_server = Zone.find_by(:id => active_node.split('-').last)
@sb[:selected_server_id] = @selected_server.id
@sb[:selected_typ] = "zone"
if @selected_server.miq_servers.length >= 1 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ class ApplicationHelper::Toolbar::DiagnosticsZoneCenter < ApplicationHelper::Too
t,
:items => [
button(
:zone_delete,
:zone_delete_server,
'pficon pficon-delete fa-lg',
t = proc do
_('Delete Zone %{server_name} [%{server_id}]') % {:server_name => @selected_zone.name, :server_id => @selected_zone.id}
_('Delete Server %{server_name} [%{server_id}]') % {:server_name => @record.name, :server_id => @record.id}
end,
t,
:confirm => proc do
_("Do you want to delete Zone %{server_name} [%{server_id}]?") % {
:server_name => @selected_zone.name,
:server_id => @selected_zone.id
_("Do you want to delete Server %{server_name} [%{server_id}]?") % {
:server_name => @record.name,
:server_id => @record.id
}
end,
:klass => ApplicationHelper::Button::ZoneDelete
:klass => ApplicationHelper::Button::ZoneDeleteServer
),
button(
:zone_role_start,
Expand Down
1 change: 1 addition & 0 deletions app/presenters/tree_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def build_tree
# Subclass this method if active node on initial load is different than root node.
def active_node_set(tree_nodes)
@tree_state.x_node_set(tree_nodes.first[:key], @name) unless @tree_state.x_node(@name)
@tree_state.x_node(@name)
end

def set_nodes(nodes)
Expand Down
6 changes: 6 additions & 0 deletions app/presenters/tree_builder_roles_by_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ def x_get_tree_roots(_count_only, _options)
x_get_tree_miq_servers
end

def override(node, _object, _pid, _options)
if @sb[:diag_selected_id] && node[:key] == "svr-#{@sb[:diag_selected_id]}"
node[:highlighted] = true
end
end

def x_get_tree_miq_servers
@root.miq_servers.sort_by { |s| s.name.to_s }.each_with_object([]) do |server, objects|
unless @sb[:diag_selected_id] # Set default selected record vars
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe ApplicationHelper::Toolbar::MiqAeDomainCenter do
describe "definition of class" do
it "contains the server delete button" do
diagnostics_zone_center = Kernel.const_get("ApplicationHelper::Toolbar::DiagnosticsZoneCenter")
buttons = diagnostics_zone_center.definition["ldap_domain_vmdb"].buttons
button_names = []
buttons.each do |button|
button_names += button[:items].pluck(:id) if button[:items]
end
expect(button_names).to include("zone_delete_server")
end
end
end
2 changes: 1 addition & 1 deletion spec/presenters/tree_builder_roles_by_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
'state' => {'expanded' => true},
'selectable' => true,
'class' => ''},],
'state' => {'expanded' => true},
'state' => {'expanded' => true, 'selected' => true},
'class' => ''}]
expect(JSON.parse(@server_tree.locals_for_render[:bs_tree])).to eq(nodes)
end
Expand Down