From 851698213b1797a0e678f770489c718037b3f830 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 (cherry picked from commit af1a7dbfe2b0e2e40650d64d4c3247f4961743c2) Conflicts: src/pybind/mgr/dashboard/frontend/src/styles/defaults/_bootstrap-defaults.scss - The file does not exist in octopus, moving a slightly changed version of the diff to src/pybind/mgr/dashboard/frontend/src/styles.scss instead --- .../app/ceph/pool/pool-form/pool-form.component.html | 4 ++++ .../ceph/pool/pool-form/pool-form.component.spec.ts | 11 +++++++++++ src/pybind/mgr/dashboard/frontend/src/styles.scss | 4 +++- 3 files changed, 18 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 398a535bf8c6..0f988ded1342 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 @@ -146,6 +146,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 a44571b78281..4d570f102df4 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 @@ -310,6 +310,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.scss b/src/pybind/mgr/dashboard/frontend/src/styles.scss index 096533658708..212d10c92f17 100644 --- a/src/pybind/mgr/dashboard/frontend/src/styles.scss +++ b/src/pybind/mgr/dashboard/frontend/src/styles.scss @@ -9,10 +9,12 @@ $fa-font-path: '~fork-awesome/fonts'; $font-family-icon: 'ForkAwesome'; // Bootstrap +$warning-dark: #fd7e14; $theme-colors: ( 'primary': $color-primary, 'secondary': $color-accent, - 'dark': $color-mild-gray + 'dark': $color-mild-gray, + 'warning-dark': $warning-dark ); $font-family-sans-serif: 'Helvetica Neue', Helvetica, Arial, 'Noto Sans', sans-serif, -- 2.47.3