Skip to content

Commit

Permalink
Merge pull request #1534 from ZitaNemeckova/tag_ansible
Browse files Browse the repository at this point in the history
Add Tags to Ansible Tower Provider and Foreman Provider
  • Loading branch information
martinpovolny authored Jun 26, 2017
2 parents f8570ae + efbf1ac commit 2425f59
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 15 deletions.
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2210,6 +2210,10 @@ def controller_for_common_methods
case controller_name
when "vm_infra", "vm_or_template", "vm_cloud"
"vm"
when 'automation_manager'
"automation_manager_provider"
when 'provider_foreman'
"configuration_manager_provider"
else
controller_name
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/application_controller/explorer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def x_history
def x_button
model, action = pressed2model_action(params[:pressed])

allowed_models = %w(common image instance vm miq_template provider storage configscript infra_networking)
allowed_models = %w(common image instance vm miq_template provider storage configscript infra_networking automation_manager_provider configuration_manager_provider)
raise ActionController::RoutingError.new('invalid button action') unless
allowed_models.include?(model)

Expand Down Expand Up @@ -94,6 +94,8 @@ def x_button
send(method, Storage)
when 'infra_networking'
send(method, Switch)
when 'automation_manager_provider', 'configuration_manager_provider'
send(method)
else
send(method, VmOrTemplate)
end
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/application_controller/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def container_tag
tagging_edit('Container')
end

def automation_manager_provider_tag
tagging_edit('ManageIQ::Providers::AnsibleTower::AutomationManager')
end

def configuration_manager_provider_tag
tagging_edit('ManageIQ::Providers::ConfigurationManager')
end

alias_method :image_tag, :tagging_edit
alias_method :instance_tag, :tagging_edit
alias_method :vm_tag, :tagging_edit
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/automation_manager_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ def self.table_name
@table_name ||= "automation_manager"
end

CM_X_BUTTON_ALLOWED_ACTIONS = {
'configscript_service_dialog' => :configscript_service_dialog,
}.freeze

def self.model_to_name(provmodel)
if provmodel.include?("ManageIQ::Providers::AnsibleTower")
Dictionary.gettext('ansible_tower', :type => :ui_title, :translate => false)
Expand Down Expand Up @@ -50,8 +46,8 @@ def tagging
@explorer ||= true
case x_active_accord
when :automation_manager_providers
assert_privileges("automation_manager_provider_configured_system_tag")
tagging_edit('ConfiguredSystem', false)
assert_privileges("automation_manager_provider_tag")
tagging_edit('ManageIQ::Providers::AnsibleTower::AutomationManager', false)
when :automation_manager_cs_filter
assert_privileges("automation_manager_configured_system_tag")
tagging_edit('ConfiguredSystem', false)
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/mixins/manager_controller_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,15 @@ def form_fields

private

def tag_action
(params[:action] == 'x_button' && %w(automation_manager_provider_tag configuration_manager_provider_tag).include?(params[:pressed])) || (params[:action] == 'tagging' && params[:pressed] == 'reset')
end

def replace_right_cell(options = {})
if tag_action
render_tagging_form
return
end
replace_trees = options[:replace_trees]
return if @in_a_form
@explorer = true
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/provider_foreman_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def tagging
@explorer = true
case x_active_accord
when :configuration_manager_providers
assert_privileges("provider_foreman_configured_system_tag")
tagging_edit('ConfiguredSystem', false)
assert_privileges("configuration_manager_provider_tag")
tagging_edit('ManageIQ::Providers::ConfigurationManager', false)
when :configuration_manager_cs_filter
assert_privileges("configured_system_tag")
tagging_edit('ConfiguredSystem', false)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def adv_search_show_alias_checkbox?
end

def pressed2model_action(pressed)
pressed =~ /^(ems_cluster|miq_template|infra_networking)_(.*)$/ ? [$1, $2] : pressed.split('_', 2)
pressed =~ /^(ems_cluster|miq_template|infra_networking|automation_manager_provider|configuration_manager_provider)_(.*)$/ ? [$1, $2] : pressed.split('_', 2)
end

def model_for_ems(record)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ class ApplicationHelper::Toolbar::AutomationManagerProviderCenter < ApplicationH
)
]
),
]
)
])
button_group('automation_manager_policy', [
select(
:automation_manager_policy_choice,
'fa fa-shield fa-lg',
t = N_('Policy'),
t,
:items => [
button(
:automation_manager_provider_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for this Ansible Tower Providers'),
N_('Edit Tags'))
]
)
])
end
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,28 @@ class ApplicationHelper::Toolbar::AutomationManagerProvidersCenter < Application
:enabled => false,
:onwhen => "1+"
),
separator,
]
)
])
button_group('automation_manager_policy', [
select(
:automation_manager_policy_choice,
'fa fa-shield fa-lg',
t = N_('Policy'),
t,
:enabled => false,
:onwhen => "1+",
:items => [
button(
:automation_manager_provider_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for the selected Ansible Tower Providers'),
N_('Edit Tags'),
:url_parms => "main_div",
:enabled => false,
:klass => ApplicationHelper::Button::ButtonWithoutRbacCheck,
:onwhen => "1+"),
]
),
]
)
])
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ class ApplicationHelper::Toolbar::ConfigurationManagerProviderCenter < Applicati
]
),
])
button_group('configuration_manager_policy', [
select(
:configuration_manager_policy_choice,
'fa fa-shield fa-lg',
t = N_('Policy'),
t,
:items => [
button(
:configuration_manager_provider_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for this Ansible Tower Providers'),
N_('Edit Tags'))
]
)
])
end
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,23 @@ class ApplicationHelper::Toolbar::ConfigurationManagerProvidersCenter < Applicat
]
),
])
button_group('configuration_manager_policy', [
select(
:configuration_manager_policy_choice,
'fa fa-shield fa-lg',
t = N_('Policy'),
t,
:enabled => false,
:onwhen => "1+",
:items => [
button(
:configuration_manager_provider_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for this Foreman Provider'),
N_('Edit Tags'),
:url_parms => "main_div",
:onwhen => "1+")
]
)
])
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
form_fields
show
x_show
x_button
show_list
tagging_edit
),
Expand Down Expand Up @@ -2701,6 +2702,7 @@
cs_form_field_changed
users
wait_for_task
x_button
) +
adv_search_post +
x_post
Expand Down

0 comments on commit 2425f59

Please sign in to comment.