Skip to content

Commit f26d160

Browse files
author
Naman Munet
committed
mgr/dashboard: Update bucket details section after making bucket lifecycle changesn
Fixes: https://tracker.ceph.com/issues/69988 Signed-off-by: Naman Munet <[email protected]>
1 parent 64849a8 commit f26d160

File tree

7 files changed

+66
-40
lines changed

7 files changed

+66
-40
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,19 @@
176176
</tr>
177177
<tr *ngIf="selection.lifecycle_progress?.length > 0">
178178
<td i18n
179-
class="bold w-25">Lifecycle Progress</td>
179+
class="bold w-25">
180+
Lifecycle progress
181+
</td>
180182
<td>
181-
<cds-tooltip [description]="lifecycleProgressMap.get(lifecycleProgress)?.description"
183+
<cds-tooltip [description]="lifecycleProgressMap.get(lifecycleProgress.status)?.description"
182184
[align]="'top'">
183185
<cds-tag size="md"
184-
[type]="lifecycleProgressMap.get(lifecycleProgress)?.color">
185-
{{ lifecycleProgress }}
186+
[type]="lifecycleProgressMap.get(lifecycleProgress.status)?.color">
187+
{{ lifecycleProgress.status }}
186188
</cds-tag>
187189
</cds-tooltip>
190+
<div *ngIf="lifecycleProgress?.status !== 'UNINITIAL'"
191+
class="spacing-left">{{lifecycleProgress?.started}}</div>
188192
</td>
189193
</tr>
190194
<tr>
@@ -230,7 +234,8 @@
230234
<a ngbNavLink
231235
i18n>Tiering</a>
232236
<ng-template ngbNavContent>
233-
<cd-rgw-bucket-lifecycle-list [bucket]="selection"></cd-rgw-bucket-lifecycle-list>
237+
<cd-rgw-bucket-lifecycle-list [bucket]="selection"
238+
(updateBucketDetails)="updateBucketDetails(extractLifecycleDetails.bind(this))"></cd-rgw-bucket-lifecycle-list>
234239
</ng-template>
235240
</ng-container>
236241
</nav>

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use '@carbon/layout';
2+
13
table {
24
table-layout: fixed;
35
}
@@ -11,3 +13,7 @@ table td {
1113
max-height: 50vh;
1214
overflow: auto;
1315
}
16+
17+
.spacing-left {
18+
margin-left: layout.$spacing-03;
19+
}

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('RgwBucketDetailsComponent', () => {
5555
rgwBucketServiceGetSpy.and.returnValue(of(bucket));
5656
component.selection = { bid: 'bucket' };
5757
component.lifecycleFormat = 'json';
58-
component.ngOnChanges();
58+
component.extraxtDetailsfromResponse();
5959
expect(component.selection.lifecycle).toEqual({});
6060
});
6161

@@ -85,7 +85,7 @@ describe('RgwBucketDetailsComponent', () => {
8585
const rateLimit = { bucket_ratelimit: { max_size: 1000 } };
8686
spyOn(rgwBucketService, 'getBucketRateLimit').and.returnValue(of(rateLimit));
8787
component.selection = { bid: 'bucket' };
88-
component.ngOnChanges();
88+
component.extraxtDetailsfromResponse();
8989
expect(component.bucketRateLimit).toEqual(rateLimit.bucket_ratelimit);
9090
});
9191

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { RgwRateLimitConfig } from '../models/rgw-rate-limit';
1313
export class RgwBucketDetailsComponent implements OnChanges {
1414
@Input()
1515
selection: any;
16-
lifecycleProgress: string;
16+
lifecycleProgress: { bucket: string; status: string; started: string };
1717
lifecycleProgressMap = new Map<string, { description: string; color: string }>([
1818
['UNINITIAL', { description: $localize`The process has not run yet`, color: 'cool-gray' }],
1919
['PROCESSING', { description: $localize`The process is currently running`, color: 'cyan' }],
@@ -27,33 +27,7 @@ export class RgwBucketDetailsComponent implements OnChanges {
2727
constructor(private rgwBucketService: RgwBucketService) {}
2828

2929
ngOnChanges() {
30-
if (this.selection) {
31-
this.rgwBucketService.get(this.selection.bid).subscribe((bucket: object) => {
32-
bucket['lock_retention_period_days'] = this.rgwBucketService.getLockDays(bucket);
33-
this.selection = bucket;
34-
if (this.lifecycleFormat === 'json' && !this.selection.lifecycle) {
35-
this.selection.lifecycle = {};
36-
}
37-
this.aclPermissions = this.parseXmlAcl(this.selection.acl, this.selection.owner);
38-
if (this.selection.replication?.['Rule']?.['Status']) {
39-
this.replicationStatus = this.selection.replication?.['Rule']?.['Status'];
40-
}
41-
if (this.selection.lifecycle_progress?.length > 0) {
42-
this.selection.lifecycle_progress.forEach(
43-
(progress: { bucket: string; status: string; started: string }) => {
44-
if (progress.bucket.includes(this.selection.bucket)) {
45-
this.lifecycleProgress = progress.status;
46-
}
47-
}
48-
);
49-
}
50-
});
51-
this.rgwBucketService.getBucketRateLimit(this.selection.bid).subscribe((resp: any) => {
52-
if (resp && resp.bucket_ratelimit !== undefined) {
53-
this.bucketRateLimit = resp.bucket_ratelimit;
54-
}
55-
});
56-
}
30+
this.updateBucketDetails(this.extraxtDetailsfromResponse.bind(this));
5731
}
5832

5933
parseXmlAcl(xml: any, bucketOwner: string): Record<string, string[]> {
@@ -90,4 +64,42 @@ export class RgwBucketDetailsComponent implements OnChanges {
9064
});
9165
return data;
9266
}
67+
68+
updateBucketDetails(cbFn: Function) {
69+
if (this.selection) {
70+
this.rgwBucketService.get(this.selection.bid).subscribe((bucket: object) => {
71+
bucket['lock_retention_period_days'] = this.rgwBucketService.getLockDays(bucket);
72+
this.selection = bucket;
73+
cbFn();
74+
});
75+
}
76+
}
77+
78+
extraxtDetailsfromResponse() {
79+
this.aclPermissions = this.parseXmlAcl(this.selection.acl, this.selection.owner);
80+
if (this.selection.replication?.['Rule']?.['Status']) {
81+
this.replicationStatus = this.selection.replication?.['Rule']?.['Status'];
82+
}
83+
this.rgwBucketService.getBucketRateLimit(this.selection.bid).subscribe((resp: any) => {
84+
if (resp && resp.bucket_ratelimit !== undefined) {
85+
this.bucketRateLimit = resp.bucket_ratelimit;
86+
}
87+
});
88+
this.extractLifecycleDetails();
89+
}
90+
91+
extractLifecycleDetails() {
92+
if (this.lifecycleFormat === 'json' && !this.selection.lifecycle) {
93+
this.selection.lifecycle = {};
94+
}
95+
if (this.selection.lifecycle_progress?.length > 0) {
96+
this.selection.lifecycle_progress.forEach(
97+
(progress: { bucket: string; status: string; started: string }) => {
98+
if (progress.bucket.includes(this.selection.bucket)) {
99+
this.lifecycleProgress = progress;
100+
}
101+
}
102+
);
103+
}
104+
}
93105
}

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-lifecycle-list/rgw-bucket-lifecycle-list.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnInit, ViewChild } from '@angular/core';
1+
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
22
import { Bucket } from '../models/rgw-bucket';
33
import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
44
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
@@ -25,6 +25,7 @@ import { NotificationType } from '~/app/shared/enum/notification-type.enum';
2525
})
2626
export class RgwBucketLifecycleListComponent implements OnInit {
2727
@Input() bucket: Bucket;
28+
@Output() updateBucketDetails = new EventEmitter();
2829
@ViewChild(TableComponent, { static: true })
2930
table: TableComponent;
3031
permission: Permission;
@@ -115,11 +116,12 @@ export class RgwBucketLifecycleListComponent implements OnInit {
115116
}
116117

117118
openTieringModal(type: string) {
118-
this.modalService.show(RgwBucketTieringFormComponent, {
119+
const modalRef = this.modalService.show(RgwBucketTieringFormComponent, {
119120
bucket: this.bucket,
120121
selectedLifecycle: this.selection.first(),
121122
editing: type === this.actionLabels.EDIT ? true : false
122123
});
124+
modalRef?.close?.subscribe(() => this.updateBucketDetails.emit());
123125
}
124126

125127
updateSelection(selection: CdTableSelection) {
@@ -149,6 +151,7 @@ export class RgwBucketLifecycleListComponent implements OnInit {
149151
NotificationType.success,
150152
$localize`Lifecycle rule deleted successfully`
151153
);
154+
this.updateBucketDetails.emit();
152155
},
153156
error: () => {
154157
this.modalRef.componentInstance.stopLoadingSpinner();

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('RgwBucketListComponent', () => {
5555

5656
expect(tableActions).toEqual({
5757
'create,update,delete': {
58-
actions: ['Create', 'Edit', 'Delete', 'Tiering'],
58+
actions: ['Create', 'Edit', 'Tiering', 'Delete'],
5959
primary: {
6060
multiple: 'Create',
6161
executing: 'Create',
@@ -91,7 +91,7 @@ describe('RgwBucketListComponent', () => {
9191
}
9292
},
9393
'update,delete': {
94-
actions: ['Edit', 'Delete', 'Tiering'],
94+
actions: ['Edit', 'Tiering', 'Delete'],
9595
primary: {
9696
multiple: '',
9797
executing: '',

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class RgwBucketListComponent extends ListWithDetails implements OnInit, O
137137
disable: () => !this.selection.hasSelection,
138138
name: this.actionLabels.TIERING
139139
};
140-
this.tableActions = [addAction, editAction, deleteAction, tieringAction];
140+
this.tableActions = [addAction, editAction, tieringAction, deleteAction];
141141
this.setTableRefreshTimeout();
142142
}
143143

0 commit comments

Comments
 (0)