From: Tiago Melo Date: Mon, 15 Apr 2019 14:48:35 +0000 (+0000) Subject: mgr/dashboard: Add enabled property to SelectOption X-Git-Tag: v14.2.2~155^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d76fad6859154a8460ed6d1f198823d645cb697b;p=ceph.git mgr/dashboard: Add enabled property to SelectOption Signed-off-by: Tiago Melo (cherry picked from commit 45e18a9c13ae3332d5dbd7e025b477606ba48a92) --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts index 8d95a4808f6d..e3134c215f79 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts @@ -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 }] ]); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts index 1ebd776a05e1..ec3a11e906d3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts @@ -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 } ]); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts index 3bc8f23892cc..ea32b634b3ec 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form-role.model.ts @@ -5,6 +5,7 @@ export class UserFormRoleModel implements SelectOption { description: string; selected = false; scopes_permissions: object; + enabled = true; constructor(name, description) { this.name = name; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.ts index 24e9b2b72d36..77a8e75c56dd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.ts @@ -93,7 +93,10 @@ export class UserFormComponent implements OnInit { } this.roleService.list().subscribe((roles: Array) => { - this.allRoles = roles; + this.allRoles = _.map(roles, (role) => { + role.enabled = true; + return role; + }); }); if (this.mode === this.userFormMode.editing) { this.initEdit(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.spec.ts index 67221be4fe6e..bd4cc25058ad 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select-badges/select-badges.component.spec.ts @@ -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); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select-option.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select-option.model.ts index 5d095b589806..bbd970c6fc25 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select-option.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select-option.model.ts @@ -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; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select.component.html index ee63842c1fd2..72682dbd342a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/select/select.component.html @@ -20,7 +20,7 @@
{ 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 }); });