From 5b6f8e75ebd0c63cd75d4d2c34f30d2985c1846f Mon Sep 17 00:00:00 2001 From: PanSpagetka Date: Thu, 8 Aug 2019 15:30:48 +0200 Subject: [PATCH 1/2] Add Set Ownership to Key Pairs --- app/controllers/auth_key_pair_cloud_controller.rb | 6 ++++++ app/controllers/mixins/actions/vm_actions/ownership.rb | 2 ++ .../toolbar/auth_key_pair_cloud_center.rb | 6 ++++++ .../toolbar/auth_key_pair_clouds_center.rb | 9 +++++++++ app/views/auth_key_pair_cloud/show.html.haml | 2 ++ config/routes.rb | 3 +++ 6 files changed, 28 insertions(+) diff --git a/app/controllers/auth_key_pair_cloud_controller.rb b/app/controllers/auth_key_pair_cloud_controller.rb index dcdae8c0022..b50b90f5abb 100644 --- a/app/controllers/auth_key_pair_cloud_controller.rb +++ b/app/controllers/auth_key_pair_cloud_controller.rb @@ -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] @@ -38,6 +40,10 @@ def specific_buttons(pressed) when 'auth_key_pair_cloud_new' javascript_redirect(:action => 'new') true + when 'auth_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 diff --git a/app/controllers/mixins/actions/vm_actions/ownership.rb b/app/controllers/mixins/actions/vm_actions/ownership.rb index 55476bd74ad..b4ab68011a7 100644 --- a/app/controllers/mixins/actions/vm_actions/ownership.rb +++ b/app/controllers/mixins/actions/vm_actions/ownership.rb @@ -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 diff --git a/app/helpers/application_helper/toolbar/auth_key_pair_cloud_center.rb b/app/helpers/application_helper/toolbar/auth_key_pair_cloud_center.rb index 48baa2a6302..9b2718ba55b 100644 --- a/app/helpers/application_helper/toolbar/auth_key_pair_cloud_center.rb +++ b/app/helpers/application_helper/toolbar/auth_key_pair_cloud_center.rb @@ -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', diff --git a/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb b/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb index aa32b56be16..e2a3d746e6d 100644 --- a/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb +++ b/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb @@ -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', diff --git a/app/views/auth_key_pair_cloud/show.html.haml b/app/views/auth_key_pair_cloud/show.html.haml index 156bd9d1e1a..e214673063c 100644 --- a/app/views/auth_key_pair_cloud/show.html.haml +++ b/app/views/auth_key_pair_cloud/show.html.haml @@ -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" diff --git a/config/routes.rb b/config/routes.rb index 5ff0d943304..b19d04250ec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -137,6 +137,7 @@ tag_edit_form_field_changed ems_form_choices download_private_key + ownership ) + compare_get, :post => %w( @@ -145,6 +146,8 @@ dynamic_checkbox_refresh form_field_changed listnav_search_selected + ownership_form_fields + ownership_update protect quick_search sections_field_changed From 5accb14431dbe0ed8d654f8221f73bd3a90a27f1 Mon Sep 17 00:00:00 2001 From: PanSpagetka Date: Fri, 9 Aug 2019 10:50:24 +0200 Subject: [PATCH 2/2] Add Ownership info to Textual summary --- app/controllers/auth_key_pair_cloud_controller.rb | 2 +- .../toolbar/auth_key_pair_clouds_center.rb | 2 +- .../auth_key_pair_cloud_helper/textual_summary.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/auth_key_pair_cloud_controller.rb b/app/controllers/auth_key_pair_cloud_controller.rb index b50b90f5abb..1c5aea7e422 100644 --- a/app/controllers/auth_key_pair_cloud_controller.rb +++ b/app/controllers/auth_key_pair_cloud_controller.rb @@ -212,7 +212,7 @@ def process_deletions(key_pairs) private def textual_group_list - [%i[properties relationships], %i[tags]] + [%i[properties relationships lifecycle], %i[tags]] end helper_method :textual_group_list diff --git a/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb b/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb index e2a3d746e6d..bc3124efb4c 100644 --- a/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb +++ b/app/helpers/application_helper/toolbar/auth_key_pair_clouds_center.rb @@ -14,7 +14,7 @@ class ApplicationHelper::Toolbar::AuthKeyPairCloudsCenter < ApplicationHelper::T :klass => ApplicationHelper::Button::AuthKeyPairCloudCreate), separator, button( - :key_pair_ownership, + :auth_key_pair_ownership, 'pficon pficon-user fa-lg', N_('Set Ownership for the selected items'), N_('Set Ownership'), diff --git a/app/helpers/auth_key_pair_cloud_helper/textual_summary.rb b/app/helpers/auth_key_pair_cloud_helper/textual_summary.rb index 58439082387..363a1dcfe2e 100644 --- a/app/helpers/auth_key_pair_cloud_helper/textual_summary.rb +++ b/app/helpers/auth_key_pair_cloud_helper/textual_summary.rb @@ -28,4 +28,19 @@ def textual_vms end h end + + def textual_group_lifecycle + TextualGroup.new( + _("Lifecycle"), + %i[owner group] + ) + end + + def textual_owner + @record.evm_owner.try(:name) + end + + def textual_group + {:label => _("Group"), :value => @record.miq_group.try(:description)} + end end