From: Alfonso Martínez Date: Thu, 10 Jun 2021 13:23:00 +0000 (+0200) Subject: mgr/dashboard: bucket details: show lock retention period only in days X-Git-Tag: v16.2.5~48^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7805e7a2b6039f74ce175ce5489cdecbc463f015;p=ceph.git mgr/dashboard: bucket details: show lock retention period only in days Fixes: https://tracker.ceph.com/issues/51164 Signed-off-by: Alfonso Martínez (cherry picked from commit b927dc5bff56be742dc4f8608994f243ab18d2d2) --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.html index 310de113c4a..bf4bdcb08d9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.html @@ -121,11 +121,6 @@ class="bold">Days {{ selection.lock_retention_period_days }} - - Years - {{ selection.lock_retention_period_years }} - diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts index 5ec44bcbd32..f9a351367da 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts @@ -16,6 +16,7 @@ export class RgwBucketDetailsComponent implements OnChanges { ngOnChanges() { if (this.selection) { this.rgwBucketService.get(this.selection.bid).subscribe((bucket: object) => { + bucket['lock_retention_period_days'] = this.rgwBucketService.getLockDays(bucket); this.selection = bucket; }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts index 574d807215f..72a37309c4e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts @@ -372,10 +372,5 @@ describe('RgwBucketFormComponent', () => { it('should have valid values [2]', () => { expectValidLockInputs(false, 'Compliance', '2'); }); - - it('should convert retention years to days', () => { - expect(component['getLockDays']({ lock_retention_period_years: 1000 })).toBe(365242); - expect(component['getLockDays']({ lock_retention_period_days: 5 })).toBe(5); - }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts index b1e3a4400a7..07160445206 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts @@ -132,7 +132,7 @@ export class RgwBucketFormComponent extends CdForm implements OnInit { // the Angular react framework will throw an error if there is no // field for a given key. let value: object = _.pick(bidResp, _.keys(defaults)); - value['lock_retention_period_days'] = this.getLockDays(bidResp); + value['lock_retention_period_days'] = this.rgwBucketService.getLockDays(bidResp); value['placement-target'] = bidResp['placement_rule']; value['versioning'] = bidResp['versioning'] === RgwBucketVersioning.ENABLED; value['mfa-delete'] = bidResp['mfa_delete'] === RgwBucketMfaDelete.ENABLED; @@ -358,12 +358,4 @@ export class RgwBucketFormComponent extends CdForm implements OnInit { getMfaDeleteStatus() { return this.isMfaDeleteEnabled ? RgwBucketMfaDelete.ENABLED : RgwBucketMfaDelete.DISABLED; } - - private getLockDays(bucketData: object): number { - if (bucketData['lock_retention_period_years'] > 0) { - return Math.floor(bucketData['lock_retention_period_years'] * 365.242); - } - - return bucketData['lock_retention_period_days']; - } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.spec.ts index e457c2ab122..6e3fbf660ca 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.spec.ts @@ -85,4 +85,10 @@ describe('RgwBucketService', () => { req.flush(['foo', 'bar']); expect(result).toBe(true); }); + + it('should convert lock retention period to days', () => { + expect(service.getLockDays({ lock_retention_period_years: 1000 })).toBe(365242); + expect(service.getLockDays({ lock_retention_period_days: 5 })).toBe(5); + expect(service.getLockDays({})).toBe(0); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts index c1c02629cdd..47126f186d1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts @@ -108,4 +108,12 @@ export class RgwBucketService { }) ); } + + getLockDays(bucketData: object): number { + if (bucketData['lock_retention_period_years'] > 0) { + return Math.floor(bucketData['lock_retention_period_years'] * 365.242); + } + + return bucketData['lock_retention_period_days'] || 0; + } }