class="bold">Days</td>
<td>{{ selection.lock_retention_period_days }}</td>
</tr>
- <tr>
- <td i18n
- class="bold">Years</td>
- <td>{{ selection.lock_retention_period_years }}</td>
- </tr>
</ng-container>
</tbody>
</table>
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;
});
}
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);
- });
});
});
// 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;
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'];
- }
}
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);
+ });
});
})
);
}
+
+ 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;
+ }
}