forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ems_storage_controller.rb
90 lines (70 loc) · 2.03 KB
/
ems_storage_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class EmsStorageController < ApplicationController
include Mixins::GenericListMixin
include Mixins::GenericShowMixin
include Mixins::EmsCommon
include Mixins::EmsCommon::Angular
include Mixins::GenericSessionMixin
include Mixins::BreadcrumbsMixin
before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
after_action :set_session_data
def self.model
ManageIQ::Providers::StorageManager
end
def self.table_name
@table_name ||= "ems_storage"
end
def ems_path(*args)
path_hash = {:action => 'show', :id => args[0].id.to_s }
path_hash.merge(args[1])
end
def new_ems_path
{:action => 'new'}
end
def ems_storage_form_fields
ems_form_fields
end
TYPE_CHECK_SHOW_IDENTIFIERS = %w[ems_storage_show].freeze
def check_generic_rbac
ident = "#{controller_name}_#{action_name == 'report_data' ? 'show_list' : action_name}"
return true if TYPE_CHECK_SHOW_IDENTIFIERS.include?(ident)
super
end
def type_feature_role_check
return true unless TYPE_CHECK_SHOW_IDENTIFIERS.include?("#{controller_name}_#{action_name}") && respond_to?(:feature_role)
handle_generic_rbac(role_allows?(:feature => feature_role(@record)))
end
def init_show(model_class = self.class.model)
@ems = @record = identify_record(params[:id], model_class)
return true unless type_feature_role_check
super
end
def feature_role(record)
if record.supports_object_storage?
'ems_object_storage_show'
elsif record.supports_block_storage?
'ems_block_storage_show'
end
end
def breadcrumbs_options
{
:breadcrumbs => [
{:title => _("Storage")},
],
}
end
private
def record_class
params[:pressed].starts_with?('cloud_object_store_object') ? CloudObjectStoreObject : CloudObjectStoreContainer
end
def textual_group_list
[
%i[properties status],
%i[relationships topology smart_management]
]
end
helper_method :textual_group_list
menu_section :sto
has_custom_buttons
end