]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: telemetry activate: show ident fields when checked
authorAaryan Porwal <aaryanporwal2233@gmail.com>
Sun, 6 Jun 2021 22:08:37 +0000 (03:38 +0530)
committerLaura Flores <lflores@redhat.com>
Tue, 22 Feb 2022 22:59:53 +0000 (22:59 +0000)
Signed-off-by: Aaryan Porwal <aaryanporwal2233@gmail.com>
(cherry picked from commit ad5b3f200529fc0bc511ce99eed338afcaef6a62)

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/telemetry/telemetry.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/telemetry/telemetry.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/telemetry/telemetry.component.ts

index 2a12f9d9a66af73660add55098a3ecb706778b40..1640ad94ed5fb25b38f85cf8c0199fa2fda268b8 100644 (file)
                   <input type="checkbox"
                          class="custom-control-input"
                          id="channel_ident"
-                         formControlName="channel_ident">
+                         formControlName="channel_ident"
+                         (click)="toggleIdent()">
                   <label class="custom-control-label"
                          for="channel_ident"></label>
                 </div>
               </div>
             </div>
+            <ng-container *ngIf="showContactInfo">
             <legend>
               <ng-container i18n>Contact Information</ng-container>
               <cd-helper i18n>Submitting any contact information is completely optional and disabled by default.</cd-helper>
                        i18n-placeholder>
               </div>
             </div>
+          </ng-container>
             <legend i18n>Advanced Settings</legend>
             <div class="form-group row">
               <label class="cd-col-form-label"
index ab4c0afdc1e59bc79e6294a14e45bb415920cf33..64cf6561a4c39513e396bda79711113dfd63b5e9 100644 (file)
@@ -80,6 +80,29 @@ describe('TelemetryComponent', () => {
       expect(component).toBeTruthy();
     });
 
+    it('should show/hide ident fields on checking/unchecking', () => {
+      const getContactField = () =>
+        fixture.debugElement.nativeElement.querySelector('input[id=contact]');
+      const getDescriptionField = () =>
+        fixture.debugElement.nativeElement.querySelector('input[id=description]');
+
+      // Initially hidden.
+      expect(getContactField()).toBeFalsy();
+      expect(getDescriptionField()).toBeFalsy();
+
+      // Show fields.
+      component.toggleIdent();
+      fixture.detectChanges();
+      expect(getContactField()).toBeTruthy();
+      expect(getDescriptionField()).toBeTruthy();
+
+      // Hide fields.
+      component.toggleIdent();
+      fixture.detectChanges();
+      expect(getContactField()).toBeFalsy();
+      expect(getDescriptionField()).toBeFalsy();
+    });
+
     it('should set module enability to true correctly', () => {
       expect(component.moduleEnabled).toBeTruthy();
     });
index e8d700a50950338aa139ba2342a4c6c7c46c227e..5661908a65531769d177bea8a3f8e663394021f9 100644 (file)
@@ -49,6 +49,7 @@ export class TelemetryComponent implements OnInit {
   sendToUrl = '';
   sendToDeviceUrl = '';
   step = 1;
+  showContactInfo = false;
 
   constructor(
     private formBuilder: CdFormBuilder,
@@ -161,6 +162,10 @@ export class TelemetryComponent implements OnInit {
     );
   }
 
+  toggleIdent() {
+    this.showContactInfo = !this.showContactInfo;
+  }
+
   updateConfig() {
     this.updatedConfig = {};
     for (const option of Object.values(this.options)) {