]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add enabled property to SelectOption
authorTiago Melo <tmelo@suse.com>
Mon, 15 Apr 2019 14:48:35 +0000 (14:48 +0000)
committerRicardo Marques <rimarques@suse.com>
Wed, 24 Apr 2019 16:01:47 +0000 (17:01 +0100)
Signed-off-by: Tiago Melo <tmelo@suse.com>
(cherry picked from commit 45e18a9c13ae3332d5dbd7e025b477606ba48a92)

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts
src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select-option.model.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select.component.spec.ts

index 8d95a4808f6def97bdbc368d3dc65020334529f5..e3134c215f790dc1f11e035e75e4e623ecd6a8f2 100644 (file)
@@ -165,15 +165,15 @@ describe('IscsiTargetFormComponent', () => {
   it('should only show images not used in other targets', () => {
     expect(component.imagesAll).toEqual([RBD_LIST[1]['value'][1]]);
     expect(component.imagesSelections).toEqual([
-      { description: '', name: 'rbd/disk_2', selected: false }
+      { description: '', name: 'rbd/disk_2', selected: false, enabled: true }
     ]);
   });
 
   it('should generate portals selectOptions', () => {
     expect(component.portalsSelections).toEqual([
-      { description: '', name: 'node1:192.168.100.201', selected: false },
-      { description: '', name: 'node1:10.0.2.15', selected: false },
-      { description: '', name: 'node2:192.168.100.202', selected: false }
+      { description: '', name: 'node1:192.168.100.201', selected: false, enabled: true },
+      { description: '', name: 'node1:10.0.2.15', selected: false, enabled: true },
+      { description: '', name: 'node2:192.168.100.202', selected: false, enabled: true }
     ]);
   });
 
@@ -247,16 +247,16 @@ describe('IscsiTargetFormComponent', () => {
         luns: []
       });
       expect(component.imagesInitiatorSelections).toEqual([
-        [{ description: '', name: 'rbd/disk_2', selected: false }]
+        [{ description: '', name: 'rbd/disk_2', selected: false, enabled: true }]
       ]);
       expect(component.groupMembersSelections).toEqual([
-        [{ description: '', name: 'iqn.initiator', selected: false }]
+        [{ description: '', name: 'iqn.initiator', selected: false, enabled: true }]
       ]);
     });
 
     it('should update data when changing an initiator name', () => {
       expect(component.groupMembersSelections).toEqual([
-        [{ description: '', name: 'iqn.initiator', selected: false }]
+        [{ description: '', name: 'iqn.initiator', selected: false, enabled: true }]
       ]);
 
       component.initiators.controls[0].patchValue({
@@ -265,7 +265,7 @@ describe('IscsiTargetFormComponent', () => {
       component.updatedInitiatorSelector();
 
       expect(component.groupMembersSelections).toEqual([
-        [{ description: '', name: 'iqn.initiator_new', selected: false }]
+        [{ description: '', name: 'iqn.initiator_new', selected: false, enabled: true }]
       ]);
     });
 
index 1ebd776a05e17b59d901720394fc9a1c642756cd..ec3a11e906d3a4adbf716d1e06e06636d6b259f3 100644 (file)
@@ -115,8 +115,8 @@ describe('NfsFormComponent', () => {
     component.onClusterChange();
 
     expect(component.daemonsSelections).toEqual([
-      { description: '', name: 'node1', selected: false },
-      { description: '', name: 'node2', selected: false }
+      { description: '', name: 'node1', selected: false, enabled: true },
+      { description: '', name: 'node2', selected: false, enabled: true }
     ]);
   });
 
index 3bc8f23892cc5f58236b41f8a1f73a8a009f785a..ea32b634b3ec288465c88a6ea659cea8690bfa1e 100644 (file)
@@ -5,6 +5,7 @@ export class UserFormRoleModel implements SelectOption {
   description: string;
   selected = false;
   scopes_permissions: object;
+  enabled = true;
 
   constructor(name, description) {
     this.name = name;
index 24e9b2b72d36a86090e1b5d4f8c4b31cdb510aee..77a8e75c56dd189b5c86429f15c0f0d1b53f975f 100644 (file)
@@ -93,7 +93,10 @@ export class UserFormComponent implements OnInit {
     }
 
     this.roleService.list().subscribe((roles: Array<UserFormRoleModel>) => {
-      this.allRoles = roles;
+      this.allRoles = _.map(roles, (role) => {
+        role.enabled = true;
+        return role;
+      });
     });
     if (this.mode === this.userFormMode.editing) {
       this.initEdit();
index 67221be4fe6e6409af93f2e08fead84526b7f6c4..bd4cc25058adb2eea63f97659e5de77d28cb272d 100644 (file)
@@ -33,8 +33,8 @@ describe('SelectBadgesComponent', () => {
   it('should reflect the attributes into CdSelect', () => {
     const data = ['a', 'b'];
     const options = [
-      { name: 'option1', description: '', selected: false },
-      { name: 'option2', description: '', selected: false }
+      { name: 'option1', description: '', selected: false, enabled: true },
+      { name: 'option2', description: '', selected: false, enabled: true }
     ];
     const i18n = TestBed.get(I18n);
     const messages = new SelectMessages({ empty: 'foo bar' }, i18n);
index 5d095b58980652069f2bc7c8259d8b556220ddcb..bbd970c6fc25f35db279583c46d22419dc6d4bb4 100644 (file)
@@ -2,10 +2,12 @@ export class SelectOption {
   selected: boolean;
   name: string;
   description: string;
+  enabled: boolean;
 
-  constructor(selected: boolean, name: string, description: string) {
+  constructor(selected: boolean, name: string, description: string, enabled = true) {
     this.selected = selected;
     this.name = name;
     this.description = description;
+    this.enabled = enabled;
   }
 }
index ee63842c1fd295a16f87b96bb7629b5decd67b74..72682dbd342ade8155e56e98ed37fd33ff65648b 100644 (file)
@@ -20,7 +20,7 @@
   </form>
   <div *ngFor="let option of filteredOptions"
        class="select-menu-item"
-       [class.disabled]="data.length === selectionLimit && !option.selected"
+       [ngClass]="{'help-block disabled': (data.length === selectionLimit || !option.enabled) && !option.selected}"
        (click)="triggerSelection(option)">
     <div class="select-menu-item-icon">
       <i class="fa fa-check"
index bebba6d96546127953d442628247d3418e60ce8c..45e8267375166f71636bca3e8af787563501cf07 100644 (file)
@@ -29,9 +29,9 @@ describe('SelectComponent', () => {
     component = fixture.componentInstance;
     fixture.detectChanges();
     component.options = [
-      { name: 'option1', description: '', selected: false },
-      { name: 'option2', description: '', selected: false },
-      { name: 'option3', description: '', selected: false }
+      { name: 'option1', description: '', selected: false, enabled: true },
+      { name: 'option2', description: '', selected: false, enabled: true },
+      { name: 'option3', description: '', selected: false, enabled: true }
     ];
   });
 
@@ -214,7 +214,8 @@ describe('SelectComponent', () => {
       expect(component.options[0]).toEqual({
         name: 'customOption',
         description: '',
-        selected: true
+        selected: true,
+        enabled: true
       });
       expect(component.options.length).toBe(4);
       expect(component.data).toEqual(['customOption']);
@@ -235,7 +236,8 @@ describe('SelectComponent', () => {
       expect(component.options[0]).toEqual({
         name: 'customOption',
         description: '',
-        selected: false
+        selected: false,
+        enabled: true
       });
     });