Skip to content

Commit 4fabd14

Browse files
committed
feat: Convey more info via volume status column
Switch to a tristate PVC status so that the volume management table can indicate whether a volume is mounted, unmounted, or being deleted.
1 parent 49fc2b3 commit 4fabd14

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

frontend/src/app/main-table/volumes-table/volume-table.component.html

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,27 @@
88
<!-- Status Column -->
99
<ng-container matColumnDef="status">
1010
<th mat-header-cell *matHeaderCellDef>Status</th>
11-
<td mat-cell *matCellDef="let elem">
12-
<!-- Running -->
11+
<td mat-cell *matCellDef="let elem" [ngSwitch]="pvcStatus(elem)">
12+
<!-- Mounted -->
1313
<mat-icon
14-
*ngIf="!checkDeletionStatus(elem)"
14+
*ngSwitchCase="PvcStatus.MOUNTED"
1515
[ngClass]="['running', 'status']"
16-
matTooltip="Running"
17-
>check_circle
16+
matTooltip="Attached"
17+
>link
18+
</mat-icon>
19+
20+
<!-- Unmounted -->
21+
<mat-icon
22+
*ngSwitchCase="PvcStatus.UNMOUNTED"
23+
[ngClass]="['warning', 'status']"
24+
matTooltip="Unattached"
25+
>link_off
1826
</mat-icon>
1927

20-
<!-- Waiting -->
28+
<!-- Deleting -->
2129
<mat-spinner
22-
*ngIf="checkDeletionStatus(elem)"
23-
matTooltip="Deleting Volume"
30+
*ngSwitchCase="PvcStatus.DELETING"
31+
matTooltip="Deleting"
2432
diameter="24"
2533
class="inline"
2634
>
@@ -54,7 +62,7 @@
5462
<td mat-cell *matCellDef="let elem">
5563
<button
5664
mat-icon-button
57-
[disabled]="checkDeletionStatus(elem) || elem.mountedBy"
65+
[disabled]="pvcStatus(elem) !== PvcStatus.UNMOUNTED"
5866
(click)="deletePvc(elem)"
5967
>
6068
<mat-icon>delete</mat-icon>

frontend/src/app/main-table/volumes-table/volume-table.component.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export type PvcWithStatus = {
1010
mountedBy: string | null;
1111
}
1212

13+
enum PvcStatus {
14+
DELETING,
15+
MOUNTED,
16+
UNMOUNTED
17+
}
18+
1319
@Component({
1420
selector: "app-volume-table",
1521
templateUrl: "./volume-table.component.html",
@@ -19,23 +25,29 @@ export class VolumeTableComponent implements OnChanges {
1925
@Input() pvcProperties: PvcWithStatus[];
2026
@Output() deletePvcEvent = new EventEmitter<PvcWithStatus>();
2127

28+
PvcStatus = PvcStatus;
29+
2230
// Table data
23-
displayedColumns: string[] = ["status", "name", "size", "mountedBy", "actions"];
31+
displayedColumns: string[] = [
32+
"status",
33+
"name",
34+
"size",
35+
"mountedBy",
36+
"actions"
37+
];
2438
dataSource = new MatTableDataSource();
2539

26-
deleteStatus: Set<string> = new Set<string>();
40+
deletionStatus: Set<string> = new Set<string>();
2741

28-
constructor(
29-
private dialog: MatDialog
30-
) {}
42+
constructor(private dialog: MatDialog) {}
3143

3244
ngOnChanges(changes: SimpleChanges): void {
3345
if (changes.pvcProperties) {
3446
const pvcNames = (changes.pvcProperties
3547
.currentValue as PvcWithStatus[]).map(p => p.pvc.name);
36-
this.deleteStatus.forEach(name => {
48+
this.deletionStatus.forEach(name => {
3749
if (!pvcNames.includes(name)) {
38-
this.deleteStatus.delete(name);
50+
this.deletionStatus.delete(name);
3951
}
4052
});
4153
}
@@ -61,12 +73,15 @@ export class VolumeTableComponent implements OnChanges {
6173
if (result !== "delete") {
6274
return;
6375
}
64-
this.deleteStatus.add(pvc.pvc.name);
76+
this.deletionStatus.add(pvc.pvc.name);
6577
this.deletePvcEvent.emit(pvc);
6678
});
6779
}
6880

69-
checkDeletionStatus(pvc: PvcWithStatus): boolean {
70-
return this.deleteStatus.has(pvc.pvc.name);
81+
pvcStatus(pvc: PvcWithStatus): PvcStatus {
82+
if (this.deletionStatus.has(pvc.pvc.name)) {
83+
return PvcStatus.DELETING;
84+
}
85+
return pvc.mountedBy ? PvcStatus.MOUNTED : PvcStatus.UNMOUNTED;
7186
}
7287
}

0 commit comments

Comments
 (0)