From af1a7dbfe2b0e2e40650d64d4c3247f4961743c2 Mon Sep 17 00:00:00 2001 From: Sebastian Krah Date: Fri, 2 Oct 2020 11:07:40 +0200 Subject: [PATCH] mgr/dashboard: Show warning when replicated size is 1 Issues a warning when creating a replicated pool and the replicated size is 1. It won't stop the user from creating the pool, but will give the user a hint that no replication will be created. Fixes: https://tracker.ceph.com/issues/42404 Signed-off-by: Sebastian Krah --- .../app/ceph/pool/pool-form/pool-form.component.html | 4 ++++ .../ceph/pool/pool-form/pool-form.component.spec.ts | 11 +++++++++++ .../src/styles/defaults/_bootstrap-defaults.scss | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html index 397c1829c9d..bb1e0f9679a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html @@ -143,6 +143,10 @@ *ngIf="form.showError('size', formDir)" i18n>The size specified is out of range. A value from {{ getMinSize() }} to {{ getMaxSize() }} is usable. + A size of 1 will not create a replication of the + object. The 'Replicated size' includes the object itself. diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts index cfb42ecd9b8..6e72d76dfd2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts @@ -319,6 +319,17 @@ describe('PoolFormComponent', () => { formHelper.expectValidChange('size', 2); }); + it('validates if warning is displayed when size is 1', () => { + formHelper.setValue('poolType', 'replicated'); + formHelper.expectValid('size'); + + formHelper.setValue('size', 1, true); + expect(fixtureHelper.getElementByCss('#size ~ .text-warning-dark')).toBeTruthy(); + + formHelper.setValue('size', 2, true); + expect(fixtureHelper.getElementByCss('#size ~ .text-warning-dark')).toBeFalsy(); + }); + it('validates compression mode default value', () => { expect(form.getValue('mode')).toBe('none'); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/styles/defaults/_bootstrap-defaults.scss b/src/pybind/mgr/dashboard/frontend/src/styles/defaults/_bootstrap-defaults.scss index 42adf5f02e9..52cc443b982 100644 --- a/src/pybind/mgr/dashboard/frontend/src/styles/defaults/_bootstrap-defaults.scss +++ b/src/pybind/mgr/dashboard/frontend/src/styles/defaults/_bootstrap-defaults.scss @@ -38,7 +38,8 @@ $fg-color-over-dark-bg: $white; $fg-hover-color-over-dark-bg: $gray-500; $theme-colors: ( - 'accent': #ef5c55 + 'accent': #ef5c55, + 'warning-dark': $orange ); // Body -- 2.39.5