]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: ingress service creation follow-up 41161/head
authorAvan Thakkar <athakkar@redhat.com>
Tue, 4 May 2021 22:01:10 +0000 (03:31 +0530)
committerAvan Thakkar <athakkar@localhost.localdomain>
Wed, 12 May 2021 10:28:04 +0000 (15:58 +0530)
Fixes: https://tracker.ceph.com/issues/50568
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
Pre-populating the service id(read-only) with the value same as backend service.

src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/services.po.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts

index 18b17c2f23ea4b30ca90186aeb563deae308d1c1..92bb1c392a736244cde2587af6f8faf9d17a869f 100644 (file)
@@ -35,7 +35,7 @@ export class ServicesPageHelper extends PageHelper {
         cy.get('#count').type('1');
       } else if (serviceType === 'ingress') {
         this.selectOption('backend_service', 'rgw.rgw.foo');
-        cy.get('#service_id').type('rgw.rgw.foo');
+        cy.get('#service_id').should('have.value', 'rgw.rgw.foo');
         cy.get('#virtual_ip').type('192.168.20.1/24');
         cy.get('#frontend_port').type('8081');
         cy.get('#monitor_port').type('8082');
index a0df3a5d4b0a752b2233523ca87ebeabdd62d249..aed6da3f964d4a45a60763f6bb8e0e5a3e4a9f0f 100644 (file)
@@ -41,7 +41,8 @@
               <select id="backend_service"
                       name="backend_service"
                       class="form-control custom-select"
-                      formControlName="backend_service">
+                      formControlName="backend_service"
+                      (change)="prePopulateId()">
                 <option *ngIf="services === null"
                         [ngValue]="null"
                         i18n>Loading...</option>
index 5b7fc6cac43b0e3ae3224604d1b60c003ec199be..e9e64b71cfe66ae91924506518db61e85fe895d4 100644 (file)
@@ -335,7 +335,6 @@ describe('ServiceFormComponent', () => {
     describe('should test service ingress', () => {
       beforeEach(() => {
         formHelper.setValue('service_type', 'ingress');
-        formHelper.setValue('service_id', 'rgw.foo');
         formHelper.setValue('backend_service', 'rgw.foo');
         formHelper.setValue('virtual_ip', '192.168.20.1/24');
         formHelper.setValue('ssl', false);
@@ -355,6 +354,12 @@ describe('ServiceFormComponent', () => {
         });
       });
 
+      it('should pre-populate the service id', () => {
+        component.prePopulateId();
+        const prePopulatedID = component.serviceForm.getValue('service_id');
+        expect(prePopulatedID).toBe('rgw.foo');
+      });
+
       it('should submit valid frontend and monitor port', () => {
         // min value
         formHelper.setValue('frontend_port', 1);
index aee978849a7b6eb2d91fd2c70c91c29c83410573..c51e1c6ac3f0b6e6d01e6b43c94450869bda2d41 100644 (file)
@@ -281,6 +281,13 @@ export class ServiceFormComponent extends CdForm implements OnInit {
     reader.readAsText(file, 'utf8');
   }
 
+  prePopulateId() {
+    const control: AbstractControl = this.serviceForm.get('service_id');
+    const backendService = this.serviceForm.getValue('backend_service');
+    // Set Id as read-only
+    control.reset({ value: backendService, disabled: true });
+  }
+
   onSubmit() {
     const self = this;
     const values: object = this.serviceForm.value;
@@ -345,6 +352,7 @@ export class ServiceFormComponent extends CdForm implements OnInit {
           break;
         case 'ingress':
           serviceSpec['backend_service'] = values['backend_service'];
+          serviceSpec['service_id'] = values['backend_service'];
           if (_.isString(values['virtual_ip']) && !_.isEmpty(values['virtual_ip'])) {
             serviceSpec['virtual_ip'] = values['virtual_ip'].trim();
           }