diff --git a/app/assets/javascripts/controllers/report_data_controller.js b/app/assets/javascripts/controllers/report_data_controller.js index 07180cf1912..858c4b7c80e 100644 --- a/app/assets/javascripts/controllers/report_data_controller.js +++ b/app/assets/javascripts/controllers/report_data_controller.js @@ -14,7 +14,7 @@ } function constructSuffixForTreeUrl(initObject, item) { - var itemId = initObject.showUrl.indexOf('xx-') !== -1 ? '_-' + item.id : '-' + item.id; + var itemId = _.isString(initObject.showUrl) && initObject.showUrl.indexOf('xx-') !== -1 ? '_-' + item.id : '-' + item.id; if (item.parent_id && item.parent_id[item.parent_id.length - 1] !== '-') { itemId = item.parent_id + '_' + item.tree_id; } else if (isAllowedParent(initObject)) { @@ -37,22 +37,6 @@ return splitUrl && (splitUrl[1] === ManageIQ.controller || splitUrl[2] === 'policies'); } - function isCurrentOpsWorkerSelected(items, initObject) { - if (initObject.activeTree === 'diagnostics_tree' && ManageIQ.controller === 'ops') { - var lastSlash = initObject.showUrl.indexOf('/', 5) + 1; - var itemId = initObject.showUrl.substring(lastSlash); - if (itemId.indexOf('?id=') === -1) { - initObject.showUrl = initObject.showUrl.substring(0, lastSlash); - if (itemId) { - itemId = itemId[itemId.length - 1] === '/' ? itemId.substring(0, itemId.length - 1) : itemId; - return _.find(items, {id: itemId}); - } - } - } - - return; - } - /** * Method for init paging component for GTL. * Default paging has 5, 10, 20, 50, 100, 1000 @@ -215,7 +199,7 @@ this.$window.DoNav(item.parent_path + '/' + item.parent_id); } else if (this.initObject.isExplorer && isCurrentControllerOrPolicies(splitUrl)) { var itemId = item.id; - if (this.initObject.showUrl.indexOf('?id=') !== -1 ) { + if (_.isString(this.initObject.showUrl) && this.initObject.showUrl.indexOf('?id=') !== -1) { itemId = constructSuffixForTreeUrl(this.initObject, item); this.activateNodeSilently(itemId); } @@ -454,7 +438,6 @@ this.initObject.showUrl = splitUrl.join('/'); } } - this.onItemSelect(isCurrentOpsWorkerSelected(this.gtlData.rows, this.initObject), true); gtlData.messages && gtlData.messages.forEach(function(oneMessage) { add_flash(oneMessage.msg, oneMessage.level); }); diff --git a/app/controllers/application_controller/report_data_additional_options.rb b/app/controllers/application_controller/report_data_additional_options.rb index 4677c0b104b..f3cfd2672c3 100644 --- a/app/controllers/application_controller/report_data_additional_options.rb +++ b/app/controllers/application_controller/report_data_additional_options.rb @@ -22,7 +22,8 @@ class ApplicationController :lastaction, :display, :gtl_type, - :supported_features_filter + :supported_features_filter, + :clickable, ) do def self.from_options(options) additional_options = new @@ -36,6 +37,7 @@ def self.from_options(options) additional_options.view_suffix = options[:view_suffix] additional_options.parent_method = options[:parent_method] additional_options.supported_features_filter = options[:supported_features_filter] + additional_options.clickable = options[:clickable] additional_options end diff --git a/app/controllers/ops_controller/diagnostics.rb b/app/controllers/ops_controller/diagnostics.rb index c3fadd6ac7c..cd98ec2b841 100644 --- a/app/controllers/ops_controller/diagnostics.rb +++ b/app/controllers/ops_controller/diagnostics.rb @@ -41,7 +41,7 @@ def restart_server def pm_restart_workers assert_privileges("restart_workers") @refresh_partial = "#{@sb[:active_tab]}_tab" - worker = MiqWorker.find_by_id(@sb[:selected_worker_id]) + worker = MiqWorker.find(checked_or_params.first) wtype = worker.normalized_type case wtype when "ems_vimbroker" @@ -417,23 +417,6 @@ def diagnostics_server_list update_gtl_div('diagnostics_server_list') if pagination_or_gtl_request? end - def diagnostics_worker_selected - @explorer = true - @sb[:selected_worker_id] = params[:id] - get_workers - - render :update do |page| - page << javascript_prologue - page.replace_html(@sb[:active_tab], :partial => "#{@sb[:active_tab]}_tab") - if center_toolbar_filename.present? - page << "$('#toolbar').show();" - page << javascript_reload_toolbars - else - page << "$('#toolbar').hide();" - end - end - end - private ############################ # Build the Utilization screen for a server @@ -543,11 +526,6 @@ def refresh_server_summary end def pm_get_workers - @sb[:selected_worker_id] = nil - get_workers - end - - def get_workers @lastaction = "pm_workers_list" @force_no_grid_xml = true @no_checkboxes = true @@ -555,8 +533,16 @@ def get_workers @embedded = @pages = false @showlinks = true status = ["started", "ready", "working"] - # passing all_pages option to show all records on same page - @view, @pages = get_view(MiqWorker, :named_scope => [[:with_miq_server_id, @sb[:selected_server_id]], [:with_status, status]], :all_pages => true) # Get the records (into a view) and the paginator + + view_options = { + :named_scope => [[:with_miq_server_id, @sb[:selected_server_id]], + [:with_status, status]], + # passing all_pages option to show all records on same page + :all_pages => true, + :clickable => false, + } + @view, @pages = get_view(MiqWorker, view_options) + # setting @embedded and @pages to nil, we don't want to show sorting/paging bar on the screen' @embedded = @pages = nil end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bf513305a86..a4f3862d37b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -506,7 +506,6 @@ def db_to_controller(db, action = "show") controller = "ansible_credential" when "MiqWorker" controller = request.parameters[:controller] - action = "diagnostics_worker_selected" when "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource", "ManageIQ::Providers::CloudManager::OrchestrationStack", "ManageIQ::Providers::AnsibleTower::AutomationManager::Job", "ConfigurationScriptBase" diff --git a/app/helpers/application_helper/button/restart_workers.rb b/app/helpers/application_helper/button/restart_workers.rb deleted file mode 100644 index 18dfe64e6be..00000000000 --- a/app/helpers/application_helper/button/restart_workers.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ApplicationHelper::Button::RestartWorkers < ApplicationHelper::Button::RefreshWorkers - def disabled? - @error_message = _('Select a worker to restart') if @sb[:selected_worker_id].nil? - @error_message.present? - end -end diff --git a/app/helpers/application_helper/toolbar/diagnostics_server_center.rb b/app/helpers/application_helper/toolbar/diagnostics_server_center.rb index fc0008be646..f2cf6f15f7f 100644 --- a/app/helpers/application_helper/toolbar/diagnostics_server_center.rb +++ b/app/helpers/application_helper/toolbar/diagnostics_server_center.rb @@ -103,8 +103,11 @@ class ApplicationHelper::Toolbar::DiagnosticsServerCenter < ApplicationHelper::T 'pficon pficon-restart', N_('Select a worker to restart'), N_('Restart selected worker'), - :confirm => N_("Warning: Selected node will be restarted, do you want to continue?"), - :klass => ApplicationHelper::Button::RestartWorkers), + :confirm => N_("Warning: Selected node will be restarted, do you want to continue?"), + :klass => ApplicationHelper::Button::RefreshWorkers, + :send_checked => true, + :enabled => false, + :onwhen => "1"), ] ), ]) diff --git a/app/helpers/gtl_helper.rb b/app/helpers/gtl_helper.rb index e808d5b697c..03eea2ca61e 100644 --- a/app/helpers/gtl_helper.rb +++ b/app/helpers/gtl_helper.rb @@ -121,9 +121,21 @@ def render_gtl_javascripts(options) isExplorer: '#{options[:explorer]}' === 'true' ? true : false, records: #{!options[:selected_records].nil? ? h(j_str(options[:selected_records].to_json)) : "\'\'"}, hideSelect: #{options[:selected_records].kind_of?(Array)}, - showUrl: '#{view_to_url(options[:view], options[:parent]) if options[:view].present? && options[:view].db.present?}' + showUrl: '#{gtl_show_url(options)}' } }}); EOJ end + + def gtl_show_url(options) + # FIXME: fetch_path doesn't work on structs in a hash + if options[:report_data_additional_options].present? + # only false, nil is true + return false if options[:report_data_additional_options].clickable == false + end + + # TODO: the "what happens on nil" logic should probably live here, not in ReportDataController.prototype.initObjects + + view_to_url(options[:view], options[:parent]) if options[:view].present? && options[:view].db.present? + end end diff --git a/app/views/layouts/gtl/_list.html.haml b/app/views/layouts/gtl/_list.html.haml index a389e8b1733..bb90126bf03 100644 --- a/app/views/layouts/gtl/_list.html.haml +++ b/app/views/layouts/gtl/_list.html.haml @@ -75,8 +75,6 @@ - table.data.each do |row| - @id = to_cid(row['id']) - classes = [] - - if view.db == "MiqWorker" && @sb[:selected_worker_id].to_i == row['id'].to_i - - classes.append("selected") - if %w(MiqEventDefinition MiqTask VmdbDatabaseConnection VmdbDatabaseSetting).include?(view.db) || @embedded - classes.append("no-hover") %tr{:class => classes.join(' ')} @@ -156,8 +154,6 @@ - click = "miqTreeActivateNode('#{x_active_tree}', '#{x_node}_cr-#{to_cid(row['id'])}');" - when "MiqDialog" - click = "miqTreeActivateNode('old_dialogs_tree', '#{TreeBuilder.get_prefix_for_model("MiqDialog")}-#{to_cid(row['id'])}');" - - when "MiqWorker" - - click = remote_function(:url => {:action => 'diagnostics_worker_selected', :id => "#{row['id']}"}) - else - click = "DoNav('#{url_for_db(view.db)}');" %td.table-view-pf-select{:title => title, :onclick => click} @@ -252,8 +248,6 @@ - click = "miqTreeActivateNode('#{x_active_tree}', '#{x_node}_cr-#{to_cid(row['id'])}');" - when "MiqDialog" - click = "miqTreeActivateNode('old_dialogs_tree', '#{TreeBuilder.get_prefix_for_model("MiqDialog")}-#{to_cid(row['id'])}');" - - when "MiqWorker" - - click = remote_function(:url => {:action => 'diagnostics_worker_selected', :id => "#{row['id']}"}) - else - if view.db == "Action" - click = "DoNav('#{url_for_db("miq_action")}');" diff --git a/config/routes.rb b/config/routes.rb index bbba4a4012e..ae3fadc734c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2678,7 +2678,6 @@ db_list diagnostics_server_list diagnostics_tree_select - diagnostics_worker_selected edit_rhn explorer fetch_build diff --git a/spec/helpers/application_helper/buttons/restart_workers_spec.rb b/spec/helpers/application_helper/buttons/restart_workers_spec.rb deleted file mode 100644 index 5cecbe19a94..00000000000 --- a/spec/helpers/application_helper/buttons/restart_workers_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -describe ApplicationHelper::Button::RestartWorkers do - let(:sandbox) { {:selected_worker_id => worker_id} } - let(:view_context) { setup_view_context_with_sandbox(sandbox) } - let(:button) { described_class.new(view_context, {}, {'sb' => sandbox}, {}) } - - describe '#calculate_properties' do - before { button.calculate_properties } - context 'when worker is not selected' do - let(:worker_id) { nil } - it_behaves_like 'a disabled button', 'Select a worker to restart' - end - context 'when worker is selected' do - let(:worker_id) { 'not_nil' } - it_behaves_like 'an enabled button' - end - end -end diff --git a/spec/routing/ops_routing_spec.rb b/spec/routing/ops_routing_spec.rb index 1cbf0531032..fe648180c9e 100644 --- a/spec/routing/ops_routing_spec.rb +++ b/spec/routing/ops_routing_spec.rb @@ -50,7 +50,6 @@ db_list diagnostics_server_list diagnostics_tree_select - diagnostics_worker_selected edit_rhn explorer fetch_build