Skip to content

Commit

Permalink
Add Set Ownership to Key Pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
PanSpagetka committed Aug 9, 2019
1 parent eac139f commit 0a0d238
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/controllers/auth_key_pair_cloud_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class AuthKeyPairCloudController < ApplicationController
include Mixins::GenericSessionMixin
include Mixins::GenericButtonMixin
include Mixins::BreadcrumbsMixin
include Mixins::CheckedIdMixin
include Mixins::Actions::VmActions::Ownership

def self.display_methods
%w[instances]
Expand Down Expand Up @@ -38,6 +40,10 @@ def specific_buttons(pressed)
when 'auth_key_pair_cloud_new'
javascript_redirect(:action => 'new')
true
when 'key_pair_ownership'
@ownershipitems = find_records_with_rbac(ManageIQ::Providers::CloudManager::AuthKeyPair, checked_or_params)
javascript_redirect(:action => 'ownership', :rec_ids => @ownershipitems.map(&:id))
true
end
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/mixins/actions/vm_actions/ownership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def get_class_from_controller_param(controller)
VmOrTemplate
when "miq_template"
MiqTemplate
when "auth_key_pair_cloud"
ManageIQ::Providers::CloudManager::AuthKeyPair
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class ApplicationHelper::Toolbar::AuthKeyPairCloudCenter < ApplicationHelper::To
t,
:url_parms => "&refresh=y",
:confirm => N_("Warning: The selected Key Pair and ALL of its components will be permanently removed!")),
button(
:auth_key_pair_ownership,
'pficon pficon-user fa-lg',
N_('Set Ownership for the selected items'),
N_('Set Ownership'),
:klass => ApplicationHelper::Button::SetOwnership),
button(
:auth_key_pair_cloud_download,
'pficon pficon-save fa-lg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ class ApplicationHelper::Toolbar::AuthKeyPairCloudsCenter < ApplicationHelper::T
t,
:klass => ApplicationHelper::Button::AuthKeyPairCloudCreate),
separator,
button(
:key_pair_ownership,
'pficon pficon-user fa-lg',
N_('Set Ownership for the selected items'),
N_('Set Ownership'),
:url_parms => "main_div",
:send_checked => true,
:enabled => false,
:onwhen => "1+"),
button(
:auth_key_pair_cloud_delete,
'pficon pficon-delete fa-lg',
Expand Down
2 changes: 2 additions & 0 deletions app/views/auth_key_pair_cloud/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- if @display == 'instances'
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- elsif @ownershipitems
= render :partial => "shared/views/ownership"
- elsif @showtype == 'main'
= render :partial => "layouts/textual_groups_generic"
2 changes: 1 addition & 1 deletion app/views/shared/views/_ownership.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- groups_opts = [["<#{_("Don't change")}>", 'dont-change'], ["<#{_('No User Group')}>", '']]
- user_group = ''
- else
- user_group = MiqGroup.find_by(:id => @group).tenant_group? ? @group : ''
- user_group = MiqGroup.find_by(:id => @group)&.tenant_group? ? @group : ''
- groups_opts = [["<#{_('No User Group')}>", user_group]]
- groups_opts += @groups.sort

Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
tag_edit_form_field_changed
ems_form_choices
download_private_key
ownership
) +
compare_get,
:post => %w(
Expand All @@ -145,6 +146,8 @@
dynamic_checkbox_refresh
form_field_changed
listnav_search_selected
ownership_form_fields
ownership_update
protect
quick_search
sections_field_changed
Expand Down

0 comments on commit 0a0d238

Please sign in to comment.