diff --git a/app/controllers/ems_physical_infra_controller.rb b/app/controllers/ems_physical_infra_controller.rb index 7bbfa2cb142..758c7709e26 100644 --- a/app/controllers/ems_physical_infra_controller.rb +++ b/app/controllers/ems_physical_infra_controller.rb @@ -34,15 +34,6 @@ def change_password_ems_physical_infra_path(id = nil) "/ems_physical_infra/change_password/#{id}" end - # This method handle view objects of page - # +/ems_physical_infra/change_password/+ - def change_password - assert_privileges('ems_physical_infra_edit') - @record = find_record_with_rbac(model, params[:id]) - @title = _("Change Password for Physical Infrasctructure Provider '%{provider_name}'") % {:provider_name => @record.name} - @in_a_form = true # to show the page on all content frame - end - def restful? true end diff --git a/app/controllers/mixins/ems_common.rb b/app/controllers/mixins/ems_common.rb index 900f104d61b..651fda2c76e 100644 --- a/app/controllers/mixins/ems_common.rb +++ b/app/controllers/mixins/ems_common.rb @@ -479,8 +479,6 @@ def button javascript_redirect(:controller => "network_router", :action => "remove_interface_select", :id => find_record_with_rbac(NetworkRouter, checked_or_params)) - elsif params[:pressed] == 'ems_infra_change_password' - javascript_redirect(change_password_ems_physical_infra_path(checked_or_params.first)) elsif params[:pressed].ends_with?("_edit") || ["#{pfx}_miq_request_new", "#{pfx}_clone", "#{pfx}_migrate", "#{pfx}_publish"].include?(params[:pressed]) || params[:pressed] == 'vm_rename' && @flash_array.nil? diff --git a/app/helpers/application_helper/toolbar/ems_physical_infra_center.rb b/app/helpers/application_helper/toolbar/ems_physical_infra_center.rb index 8508557fb24..461a3475a97 100644 --- a/app/helpers/application_helper/toolbar/ems_physical_infra_center.rb +++ b/app/helpers/application_helper/toolbar/ems_physical_infra_center.rb @@ -104,12 +104,6 @@ class ApplicationHelper::Toolbar::EmsPhysicalInfraCenter < ApplicationHelper::To t = N_('Authentication'), t, :items => [ - button( - :ems_infra_change_password, - 'pficon pficon-edit fa-lg', - t = N_('Change password'), - t - ), button( :ems_physical_infra_recheck_auth_status, 'fa fa-search fa-lg', diff --git a/app/helpers/application_helper/toolbar/ems_physical_infras_center.rb b/app/helpers/application_helper/toolbar/ems_physical_infras_center.rb index 2e82fa7d44c..6e498c7589f 100644 --- a/app/helpers/application_helper/toolbar/ems_physical_infras_center.rb +++ b/app/helpers/application_helper/toolbar/ems_physical_infras_center.rb @@ -101,15 +101,6 @@ class ApplicationHelper::Toolbar::EmsPhysicalInfrasCenter < ApplicationHelper::T :enabled => false, :onwhen => "1+", :items => [ - button( - :ems_infra_change_password, - 'pficon pficon-edit fa-lg', - N_('Select a single Infrastructure Provider to Change password'), - N_('Change Password'), - :send_checked => true, - :enabled => false, - :onwhen => "1" - ), button( :ems_physical_infra_recheck_auth_status, 'fa fa-search fa-lg', diff --git a/app/javascript/oldjs/components/index.js b/app/javascript/oldjs/components/index.js index d9fd703fd1d..66f7d4ece3c 100644 --- a/app/javascript/oldjs/components/index.js +++ b/app/javascript/oldjs/components/index.js @@ -30,7 +30,6 @@ require('./pf_charts/pie-chart.component.js'); require('./pf_charts/sparkline-chart.component.js'); require('./pf_charts/trends-chart.component.js'); require('./pf_charts/utilization-trend-chart.component.js'); -require('./physical_infrastructures/change-password.js'); require('./provider-option-field-input.js'); require('./provier-option-section.js'); require('./recent-resource.js'); diff --git a/app/javascript/oldjs/components/physical_infrastructures/change-password.js b/app/javascript/oldjs/components/physical_infrastructures/change-password.js deleted file mode 100644 index 31081774aee..00000000000 --- a/app/javascript/oldjs/components/physical_infrastructures/change-password.js +++ /dev/null @@ -1,94 +0,0 @@ -(function() { - ManageIQ.angular.app.component('changePassword', { - bindings: { - recordId: '@?', - recordName: '@?', - redirectUrl: '@', - }, - controllerAs: 'vm', - controller: changePasswordFormController, - templateUrl: '/static/ems_physical_infra/change_password.html.haml', - }); - - changePasswordFormController.$inject = ['API', 'miqService']; - - function changePasswordFormController(API, miqService) { - var vm = this; - - vm.$onInit = function() { - vm.entity = 'Physical Provider'; - - vm.model = modelInit(); - vm.modelCopy = angular.copy(vm.model); - }; - - vm.saveClicked = function() { - var saveMsg = sprintf(__('Requested password change for the %s "%s".'), vm.entity, vm.recordName); - vm.saveWithAPI('post', '/api/providers/' + vm.recordId, vm.model, saveMsg); - }; - - vm.saveWithAPI = function(method, url, saveObject, saveMsg) { - miqService.sparkleOn(); - API[method](url, saveObject, { - skipErrors: [400], // server-side validation - }) - .then(miqService.redirectBack.bind(vm, saveMsg, 'success', vm.redirectUrl)) - .catch(miqService.handleFailure); - }; - - vm.resetClicked = function() { - vm.model = modelInit(); - }; - - vm.cancelClicked = function() { - miqService.sparkleOn(); - miqService.redirectBack(sprintf(__('Edit of %s "%s" was canceled by the user.'), vm.entity, vm.recordName), 'warning', vm.redirectUrl); - }; - - vm.current_and_new_password_are_equals = function() { - return isFieldsEquals(vm.model.new_password, vm.model.current_password); - }; - - vm.confirmation_and_new_password_are_different = function() { - if (vm.model.confirm_password) { - return !isFieldsEquals(vm.model.confirm_password, vm.model.new_password); - } - return false; - }; - - vm.saveable = function() { - return !!(vm.model.current_password - && vm.model.new_password - && vm.model.confirm_password - && !vm.confirmation_and_new_password_are_different() - && !vm.current_and_new_password_are_equals()); - }; - } - - /** - * Compares two fields and see if they are equal. - * If some field is empty it doesn't compares and just return false. - * - * @param {*} firstField - First field to be compared - * @param {*} secondField - Second field to be compared - * - * @return {Boolean} If one of the fields is empty, returns false - * if the fields are equal, returns true - * else return false. - */ - function isFieldsEquals(firstField, secondField) { - if (firstField && secondField) { - return firstField === secondField; - } - return false; - } - - function modelInit() { - return { - current_password: '', - new_password: '', - confirm_password: '', - action: 'change_password', - }; - } -})(); diff --git a/app/views/ems_physical_infra/change_password.html.haml b/app/views/ems_physical_infra/change_password.html.haml deleted file mode 100644 index 2381a3a7d39..00000000000 --- a/app/views/ems_physical_infra/change_password.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -- @angular_form = true - -= render :partial => "layouts/flash_msg" - -%change-password{"record-id" => @record.id, - "record-name" => @record.name, - "redirect-url" => ems_physical_infra_path(@record),} - -:javascript - miq_bootstrap('change-password'); diff --git a/app/views/static/ems_physical_infra/change_password.html.haml b/app/views/static/ems_physical_infra/change_password.html.haml deleted file mode 100644 index f3567818345..00000000000 --- a/app/views/static/ems_physical_infra/change_password.html.haml +++ /dev/null @@ -1,55 +0,0 @@ -%form.form-horizontal{"name" => "angularForm", - "model-copy" => "vm.modelCopy", - "model" => "vm.model", - "ng-cloak" => "", - "form-changed" => true, - "miq-form" => true} - - .form-group{"ng-class" => "{'has-error': angularForm.current_password.$invalid}"} - %label.col-md-2.control-label{"for" => "current_password"} - = _('Current Password') - .col-md-8 - %input.form-control{"type" => "password", - :autocomplete => "off", - "id" => "current_password", - "name" => "current_password", - "ng-model" => "vm.model.current_password", - "required" => "true", - "checkchange" => "", - "auto-focus" => ""} - %span.help-block{"ng-show" => "angularForm.current_password.$error.required"} - = _("Required") - - .form-group{"ng-class" => "{'has-error': angularForm.new_password.$invalid || vm.current_and_new_password_are_equals()}"} - %label.col-md-2.control-label{"for" => "new_password"} - = _('New Password') - .col-md-8 - %input.form-control{"type" => "password", - :autocomplete => "off", - "id" => "new_password", - "name" => "new_password", - "ng-model" => "vm.model.new_password", - "required" => "true", - "checkchange" => ""} - %span.help-block{"ng-show" => "angularForm.new_password.$error.required"} - = _("Required") - %span.help-block{"ng-show" => "vm.current_and_new_password_are_equals()"} - = _("Current and new password must be different") - - .form-group{"ng-class" => "{'has-error': angularForm.confirm_new_password.$invalid || vm.confirmation_and_new_password_are_different()}"} - %label.col-md-2.control-label{"for" => "confirm_new_password"} - = _('Confirm New Password') - .col-md-8 - %input.form-control{"type" => "password", - :autocomplete => "off", - "id" => "confirm_new_password", - "name" => "confirm_new_password", - "ng-model" => "vm.model.confirm_password", - "required" => "true", - "checkchange" => ""} - %span.help-block{"ng-show" => "angularForm.confirm_new_password.$error.required"} - = _("Required") - %span.help-block{"ng-show" => "vm.confirmation_and_new_password_are_different()"} - = _("Confirm password did not match") - - = render :partial => "layouts/angular/generic_form_buttons" diff --git a/config/routes.rb b/config/routes.rb index 6960c2b2705..d04aa6ce6b4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1225,7 +1225,6 @@ show show_list tagging_edit - change_password ), :post => %w( new diff --git a/spec/javascripts/components/physical_infrastructures/change-password_spec.js b/spec/javascripts/components/physical_infrastructures/change-password_spec.js deleted file mode 100644 index 2d4aa1c4812..00000000000 --- a/spec/javascripts/components/physical_infrastructures/change-password_spec.js +++ /dev/null @@ -1,50 +0,0 @@ -describe('change-password', function() { - var $componentController, vm, miqService, API; - - describe('load page', function() { - beforeEach(module('ManageIQ')); - beforeEach(inject(function(_$componentController_, _API_, _miqService_, $q) { - $componentController = _$componentController_; - API = _API_; - miqService = _miqService_; - - spyOn(miqService.redirectBack, 'bind'); - var deferred = $q.defer(); - spyOn(API, 'post').and.callFake(function() {return deferred.promise;}); - - var bindings = {recordId: '1111', redirectUrl: '/controller/go_back', recordName: 'provider'}; - vm = $componentController('changePassword', null, bindings); - vm.$onInit(); - })); - - it('sets saveable to false', function() { - expect(vm.saveable()).toBe(false); - }); - - it('identifies errors in user entries', function() { - vm.model.current_password = 'current_password'; - vm.model.new_password = 'current_password'; - vm.model.confirm_password = 'different_confirm_password'; - vm.model.name = 'xyz'; - - expect(vm.confirmation_and_new_password_are_different()).toBe(true); - expect(vm.current_and_new_password_are_equals()).toBe(true); - }); - - it('saves the new password', function() { - vm.model.current_password = 'current_password'; - vm.model.new_password = 'pass'; - vm.model.confirm_password = 'pass'; - vm.recordName = 'xyz'; - - expect(vm.confirmation_and_new_password_are_different()).toBe(false); - expect(vm.current_and_new_password_are_equals()).toBe(false); - - vm.saveClicked(); - expect(API.post).toHaveBeenCalledWith('/api/providers/1111', vm.model, { - skipErrors: [400], - }); - expect(miqService.redirectBack.bind).toHaveBeenCalledWith(vm, 'Requested password change for the Physical Provider \"xyz\".', 'success', vm.redirectUrl); - }); - }); -});