From 4ef0e2c1ba2c7c2b12556f5ee7a593ae4ba99144 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alfonso=20Mart=C3=ADnez?= Date: Wed, 22 Jan 2020 16:05:12 +0100 Subject: [PATCH] mgr/dashboard: disable 'Add Capability' button when all the capabilities are added MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes: https://tracker.ceph.com/issues/43564 Signed-off-by: Alfonso Martínez --- .../ceph/rgw/models/rgw-user-capabilities.ts | 15 +++++++++ .../rgw-user-capability-modal.component.ts | 3 +- .../rgw-user-form.component.html | 5 +++ .../rgw-user-form.component.spec.ts | 33 ++++++++++++++++++- .../rgw-user-form/rgw-user-form.component.ts | 5 +++ 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/models/rgw-user-capabilities.ts diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/models/rgw-user-capabilities.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/models/rgw-user-capabilities.ts new file mode 100644 index 00000000000..dac6986c761 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/models/rgw-user-capabilities.ts @@ -0,0 +1,15 @@ +export enum RgwUserAvailableCapability { + USERS = 'users', + BUCKETS = 'buckets', + METADATA = 'metadata', + USAGE = 'usage', + ZONE = 'zone' +} + +export class RgwUserCapabilities { + static readonly capabilities = RgwUserAvailableCapability; + + static getAll(): string[] { + return Object.values(RgwUserCapabilities.capabilities); + } +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts index f6d9d30ad52..d890aa902ee 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts @@ -8,6 +8,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'; import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { CdFormBuilder } from '../../../shared/forms/cd-form-builder'; import { CdFormGroup } from '../../../shared/forms/cd-form-group'; +import { RgwUserCapabilities } from '../models/rgw-user-capabilities'; import { RgwUserCapability } from '../models/rgw-user-capability'; @Component({ @@ -78,7 +79,7 @@ export class RgwUserCapabilityModalComponent { usedTypes.push(capability.type); }); this.types = []; - ['users', 'buckets', 'metadata', 'usage', 'zone'].forEach((type) => { + RgwUserCapabilities.getAll().forEach((type) => { if (_.indexOf(usedTypes, type) === -1) { this.types.push(type); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html index f676c677dbd..e6e08703108 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html @@ -414,6 +414,11 @@