Skip to content

Commit db165f1

Browse files
author
Hilda Stastna
committed
Refactor get_rec_cls, add default record_class in the CiProcessing
1 parent 6a67826 commit db165f1

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

app/controllers/application_controller/ci_processing.rb

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def breadcrumb_name(_model)
222222
def process_cloud_object_storage_buttons(pressed)
223223
assert_privileges(pressed)
224224

225-
klass = get_rec_cls
225+
klass = record_class
226226
task = pressed.sub("#{klass.name.underscore.to_sym}_", "")
227227

228228
return tag(klass) if task == "tag"
@@ -247,33 +247,12 @@ def cloud_object_store_button_operation(klass, task)
247247
process_objects(items.ids.sort, method, display_name)
248248
end
249249

250-
def get_rec_cls
251-
# FIXME: the specs for ci_processing rely on setting (and testing) request.parameters['controller'].
252-
# That is wrong and needs to be fixed.
253-
case request.parameters["controller"] || controller_name
254-
when "miq_template"
255-
MiqTemplate
256-
when "orchestration_stack"
257-
params[:display] == "instances" ? VmOrTemplate : OrchestrationStack
258-
when "service"
259-
Service
260-
when "cloud_object_store_container"
261-
params[:pressed].starts_with?("cloud_object_store_object") ? CloudObjectStoreObject : CloudObjectStoreContainer
262-
when "cloud_object_store_object"
263-
CloudObjectStoreObject
264-
when "ems_storage"
265-
params[:pressed].starts_with?("cloud_object_store_object") ? CloudObjectStoreObject : CloudObjectStoreContainer
266-
when "ems_cluster"
267-
%w[all_vms vms].include?(params[:display]) || params[:pressed].starts_with?('miq_template') ? VmOrTemplate : EmsCluster
268-
when "storage"
269-
%w[all_vms vms].include?(params[:display]) ? VmOrTemplate : Storage
270-
else
271-
VmOrTemplate
272-
end
250+
def record_class
251+
VmOrTemplate
273252
end
274253

275254
def process_objects(objs, task, display_name = nil)
276-
klass = get_rec_cls
255+
klass = record_class
277256
klass_str = klass.to_s
278257

279258
assert_rbac(klass, objs)
@@ -608,7 +587,7 @@ def process_resourcepools(rps, task)
608587
# on a record
609588
# options - other optional parameters
610589
def generic_button_operation(action, action_name, operation, options = {})
611-
records = find_records_with_rbac(get_rec_cls, checked_or_params)
590+
records = find_records_with_rbac(record_class, checked_or_params)
612591
if testable_action(action) && !records_support_feature?(records, action_to_feature(action))
613592
javascript_flash(
614593
:text => _("%{action_name} action does not apply to selected items") % {:action_name => action_name},

app/controllers/vm_common.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def reload
8787
end
8888

8989
def show_timeline
90-
db = get_rec_cls
90+
db = record_class
9191
@display = "timeline"
9292
session[:tl_record_id] = params[:id] if params[:id]
9393
@record = find_record_with_rbac(db, session[:tl_record_id])

0 commit comments

Comments
 (0)