From ed39b8d93df084900fa54229b18a24726a497045 Mon Sep 17 00:00:00 2001 From: Gilbert Cherrie Date: Tue, 15 Oct 2024 15:03:51 -0400 Subject: [PATCH] Remove unused namespace angular code --- app/javascript/oldjs/components/index.js | 1 - .../components/miq_ae_class/namespace-form.js | 82 ------------------- .../miq_ae_class/namespace_form.html.haml | 45 ---------- .../miq_ae_class/namespace_form_spec.js | 81 ------------------ 4 files changed, 209 deletions(-) delete mode 100644 app/javascript/oldjs/components/miq_ae_class/namespace-form.js delete mode 100644 app/views/static/miq_ae_class/namespace_form.html.haml delete mode 100644 spec/javascripts/components/miq_ae_class/namespace_form_spec.js diff --git a/app/javascript/oldjs/components/index.js b/app/javascript/oldjs/components/index.js index 7cf57e50e71..c5b2481b129 100644 --- a/app/javascript/oldjs/components/index.js +++ b/app/javascript/oldjs/components/index.js @@ -1,7 +1,6 @@ require('./ae_resolve_options/ae-resolve-options.js'); require('./index.js'); require('./miq-button.js'); -require('./miq_ae_class/namespace-form.js'); require('./provider-option-field-input.js'); require('./provier-option-section.js'); require('./sanitize.js'); diff --git a/app/javascript/oldjs/components/miq_ae_class/namespace-form.js b/app/javascript/oldjs/components/miq_ae_class/namespace-form.js deleted file mode 100644 index d5028ac1edc..00000000000 --- a/app/javascript/oldjs/components/miq_ae_class/namespace-form.js +++ /dev/null @@ -1,82 +0,0 @@ -ManageIQ.angular.app.component('namespaceForm', { - bindings: { - 'aeNsDomain': '<', - 'namespacePath': '@', - 'namespaceId': '@', - 'nameReadonly': '<', - 'descriptionReadonly': '<', - }, - controllerAs: 'vm', - controller: ['$scope', '$http', 'miqService', '$window', function($scope, $http, miqService, $window) { - $scope.__ = __; - $scope.controllerName = 'vm'; - - var vm = this; - - this.$onInit = function() { - vm.saveable = miqService.saveable; - vm.newRecord = vm.namespaceId === 'new'; - - vm.model = 'namespaceModel'; - vm.namespaceModel = { - name: '', - description: '', - }; - - if (vm.aeNsDomain) { - vm.namespaceModel.enabled = true; - } - - vm.afterGet = false; - if (vm.namespaceId === 'new') { - vm.afterGet = true; - miqService.sparkleOff(); - vm.modelCopy = angular.copy( vm.namespaceModel ); - } else { - $http.get('/miq_ae_class/namespace/' + vm.namespaceId) - .then(getNamespace) - .catch(miqService.handleFailure); - } - }; - - var getNamespace = function(response) { - Object.assign(vm.namespaceModel, response.data); - vm.modelCopy = angular.copy( vm.namespaceModel ); - vm.afterGet = true; - miqService.sparkleOff(); - }; - - vm.cancelClicked = function() { - miqService.sparkleOn(); - var message = ''; - if (vm.newRecord) { - message = vm.aeNsDomain ? __('Add of Domain was cancelled by user.') : __('Add of Namespace was cancelled by user.'); - } else { - message = vm.aeNsDomain ? __('Edit of Domain "%s" was cancelled by user.') : __('Edit of Namespace "%s" was cancelled by user.'); - message = sprintf(message, vm.namespaceModel.name); - } - miqFlashLater({ - message: message, - level: 'warning', - }); - $window.location.href = '/miq_ae_class/explorer'; - }; - - vm.resetClicked = function(angularForm) { - vm.namespaceModel = angular.copy( vm.modelCopy ); - angularForm.$setPristine(true); - miqService.miqFlash('warn', __('All changes have been reset')); - }; - - vm.saveClicked = function() { - var url = '/miq_ae_class/update_namespace/' + vm.namespaceId + '?button=save'; - miqService.miqAjaxButton(url, vm.namespaceModel, { complete: false }); - }; - - vm.addClicked = function() { - var url = '/miq_ae_class/create_namespace/new?button=add'; - miqService.miqAjaxButton(url, vm.namespaceModel, { complete: false }); - }; - }], - templateUrl: '/static/miq_ae_class/namespace_form.html.haml', -}); diff --git a/app/views/static/miq_ae_class/namespace_form.html.haml b/app/views/static/miq_ae_class/namespace_form.html.haml deleted file mode 100644 index 384874ca78b..00000000000 --- a/app/views/static/miq_ae_class/namespace_form.html.haml +++ /dev/null @@ -1,45 +0,0 @@ -%form#form_ns_div{'ng-show' => "vm.afterGet", - 'ng-cloak' => '', - :name => "angularForm", - "miq-form" => true, - 'form-changed' => true, - "model" => "vm.namespaceModel", - "model-copy" => 'vm.modelCopy',} - %h3 - = _('Info') - .form-horizontal - .form-group{'ng-if' => '!vm.aeNsDomain'} - %label.col-md-2.control-label - = _('Fully Qualified Name') - .col-md-8 - = h('{{vm.namespacePath}}') - .form-group - %label.col-md-2.control-label - = _('Name') - .col-md-8 - %input.form-control{:id => 'ns_name', - :name => 'ns_name', - :maxlength => 255, - :type => 'text', - 'ng-model' => 'vm.namespaceModel.name', - :autofocus => true, - 'ng-readonly' => 'vm.nameReadonly'} - .form-group - %label.col-md-2.control-label - = _('Description') - .col-md-8 - %input.form-control{:id => 'ns_description', - :name => 'ns_description', - :maxlength => 255, - :type => 'text', - 'ng-model' => 'vm.namespaceModel.description', - 'ng-readonly' => 'vm.descriptionReadonly'} - .form-group{'ng-if' => 'vm.aeNsDomain'} - %label.col-md-2.control-label - = _('Enabled') - .col-md-8 - %input{:id => 'ns_enabled', - :name => 'ns_enabled', - :type => 'checkbox', - 'ng-model' => 'vm.namespaceModel.enabled'} - = render :partial => 'layouts/angular/generic_form_buttons' diff --git a/spec/javascripts/components/miq_ae_class/namespace_form_spec.js b/spec/javascripts/components/miq_ae_class/namespace_form_spec.js deleted file mode 100644 index 21301b055bf..00000000000 --- a/spec/javascripts/components/miq_ae_class/namespace_form_spec.js +++ /dev/null @@ -1,81 +0,0 @@ -describe('namespace-form', function() { - var $componentController, miqService, vm; - - describe('when vm.namespaceId is new', function () { - beforeEach(module('ManageIQ')); - beforeEach(inject(function (_$componentController_, _miqService_) { - $componentController = _$componentController_; - miqService = _miqService_; - - spyOn(miqService, 'miqAjaxButton'); - - var bindings = {aeNsDomain: false, - namespacePath: 'parent/', - namespaceId: "new", - nameReadonly: false, - descriptionReadonly: false}; - vm = $componentController('namespaceForm', null, bindings); - vm.$onInit(); - })); - - it('sets newRecord to true', function () { - expect(vm.newRecord).toBe(true); - }); - - it('adds a Namespace record', function () { - vm.namespaceModel.name = "name"; - vm.namespaceModel.description = "description"; - vm.addClicked(); - expect(miqService.miqAjaxButton).toHaveBeenCalledWith('/miq_ae_class/create_namespace/new?button=add', vm.namespaceModel, { complete: false }); - }); - }); - describe('when namespace exists', function () { - beforeEach(module('ManageIQ')); - beforeEach(inject(function (_$componentController_, _miqService_, _$httpBackend_) { - $componentController = _$componentController_; - miqService = _miqService_; - var $httpBackend = _$httpBackend_; - $httpBackend.whenGET('/miq_ae_class/namespace/123').respond({name: "Name", description: "Description"}); - - spyOn(miqService, 'miqAjaxButton'); - spyOn(miqService, 'miqFlash'); - - var bindings = {aeNsDomain: false, - namespacePath: 'parent/', - namespaceId: "123", - nameReadonly: false, - descriptionReadonly: false}; - vm = $componentController('namespaceForm', null, bindings); - vm.$onInit(); - $httpBackend.flush(); - })); - - it('sets newRecord to true', function () { - expect(vm.newRecord).toBe(false); - }); - - it('sets namespaceModel correctly', function () { - expect(vm.namespaceModel).toEqual({name: "Name", description: "Description"}); - }); - - it('updates a Namespace record', function () { - vm.namespaceModel.name = 'Changed name'; - vm.namespaceModel.name = 'Changed description'; - vm.saveClicked(); - expect(miqService.miqAjaxButton).toHaveBeenCalledWith('/miq_ae_class/update_namespace/123?button=save', vm.namespaceModel, { complete: false }); - }); - - it('#reset resets form correctly', function () { - var angularForm = { - $setPristine: function(value) {}, - $setUntouched: function(value) {}, - }; - - vm.namespaceModel.name = 'Changed name'; - vm.namespaceModel.name = 'Changed description'; - vm.resetClicked(angularForm); - expect(miqService.miqFlash).toHaveBeenCalledWith('warn', 'All changes have been reset'); - expect(vm.namespaceModel).toEqual({name: "Name", description: "Description"}); - }); - }); -});