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

Support Physical Infrastructure policies in the UI #1504

Merged
merged 1 commit into from
Jun 12, 2017
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/application_controller/tree_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def squash_toggle
def find_record
# TODO: This logic should probably be reversed - fixed list for VmOrTemplate.
# (Better yet, override the method only in VmOrTemplate related controllers.)
if %w(host container_replicator container_group container_node container_image ext_management_system).include? controller_name
if %w(host container_replicator container_group container_node container_image ext_management_system physical_server).include? controller_name
identify_record(params[:id], controller_name.classify)
else
identify_record(params[:id], VmOrTemplate)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/miq_policy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MiqPolicyController < ApplicationController
after_action :cleanup_action
after_action :set_session_data

UI_FOLDERS = [Host, Vm, ContainerReplicator, ContainerGroup, ContainerNode, ContainerImage, ExtManagementSystem].freeze
UI_FOLDERS = [Host, Vm, ContainerReplicator, ContainerGroup, ContainerNode, ContainerImage, ExtManagementSystem, PhysicalServer].freeze

def export
@breadcrumbs = []
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/miq_policy_controller/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def policy_edit

case params[:button]
when "save", "add"
$log.info("===> Checking privileges...")
assert_privileges("policy_#{@policy.id ? "edit" : "new"}")
$log.info("===> Privileges checked")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra logging
Won't hurt I guess.

policy = @policy.id.blank? ? MiqPolicy.new : MiqPolicy.find(@policy.id) # Get new or existing record
policy.mode = @edit[:new][:mode]
policy.towhat = @edit[:new][:towhat] if @policy.id.blank? # Set model if new record
Expand Down
2 changes: 2 additions & 0 deletions app/decorators/miq_policy_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def fonticon
'pficon pficon-image'
when 'ExtManagementSystem'
'pficon pficon-server'
when 'PhysicalServer'
'pficon pficon-enterprise'
end
"#{icon}#{active ? '' : ' fa-inactive'}"
end
Expand Down
1 change: 1 addition & 0 deletions app/presenters/tree_builder_buttons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def buttons_node_image(node)
when 'Service' then {:icon => 'pficon pficon-service'}
when 'Storage' then {:icon => 'fa fa-database'}
when 'Vm' then {:icon => 'pficon pficon-virtual-machine'}
when 'PhysicalServer' then {:icon => 'pficon pficon-enterprise'}
end
end
end
5 changes: 4 additions & 1 deletion app/presenters/tree_builder_condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def x_get_tree_roots(count_only, _options)
:ContainerGroup => _("Pod Conditions"),
:ContainerNode => _("Container Node Conditions"),
:ContainerImage => _("Container Image Conditions"),
:ExtManagementSystem => _("Provider Conditions")}
:ExtManagementSystem => _("Provider Conditions"),
:PhysicalServer => _("Physical Infrastructure Conditions")}

objects = MiqPolicyController::UI_FOLDERS.collect do |model|
text = text_i18n[model.name.to_sym]
Expand All @@ -45,6 +46,8 @@ def x_get_tree_roots(count_only, _options)
'pficon pficon-image'
when 'ExtManagementSystem'
'pficon pficon-server'
when 'PhysicalServer'
'pficon pficon-enterprise'
end
{
:id => model.name.camelize(:lower),
Expand Down
8 changes: 6 additions & 2 deletions app/presenters/tree_builder_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ def compliance_control_kids(mode)
:ContainerGroup => _("Pod Compliance Policies"),
:ContainerNode => _("Container Node Compliance Policies"),
:ContainerImage => _("Container Image Compliance Policies"),
:ExtManagementSystem => _("Provider Compliance Policies")},
:ExtManagementSystem => _("Provider Compliance Policies"),
:PhysicalServer => _("Physical Infrastructure Compliance Policies")},
:control => {:Host => _("Host Control Policies"),
:Vm => _("Vm Control Policies"),
:ContainerReplicator => _("Replicator Control Policies"),
:ContainerGroup => _("Pod Control Policies"),
:ContainerNode => _("Container Node Control Policies"),
:ContainerImage => _("Container Image Control Policies"),
:ExtManagementSystem => _("Provider Control Policies")}}
:ExtManagementSystem => _("Provider Control Policies"),
:PhysicalServer => _("Physical Infrastructure Control Policies")}}

MiqPolicyController::UI_FOLDERS.collect do |model|
text = text_i18n[mode.to_sym][model.name.to_sym]
Expand All @@ -47,6 +49,8 @@ def compliance_control_kids(mode)
'pficon pficon-image'
when 'ExtManagementSystem'
'pficon pficon-server'
when 'PhysicalServer'
'pficon pficon-enterprise'
end
{
:id => "#{mode}-#{model.name.camelize(:lower)}",
Expand Down
2 changes: 2 additions & 0 deletions app/presenters/tree_builder_protect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def x_get_tree_hash_kids(parent, count_only)
'pficon pficon-image'
when 'ExtManagementSystem'
'pficon pficon-server'
when 'PhysicalServer'
'pficon pficon-enterprise'
end
{
:id => "policy_#{policy.id}",
Expand Down
34 changes: 18 additions & 16 deletions app/views/miq_policy/_policy_folders.html.haml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
- if @folders
- folders_i18n = {"Compliance" => _("Compliance Policies"),
"Control" => _("Control Policies"),
"Host Compliance" => _("Host Compliance Policies"),
"Vm Compliance" => _("Vm Compliance Policies"),
"Container Replicator Compliance" => _("Replicator Compliance Policies"),
"Container Group Compliance" => _("Pod Compliance Policies"),
"Container Node Compliance" => _("Container Node Compliance Policies"),
"Container Image Compliance" => _("Container Image Compliance Policies"),
"Ext Management System Compliance" => _("Provider Compliance Policies"),
"Host Control" => _("Host Control Policies"),
"Vm Control" => _("Vm Control Policies"),
"Container Replicator Control" => _("Replicator Control Policies"),
"Container Group Control" => _("Pod Control Policies"),
"Container Node Control" => _("Container Node Control Policies"),
"Container Image Control" => _("Container Image Control Policies"),
"Ext Management System Control" => _("Provider Control Policies"),
- folders_i18n = {"Compliance" => _("Compliance Policies"),
"Control" => _("Control Policies"),
"Host Compliance" => _("Host Compliance Policies"),
"Vm Compliance" => _("Vm Compliance Policies"),
"Container Replicator Compliance" => _("Replicator Compliance Policies"),
"Container Group Compliance" => _("Pod Compliance Policies"),
"Container Node Compliance" => _("Container Node Compliance Policies"),
"Container Image Compliance" => _("Container Image Compliance Policies"),
"Ext Management System Compliance" => _("Provider Compliance Policies"),
"Physical Infrastructure Compliance" => _("Physical Infrastructure Compliance Policies"),
"Host Control" => _("Host Control Policies"),
"Vm Control" => _("Vm Control Policies"),
"Container Replicator Control" => _("Replicator Control Policies"),
"Container Group Control" => _("Pod Control Policies"),
"Container Node Control" => _("Container Node Control Policies"),
"Container Image Control" => _("Container Image Control Policies"),
"Ext Management System Control" => _("Provider Control Policies"),
"Physical Infrastructure Control" => _("Physical Infrastructure Control Policies"),
}
= render :partial => "layouts/flash_msg"
%table.table.table-striped.table-bordered.table-hover
Expand Down