Skip to content

Commit

Permalink
Made "Advanced" tab visible for all Server nodes.
Browse files Browse the repository at this point in the history
Allow edit of advanced config setting for all servers. Made changes so this code can be used to edit Zone/Region config settings in future.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1536524
  • Loading branch information
h-kataria committed May 10, 2018
1 parent 393d218 commit 39f0e57
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
46 changes: 27 additions & 19 deletions app/controllers/ops_controller/settings/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,29 @@ def pglogical_validate_subscription

PASSWORD_MASK = '●●●●●●●●'.freeze

def fetch_advanced_settings(resource)
@edit = {}
@edit[:current] = {:file_data => VMDB::Config.get_file(resource)}
@edit[:new] = copy_hash(@edit[:current])
@edit[:key] = "#{@sb[:active_tab]}_edit__#{@sb[:selected_server_id]}"
@in_a_form = true
end

def save_advanced_settings(resource)
result = VMDB::Config.save_file(@edit[:new][:file_data], resource) # Save the config file
if result != true # Result contains errors?
result.each do |field, msg|
add_flash("#{field.to_s.titleize}: #{msg}", :error)
end
@changed = (@edit[:new] != @edit[:current])
else
add_flash(_("Configuration changes saved"))
@changed = false
end
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
end

def find_or_new_subscription(id = nil)
id.nil? ? PglogicalSubscription.new : PglogicalSubscription.find(id)
end
Expand Down Expand Up @@ -424,19 +447,8 @@ def settings_update_save
when "settings_custom_logos" # Custom Logo tab
@changed = (@edit[:new] != @edit[:current].config)
@update = VMDB::Config.new("vmdb") # Get the settings object to update it
when "settings_advanced" # Advanced manual yaml editor tab
result = VMDB::Config.save_file(@edit[:new][:file_data]) # Save the config file
if result != true # Result contains errors?
result.each do |field, msg|
add_flash("#{field.to_s.titleize}: #{msg}", :error)
end
@changed = (@edit[:new] != @edit[:current])
else
add_flash(_("Configuration changes saved"))
@changed = false
end
get_node_info(x_node)
replace_right_cell(:nodetype => @nodetype)
when "settings_advanced" # Advanced manual yaml editor tab
save_advanced_settings(MiqServer.find(@sb[:selected_server_id]))
return
end
if !%w(settings_advanced settings_rhn_edit settings_workers).include?(@sb[:active_tab]) &&
Expand Down Expand Up @@ -1079,12 +1091,8 @@ def settings_set_form_vars
@logo_file = @@logo_file
@login_logo_file = @@login_logo_file
@in_a_form = true
when "settings_advanced" # Advanced yaml editor
@edit = {}
@edit[:current] = {:file_data => VMDB::Config.get_file}
@edit[:new] = copy_hash(@edit[:current])
@edit[:key] = "#{@sb[:active_tab]}_edit__#{@sb[:selected_server_id]}"
@in_a_form = true
when "settings_advanced" # Advanced yaml editor
fetch_advanced_settings(MiqServer.find(@sb[:selected_server_id]))
end
if %w(settings_server settings_authentication settings_custom_logos).include?(@sb[:active_tab]) &&
x_node.split("-").first != "z"
Expand Down
8 changes: 4 additions & 4 deletions app/views/ops/_all_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
- if cur_svr_id == my_server.id
= miq_tab_header("settings_custom_logos", @sb[:active_tab]) do
= _("Custom Logos")
= miq_tab_header("settings_advanced", @sb[:active_tab]) do
= _("Advanced")
= miq_tab_header("settings_advanced", @sb[:active_tab]) do
= _("Advanced")
.tab-content
= miq_tab_content("settings_server", @sb[:active_tab]) do
= render :partial => "settings_server_tab"
Expand All @@ -38,8 +38,8 @@
- if cur_svr_id == my_server.id
= miq_tab_content("settings_custom_logos", @sb[:active_tab]) do
= render :partial => "settings_custom_logos_tab"
= miq_tab_content("settings_advanced", @sb[:active_tab]) do
= render :partial => "settings_advanced_tab"
= miq_tab_content("settings_advanced", @sb[:active_tab]) do
= render :partial => "settings_advanced_tab"
- else
- if selected_settings_tree?(x_node)
.tab-content
Expand Down

0 comments on commit 39f0e57

Please sign in to comment.