From f9e748e9555517d7987e6309efc7158bed38eb60 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Fri, 22 Jun 2018 12:01:08 +0200 Subject: [PATCH 01/10] Remove checkchange --- app/views/vm_common/_resize.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/vm_common/_resize.html.haml b/app/views/vm_common/_resize.html.haml index b63dafa9a0c..ed47e542ca5 100644 --- a/app/views/vm_common/_resize.html.haml +++ b/app/views/vm_common/_resize.html.haml @@ -20,8 +20,7 @@ %select{:name => 'flavor_id', 'ng-model' => 'vm.vmCloudModel.flavor_id', 'ng-options' => 'flavor.id as flavor.name for flavor in vm.flavors', - :miqrequired => true, - :checkchange => true} + :miqrequired => true} %div_for_paging{'ng-controller' => "pagingDivButtonGroupController", 'paging_div_buttons_id' => "angular_paging_div_buttons", From c4595a1fbe61a9e7d5de7fd1ff881e94a08f76aa Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Fri, 22 Jun 2018 12:06:06 +0200 Subject: [PATCH 02/10] Fix styling --- .../controllers/vm_cloud/vm_cloud_resize_form_controller.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js index 7981d5f292c..b04ba434a4b 100644 --- a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js +++ b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js @@ -27,8 +27,9 @@ ManageIQ.angular.app.controller('vmCloudResizeFormController', ['$http', '$scope $scope.submitClicked = function() { miqService.sparkleOn(); var url = '/vm_cloud/resize_vm/' + vmCloudResizeFormId + '?button=submit'; - miqService.miqAjaxButton(url, {objectId: vm.objectId, - flavor_id: vm.vmCloudModel.flavor_id}); + miqService.miqAjaxButton(url, { + objectId: vm.objectId, + flavor_id: vm.vmCloudModel.flavor_id}); }; function getResizeFormData(response) { From 99bc9d3e86c9e2428a7107225df469532c1be594 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Fri, 22 Jun 2018 12:49:30 +0200 Subject: [PATCH 03/10] Clean @record before using it --- app/controllers/mixins/actions/vm_actions/resize.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/mixins/actions/vm_actions/resize.rb b/app/controllers/mixins/actions/vm_actions/resize.rb index 73373537d1d..917edc67af5 100644 --- a/app/controllers/mixins/actions/vm_actions/resize.rb +++ b/app/controllers/mixins/actions/vm_actions/resize.rb @@ -6,6 +6,7 @@ def resizevms assert_privileges(params[:pressed]) # if coming in to edit from miq_request list view recs = checked_or_params + @record = nil if !session[:checked_items].nil? && (@lastaction == "set_checked_items" || params[:pressed] == "miq_request_edit") request_id = params[:id] @record = VmCloudReconfigureRequest.find(request_id).vms.first From 8b1dc95b9d63b71c4a25edce1705058cd619556a Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Fri, 22 Jun 2018 13:43:48 +0200 Subject: [PATCH 04/10] Don't check privileges for any value in params[:pressed] but use switch for allowed values --- app/controllers/mixins/actions/vm_actions/resize.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/mixins/actions/vm_actions/resize.rb b/app/controllers/mixins/actions/vm_actions/resize.rb index 917edc67af5..233d394b325 100644 --- a/app/controllers/mixins/actions/vm_actions/resize.rb +++ b/app/controllers/mixins/actions/vm_actions/resize.rb @@ -3,7 +3,12 @@ module Actions module VmActions module Resize def resizevms - assert_privileges(params[:pressed]) + case params[:pressed] + when "instance_resize" + assert_privileges("instance_resize") + when "miq_request_edit" + assert_privileges("miq_request_edit") + end # if coming in to edit from miq_request list view recs = checked_or_params @record = nil From b466d11cf0ed24dcddf6975c943b1d5f03a37547 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Fri, 22 Jun 2018 13:45:18 +0200 Subject: [PATCH 05/10] Delete duplicate code: recs already contains params[:id] from recs = checked_or_params line --- app/controllers/mixins/actions/vm_actions/resize.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/mixins/actions/vm_actions/resize.rb b/app/controllers/mixins/actions/vm_actions/resize.rb index 233d394b325..ccb838dd7bb 100644 --- a/app/controllers/mixins/actions/vm_actions/resize.rb +++ b/app/controllers/mixins/actions/vm_actions/resize.rb @@ -17,7 +17,6 @@ def resizevms @record = VmCloudReconfigureRequest.find(request_id).vms.first end - recs = [params[:id].to_i] if recs.blank? @record ||= find_record_with_rbac(VmOrTemplate, recs.first) # Set the VM object if @record.supports_resize? if @explorer From d69fc47e3f52be5f4435120e8704b02a6efb0d05 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Mon, 25 Jun 2018 09:49:58 +0200 Subject: [PATCH 06/10] Simplify --- app/controllers/mixins/actions/vm_actions/resize.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/mixins/actions/vm_actions/resize.rb b/app/controllers/mixins/actions/vm_actions/resize.rb index ccb838dd7bb..4ab0ee98b90 100644 --- a/app/controllers/mixins/actions/vm_actions/resize.rb +++ b/app/controllers/mixins/actions/vm_actions/resize.rb @@ -48,7 +48,7 @@ def resize ) end @sb[:explorer] = @explorer - @request_id = params[:req_id] ? params[:req_id] : nil + @request_id = params[:req_id] @in_a_form = true @resize = true render :action => "show" unless @explorer From d5e4ad7cbc1626be1dcaac2b0702ab999943adf0 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Mon, 25 Jun 2018 10:24:11 +0200 Subject: [PATCH 07/10] Use vm.formId instead of vmCloudResizeFormId for consistency sake --- .../vm_cloud/vm_cloud_resize_form_controller.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js index b04ba434a4b..55412317d16 100644 --- a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js +++ b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js @@ -6,27 +6,27 @@ ManageIQ.angular.app.controller('vmCloudResizeFormController', ['$http', '$scope flavor_id: null, }; vm.flavors = []; - vm.vmCloudResizeformId = vmCloudResizeFormId; + vm.formId = vmCloudResizeFormId; vm.objectId = objectId; ManageIQ.angular.scope = vm; - vm.newRecord = vmCloudResizeFormId == 'new'; + vm.newRecord = vm.formId == 'new'; - $http.get('/vm_cloud/resize_form_fields/' + vmCloudResizeFormId + '?objectId=' + vm.objectId) + $http.get('/vm_cloud/resize_form_fields/' + vm.formId + '?objectId=' + vm.objectId) .then(getResizeFormData) .catch(miqService.handleFailure); }; $scope.cancelClicked = function() { miqService.sparkleOn(); - var url = '/vm_cloud/resize_vm/' + vmCloudResizeFormId + '?button=cancel'; + var url = '/vm_cloud/resize_vm/' + vm.formId + '?button=cancel'; miqService.miqAjaxButton(url, {objectId: vm.objectId}); }; $scope.submitClicked = function() { miqService.sparkleOn(); - var url = '/vm_cloud/resize_vm/' + vmCloudResizeFormId + '?button=submit'; + var url = '/vm_cloud/resize_vm/' + vm.formId + '?button=submit'; miqService.miqAjaxButton(url, { objectId: vm.objectId, flavor_id: vm.vmCloudModel.flavor_id}); From 6128f848f8c9c90d691a69582f35fbb17b7818ec Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Mon, 25 Jun 2018 11:31:38 +0200 Subject: [PATCH 08/10] Raise error if unexpected params[:pressed] --- app/controllers/mixins/actions/vm_actions/resize.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/mixins/actions/vm_actions/resize.rb b/app/controllers/mixins/actions/vm_actions/resize.rb index 4ab0ee98b90..e2873b643de 100644 --- a/app/controllers/mixins/actions/vm_actions/resize.rb +++ b/app/controllers/mixins/actions/vm_actions/resize.rb @@ -8,6 +8,8 @@ def resizevms assert_privileges("instance_resize") when "miq_request_edit" assert_privileges("miq_request_edit") + else + raise MiqException::RbacPrivilegeException, _("The user is not authorized for this task or item.") end # if coming in to edit from miq_request list view recs = checked_or_params From 59c67b160140a6fd56c4d5d8eb5bb03dae398dd5 Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Mon, 25 Jun 2018 12:30:21 +0000 Subject: [PATCH 09/10] vmCloudResizeFormController - fix whitespace issues --- .../vm_cloud/vm_cloud_resize_form_controller.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js index 55412317d16..e682f71ec63 100644 --- a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js +++ b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js @@ -21,7 +21,9 @@ ManageIQ.angular.app.controller('vmCloudResizeFormController', ['$http', '$scope $scope.cancelClicked = function() { miqService.sparkleOn(); var url = '/vm_cloud/resize_vm/' + vm.formId + '?button=cancel'; - miqService.miqAjaxButton(url, {objectId: vm.objectId}); + miqService.miqAjaxButton(url, { + objectId: vm.objectId, + }); }; $scope.submitClicked = function() { @@ -29,7 +31,8 @@ ManageIQ.angular.app.controller('vmCloudResizeFormController', ['$http', '$scope var url = '/vm_cloud/resize_vm/' + vm.formId + '?button=submit'; miqService.miqAjaxButton(url, { objectId: vm.objectId, - flavor_id: vm.vmCloudModel.flavor_id}); + flavor_id: vm.vmCloudModel.flavor_id, + }); }; function getResizeFormData(response) { From eaf041f42d74a73090767150c6edc0acb4d4e97a Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Mon, 25 Jun 2018 12:30:41 +0000 Subject: [PATCH 10/10] vmCloudResizeFormController - sparkleOn before loading data from server --- .../controllers/vm_cloud/vm_cloud_resize_form_controller.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js index e682f71ec63..77a0da7bd65 100644 --- a/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js +++ b/app/assets/javascripts/controllers/vm_cloud/vm_cloud_resize_form_controller.js @@ -13,6 +13,7 @@ ManageIQ.angular.app.controller('vmCloudResizeFormController', ['$http', '$scope vm.newRecord = vm.formId == 'new'; + miqService.sparkleOn(); $http.get('/vm_cloud/resize_form_fields/' + vm.formId + '?objectId=' + vm.objectId) .then(getResizeFormData) .catch(miqService.handleFailure);