@@ -10,6 +10,12 @@ export type PvcWithStatus = {
10
10
mountedBy : string | null ;
11
11
}
12
12
13
+ enum PvcStatus {
14
+ DELETING ,
15
+ MOUNTED ,
16
+ UNMOUNTED
17
+ }
18
+
13
19
@Component ( {
14
20
selector : "app-volume-table" ,
15
21
templateUrl : "./volume-table.component.html" ,
@@ -19,23 +25,29 @@ export class VolumeTableComponent implements OnChanges {
19
25
@Input ( ) pvcProperties : PvcWithStatus [ ] ;
20
26
@Output ( ) deletePvcEvent = new EventEmitter < PvcWithStatus > ( ) ;
21
27
28
+ PvcStatus = PvcStatus ;
29
+
22
30
// Table data
23
- displayedColumns : string [ ] = [ "status" , "name" , "size" , "mountedBy" , "actions" ] ;
31
+ displayedColumns : string [ ] = [
32
+ "status" ,
33
+ "name" ,
34
+ "size" ,
35
+ "mountedBy" ,
36
+ "actions"
37
+ ] ;
24
38
dataSource = new MatTableDataSource ( ) ;
25
39
26
- deleteStatus : Set < string > = new Set < string > ( ) ;
40
+ deletionStatus : Set < string > = new Set < string > ( ) ;
27
41
28
- constructor (
29
- private dialog : MatDialog
30
- ) { }
42
+ constructor ( private dialog : MatDialog ) { }
31
43
32
44
ngOnChanges ( changes : SimpleChanges ) : void {
33
45
if ( changes . pvcProperties ) {
34
46
const pvcNames = ( changes . pvcProperties
35
47
. currentValue as PvcWithStatus [ ] ) . map ( p => p . pvc . name ) ;
36
- this . deleteStatus . forEach ( name => {
48
+ this . deletionStatus . forEach ( name => {
37
49
if ( ! pvcNames . includes ( name ) ) {
38
- this . deleteStatus . delete ( name ) ;
50
+ this . deletionStatus . delete ( name ) ;
39
51
}
40
52
} ) ;
41
53
}
@@ -61,12 +73,15 @@ export class VolumeTableComponent implements OnChanges {
61
73
if ( result !== "delete" ) {
62
74
return ;
63
75
}
64
- this . deleteStatus . add ( pvc . pvc . name ) ;
76
+ this . deletionStatus . add ( pvc . pvc . name ) ;
65
77
this . deletePvcEvent . emit ( pvc ) ;
66
78
} ) ;
67
79
}
68
80
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 ;
71
86
}
72
87
}
0 commit comments