From 6eb7ce73ec512cd6f3538b9bb902a9ecaab9d092 Mon Sep 17 00:00:00 2001 From: Gilbert Cherrie Date: Thu, 11 Jan 2024 12:32:01 -0500 Subject: [PATCH] Remove old angular controllers --- .../oldjs/components/auth-credentials.js | 77 ------------ app/javascript/oldjs/components/index.js | 1 - .../credentials/credentials_controller.js | 57 --------- app/javascript/oldjs/controllers/index.js | 1 - .../oldjs/directives/clear_field_set_focus.js | 35 ------ ...th_credentials_angular_bootstrap.html.haml | 91 -------------- .../_auth_service_account_angular.html.haml | 34 ----- app/views/static/auth-credentials.html.haml | 79 ------------ .../credentials_controller_spec.js | 118 ------------------ .../directives/clear_field_set_focus_spec.js | 43 ------- 10 files changed, 536 deletions(-) delete mode 100644 app/javascript/oldjs/components/auth-credentials.js delete mode 100644 app/javascript/oldjs/controllers/credentials/credentials_controller.js delete mode 100644 app/javascript/oldjs/directives/clear_field_set_focus.js delete mode 100644 app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml delete mode 100644 app/views/layouts/angular/_auth_service_account_angular.html.haml delete mode 100644 app/views/static/auth-credentials.html.haml delete mode 100644 spec/javascripts/controllers/credentials/credentials_controller_spec.js delete mode 100644 spec/javascripts/directives/clear_field_set_focus_spec.js diff --git a/app/javascript/oldjs/components/auth-credentials.js b/app/javascript/oldjs/components/auth-credentials.js deleted file mode 100644 index f365ed1a724b..000000000000 --- a/app/javascript/oldjs/components/auth-credentials.js +++ /dev/null @@ -1,77 +0,0 @@ -ManageIQ.angular.app.component('authCredentials', { - bindings: { - modelCopy: '<', - formModel: '<', - enableValidButton: '<', - validate: '<', - prefix: '@', - formLabels: ' "CredentialsController as vm", "vm-scope" => "$parent.vm.model ? $parent.vm : $parent"} - %div{"ng-show" => "#{ng_show} && #{ng_show_userid}"} - .form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_userid.$invalid}"} - %label.col-md-2.control-label{"for" => "#{prefix}_userid"} - = userid_label - .col-md-4 - - hash_for_userid = {"type" => "text", - "id" => "#{prefix}_userid", - "ng-required" => "#{ng_reqd_userid}", - "ng-disabled" => userid_disabled, - "name" => "#{prefix}_userid", - "ng-model" => "#{main_scope}.#{ng_model}.#{prefix}_userid", - "checkchange" => "", - "ng-trim" => false, - "detect_spaces" => "", - "prefix" => "#{prefix}", - "main-scope" => "#{main_scope}", - "reset-validation-status" => "#{prefix}_auth_status"} - - hash_for_userid['is-uuid'] = 4 if guid_regex - %input.form-control{hash_for_userid} - %span.help-block{"ng-show" => "angularForm.#{prefix}_userid.$error.required"} - = _("Required") - %span.help-block{"ng-show" => "angularForm.#{prefix}_userid.$error.detectedSpaces"} - = _("Spaces are prohibited") - %span.help-block{"ng-show" => "angularForm.#{prefix}_userid.$error.isUuid"} - = _("Invalid input format, please enter a GUID") - .note{"ng-if" => "emsCommonModel.emstype == 'scvmm' && emsCommonModel.default_security_protocol == 'kerberos'"} - = _("Note: Username must be in the format: name@realm") - .note{"ng-if" => "'#{j_str ng_model}' == 'emsCommonModel' && useridPrivileged()"} - = _("Should have privileged access, such as root or administrator.") - - %div{"ng-show" => "#{ng_show} && #{ng_show_password}"} - .form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_password.$error.required}"} - %label.col-md-2.control-label{"for" => "#{prefix}_password"} - %div{"ng-show" => "vm.bChangeStoredPassword != true"} - = password_label - %div{"ng-show" => "vm.bChangeStoredPassword"} - = new_password_label - .col-md-4 - %input.form-control{"type" => "password", - :autocomplete => "off", - "id" => "#{prefix}_password", - "ng-required" => "#{ng_reqd_password}", - "ng-disabled" => "!vm.showVerify('#{prefix}_userid')" || password_disabled, - "name" => "#{prefix}_password", - "ng-model" => "#{main_scope}.#{ng_model}.#{prefix}_password", - "prefix" => "#{prefix}", - "clear-field-set-focus" => "", - "checkchange" => "", - "main-scope" => "#{main_scope}", - "reset-validation-status" => "#{prefix}_auth_status"} - %span.help-block{"ng-show" => "angularForm.#{prefix}_password.$error.required"} - = _("Required") - %div{"ng-if" => "vm.showChangePasswordLinks('#{prefix}_userid')"} - %a{:href => "", "ng-hide" => "vm.bChangeStoredPassword", "ng-click" => "vm.changeStoredPassword()"} - = change_stored_password - %a{:href => "", "ng-show" => "vm.bChangeStoredPassword", "ng-click" => "vm.cancelPasswordChange()"} - = cancel_password_change - %div{"ng-show" => "#{ng_show}", "ng-if" => "#{validate_button}"} - .form-group - %label.col-md-2 - .col-md-4 - = render :partial => "layouts/angular/form_buttons_verify_angular", - :locals => {:ng_show => "#{ng_show}", - :validate_url => validate_url, - :id => id, - :ng_model => "#{ng_model}", - :main_scope => main_scope, - :valtype => "#{prefix}", - :verify_title_off => verify_title_off, - :basic_info_needed => defined?(basic_info_needed) ? basic_info_needed : nil} diff --git a/app/views/layouts/angular/_auth_service_account_angular.html.haml b/app/views/layouts/angular/_auth_service_account_angular.html.haml deleted file mode 100644 index 41e3dde7ff82..000000000000 --- a/app/views/layouts/angular/_auth_service_account_angular.html.haml +++ /dev/null @@ -1,34 +0,0 @@ -- ng_show ||= true -- validate_url ||= 'log_depot_edit' -- prefix ||= 'log' -- vm_scope ||= false -- main_scope = vm_scope ? "$parent.vm" : "$parent" - -%div{"ng-controller" => "CredentialsController", "vm-scope" => main_scope} - %div{"ng-show" => ng_show} - .form-group{"ng-class" => "{'has-error': angularForm.service_account.$invalid}"} - %label.col-md-2.control-label{"for" => "service_account"} - = _("Service Account JSON") - .col-md-4 - %textarea.form-control{"id" => "service_account", - "name" => "service_account", - "ng-required" => true, - "ng-model" => "#{ng_model}.service_account", - "prefix" => prefix, - "ng-trim" => false, - "reset-validation-status" => "#{prefix}_auth_status"} - %span.help-block{"ng-show" => "angularForm.service_account.$error.required"} - = _("Required") - %span.help-block{"ng-show" => "angularForm.service_account.$error.detectedSpaces"} - = _("Spaces are prohibited") - .form-group - %label.col-md-2 - .col-md-4 - = render :partial => "layouts/angular/form_buttons_verify_angular", - :locals => {:ng_show => ng_show, - :validate_url => validate_url, - :id => id, - :valtype => prefix, - :ng_model => "#{ng_model}", - :main_scope => main_scope, - :basic_info_needed => defined?(basic_info_needed) ? basic_info_needed : nil} diff --git a/app/views/static/auth-credentials.html.haml b/app/views/static/auth-credentials.html.haml deleted file mode 100644 index 1a9f22220315..000000000000 --- a/app/views/static/auth-credentials.html.haml +++ /dev/null @@ -1,79 +0,0 @@ -%ng-form.form-horizontal{:name => 'authCredentialsForm', - "form-changed" => ""} - %div{"ng-show" => "!vm.hideUser"} - .form-group{"ng-class" => "{'has-error' : authCredentialsForm[vm.prefix + '_userid'].$invalid}"} - %label - %label.col-md-2.control-label{"for" => "{{vm.prefix}}_userid"} - {{ vm.userIdLabel }} - .col-md-4 - %input.form-control{"type" => "text", - "ng-attr-name" => "{{vm.prefix}}_userid", - "ng-attr-id" => "{{vm.prefix}}_userid", - "ng-required" => 'vm.userRequired', - "ng-model" => "vm.formModel[vm.prefix + '_userid']", - 'detect_spaces' => '', - "ng-trim" => false, - "reset-validation-status" => "{{vm.prefix}}_auth_status", - "prefix" => '{{vm.prefix}}'} - - %span.help-block{"ng-show" => "authCredentialsForm[vm.prefix + '_userid'].$error.required"} - = _("Required") - %span.help-block{"ng-show" => "authCredentialsForm[vm.prefix + '_userid'].$error.detectedSpaces"} - = _("Spaces are prohibited") - %span.help-block{"ng-show" => "authCredentialsForm[vm.prefix + '_userid'].$error.isUuid"} - = _("Invalid input format, please enter a GUID") - .note{"ng-if" => "vm.guidRegex"} - = _("Note: Username must be in the format: name@realm") - .note{"ng-if" => "vm.userPrivileged"} - = _("Should have privileged access, such as root or administrator.") - %div{"ng-show" => "!vm.hidePassword"} - .form-group{"ng-class" => "{'has-error': authCredentialsForm[vm.prefix + '_password'].$error.required}"} - %label.col-md-2.control-label{"for" => "{{vm.prefix}}_password"} - %div{"ng-show" => "vm.bChangeStoredPassword != true"} - {{ vm.passwordLabel }} - %div{"ng-show" => "vm.bChangeStoredPassword"} - {{ vm.newPasswordLabel }} - .col-md-4 - %input.form-control{"type" => "password", - :autocomplete => "off", - "ng-model" => "vm.formModel[vm.prefix + '_password']", - "ng-disabled" => "!vm.showVerify(vm.prefix + '_userid')", - "ng-attr-name" => "{{vm.prefix}}_password", - "ng-attr-id" => "{{vm.prefix}}_password", - "reset-validation-status" => "{{vm.prefix}}_auth_status", - "prefix" => '{{vm.prefix}}', - "ng-required" => "vm.passwordRequired"} - %span.help-block{"ng-show" => "authCredentialsForm[vm.prefix + '_password'].$error.required"} - = _("Required") - %div{"ng-if" => "vm.showChangePasswordLinks(vm.prefix + '_userid')"} - %a{:href => "", "ng-hide" => "vm.bChangeStoredPassword", "ng-click" => "vm.changeStoredPassword()"} - {{ vm.changeStoredPasswordLabel }} - %a{:href => "", "ng-show" => "vm.bChangeStoredPassword", "ng-click" => "vm.cancelPasswordChange()"} - {{ vm.cancelPasswordChangeLabel }} - %div - .form-group - %label.col-md-2 - .col-md-4 - %miq-button.validate_button{:name => _('Validate'), - 'on-click' => "vm.validate()", - "disabled-title" => '{{vm.buttonLabels.verifyTitleOffLabel}}', - "enabled-title" => '{{vm.buttonLabels.verifyTitleOnLabel}}', - :enabled => "vm.enableValidButton && authCredentialsForm[vm.prefix + '_userid'].$valid && authCredentialsForm[vm.prefix + '_password'].$valid", - :xs => 'true', - :primary => 'true'} - - %div{"ng-if" => "vm.checkAuthentication"} - .form-group{"ng-class" => "{'has-error': !vm.formModel[vm.prefix + '_auth_status']}"} - .col-md-offset-2.col-md-4 - %input.form-control{"type" => "checkbox", - "id" => "{{vm.prefix}}_auth_status", - "name" => "{{vm.prefix}}_auth_status", - "ng-model" => "vm.formModel[vm.prefix + '_auth_status']", - "adjust-error-on-tab" => "vm.formModel[vm.prefix + '_auth_status']", - "validation-status" => "", - "post-validation-model-registry" => "vm.postValidationModelRegistry", - "prefix" => "{{vm.prefix}}", - "ng-show" => false} - - %span.help-block{"ng-if" => "!vm.formModel[vm.prefix + '_auth_status']"} - = _("Validation Required") diff --git a/spec/javascripts/controllers/credentials/credentials_controller_spec.js b/spec/javascripts/controllers/credentials/credentials_controller_spec.js deleted file mode 100644 index e80ac02c23bc..000000000000 --- a/spec/javascripts/controllers/credentials/credentials_controller_spec.js +++ /dev/null @@ -1,118 +0,0 @@ -describe('CredentialsController', function() { - var $scope, vm, $httpBackend; - - beforeEach(module('ManageIQ')); - - beforeEach(inject(function(_$httpBackend_, $rootScope, _$controller_) { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $scope.model = "hostModel"; - vm = _$controller_('CredentialsController', - {$http: $httpBackend, - $scope: $scope, - $attrs: {'vmScope': '$parent'}}); - })); - - afterEach(function() { - $httpBackend.verifyNoOutstandingExpectation(); - $httpBackend.verifyNoOutstandingRequest(); - }); - - describe('when formId is new', function() { - beforeEach(inject(function(_$httpBackend_, $rootScope, _$controller_) { - $scope.$parent.formId = 'new'; - vm = _$controller_('CredentialsController', - {$http: $httpBackend, - $scope: $scope, - $attrs: {'vmScope': '$parent'}}); - })); - it('initializes stored password state flags for new records', function() { - expect(vm.newRecord).toBeTruthy(); - expect(vm.bChangeStoredPassword).toBeUndefined(); - expect(vm.bCancelPasswordChange).toBeUndefined(); - }); - }); - - describe('when formId is not new', function() { - beforeEach(inject(function(_$httpBackend_, $rootScope, _$controller_) { - $scope.$parent.formId = '12345'; - vm = _$controller_('CredentialsController', - {$http: $httpBackend, $scope: $scope, $attrs: {'vmScope': '$parent'}}); - })); - it('initializes stored password state flags for existing records', function() { - expect(vm.newRecord).toBeFalsy(); - expect(vm.bChangeStoredPassword).toBeFalsy(); - expect(vm.bCancelPasswordChange).toBeFalsy(); - }); - }); - - it('sets proper values when Change Stored Password is clicked', function() { - vm.changeStoredPassword(); - expect(vm.bChangeStoredPassword).toBeTruthy(); - expect(vm.bCancelPasswordChange).toBeFalsy(); - }); - - it('sets proper values when Cancel Password change is clicked', function() { - vm.changeStoredPassword(); - vm.cancelPasswordChange(); - expect(vm.bChangeStoredPassword).toBeFalsy(); - expect(vm.bCancelPasswordChange).toBeTruthy(); - }); - - it('shows Verify Password field when record is new', function() { - vm.newRecord = true; - $scope.$parent.hostModel = {'default_userid': '', 'default_password': ''}; - $scope.$parent.modelCopy = angular.copy( $scope.$parent.hostModel ); - expect(vm.showVerify('default_userid')).toBeTruthy(); - }); - - it('shows Verify Password field only after Change Stored Password is clicked', function() { - $scope.$parent.hostModel = {'default_userid': 'abc', 'default_password': '********'}; - $scope.$parent.modelCopy = angular.copy( $scope.$parent.hostModel ); - expect(vm.showVerify('default_userid')).toBeFalsy(); - vm.changeStoredPassword(); - expect(vm.showVerify('default_userid')).toBeTruthy(); - }); - - it('shows Verify Password field when record is not new, userid does not exist', function() { - vm.newRecord = false; - $scope.$parent.hostModel = {'default_userid': '', 'default_password': ''}; - $scope.$parent.modelCopy = angular.copy( $scope.$parent.hostModel ); - expect(vm.showVerify('default_userid')).toBeTruthy(); - }); - - it('shows password change links when record is not new and userid exists', function() { - vm.newRecord = false; - $scope.$parent.hostModel = {'default_userid': 'abc', 'default_password': '********'}; - $scope.$parent.modelCopy = angular.copy( $scope.$parent.hostModel ); - expect(vm.showChangePasswordLinks('default_userid')).toBeTruthy(); - }); - - it('does not show password change links when record is not new and userid does not exist', function() { - vm.newRecord = false; - $scope.$parent.hostModel = {'default_userid': '', 'default_password': ''}; - $scope.$parent.modelCopy = angular.copy( $scope.$parent.hostModel ); - expect(vm.showChangePasswordLinks('default_userid')).toBeFalsy(); - }); - - it('does not show password change links when record is not new, userid did not exist before but is now filled in by the user', function() { - vm.newRecord = false; - $scope.$parent.hostModel = {'default_userid': '', 'default_password': ''}; - $scope.$parent.modelCopy = angular.copy( $scope.$parent.hostModel ); - $scope.$parent.hostModel.default_userid = 'xyz'; - expect(vm.showChangePasswordLinks('default_userid')).toBeFalsy(); - }); - - it('restores the flag values to original state when reset is clicked after Change stored password link was clicked', function() { - vm.changeStoredPassword(); - vm.resetClicked(); - expect(vm.bCancelPasswordChange).toBeTruthy(); - expect(vm.bChangeStoredPassword).toBeFalsy(); - }); - - it('restores the flag values to original state when reset is clicked before Change stored password link was clicked', function() { - vm.resetClicked(); - expect(vm.bCancelPasswordChange).toBeFalsy(); - expect(vm.bChangeStoredPassword).toBeFalsy(); - }); -}); diff --git a/spec/javascripts/directives/clear_field_set_focus_spec.js b/spec/javascripts/directives/clear_field_set_focus_spec.js deleted file mode 100644 index 9f9ead87b80d..000000000000 --- a/spec/javascripts/directives/clear_field_set_focus_spec.js +++ /dev/null @@ -1,43 +0,0 @@ -describe('clearFieldSetFocus initialization', function() { - var $scope, form, ctrl, hostScope, credScope; - beforeEach(module('ManageIQ')); - beforeEach(inject(function($compile, $rootScope, _miqService_, _$controller_) { - hostScope = $rootScope.$new(); - credScope = hostScope.$new(); - $scope = credScope.$new(); - miqService = _miqService_; - - $scope.$parent.formId = '12345'; - ctrl = _$controller_('CredentialsController', - {$scope: credScope, $attrs: {'vmScope': '$parent'}}); - - var element = angular.element( - '
' + - '' + - '' + - '' - ); - elem = $compile(element)(credScope); - form = $scope.angularForm; - $scope.$parent.model = "hostModel"; - $scope.$parent.hostModel = {'password': ''}; - $scope.$parent.hostModel.password = miqService.storedPasswordPlaceholder; - $scope.$parent.vm = ctrl; - })); - - describe('clear-field-set-focus specs', function() { - it('sets focus on the password field and clears out the placeholder', inject(function($timeout) { - spyOn(elem[0][0], 'focus'); - ctrl.changeStoredPassword(); - $timeout.flush(); - expect($scope.$parent.hostModel.password).toBe(''); - expect((elem[0][0]).focus).toHaveBeenCalled(); - })); - - it('puts back the placeholder when cancel password change is selected', inject(function($timeout) { - ctrl.bCancelPasswordChange = true; - $timeout.flush(); - expect($scope.$parent.hostModel.password).toBe(miqService.storedPasswordPlaceholder); - })); - }); -});