1
1
import SteveModel from '@shell/plugins/steve/steve-class' ;
2
+ import { PRODUCT_NAME , PAGE } from "@sbombastic-image-vulnerability-scanner/types" ;
2
3
import { insertAt } from '@shell/utils/array' ;
3
4
4
5
export default class SbombasticRancherIoVexhub extends SteveModel {
5
6
get _availableActions ( ) {
6
7
let out = super . _availableActions || [ ] ;
7
8
9
+ // Check if we are in the details page
10
+ const isDetailsPage = this . $rootState . targetRoute && 'id' in this . $rootState . targetRoute . params ;
11
+
8
12
// Remove download actions and View in API, keep edit YAML and clone
9
13
const remove = new Set ( [
10
14
'download' ,
@@ -17,30 +21,7 @@ export default class SbombasticRancherIoVexhub extends SteveModel {
17
21
out = out . filter ( ( a ) => ! a ?. action || ! remove . has ( a . action ) ) ;
18
22
19
23
const isEnabled = ! ! this . spec ?. enabled ;
20
-
21
- const toggle = isEnabled
22
- ? {
23
- action : 'disable' ,
24
- label : this . t ( 'imageScanner.vexManagement.buttons.disable' ) || 'Disable' ,
25
- icon : 'icon-pause' ,
26
- enabled : true ,
27
- bulkable : true ,
28
- invoke : async ( ) => {
29
- this . spec = { ...( this . spec || { } ) , enabled : false } ;
30
- await this . save ( ) ;
31
- }
32
- }
33
- : {
34
- action : 'enable' ,
35
- label : this . t ( 'imageScanner.vexManagement.buttons.enable' ) || 'Enable' ,
36
- icon : 'icon-play' ,
37
- enabled : true ,
38
- bulkable : true ,
39
- invoke : async ( ) => {
40
- this . spec = { ...( this . spec || { } ) , enabled : true } ;
41
- await this . save ( ) ;
42
- }
43
- } ;
24
+ const toggle = this . toggle ;
44
25
45
26
if ( isEnabled ) {
46
27
// For enabled items: Disable, then other actions
@@ -57,20 +38,65 @@ export default class SbombasticRancherIoVexhub extends SteveModel {
57
38
}
58
39
59
40
// Ensure all actions are enabled
60
- return reordered . map ( action => {
41
+ const returnActions = reordered . map ( action => {
61
42
if ( action && action . enabled === false ) {
62
43
return { ...action , enabled : true } ;
63
44
}
64
45
return action ;
65
46
} ) ;
47
+ return isDetailsPage ? returnActions . slice ( 1 ) : returnActions ;
66
48
}
67
49
68
50
// When disabled: Enable, then Delete
69
51
const deleteAction = out . find ( ( a ) => a ?. action === 'promptRemove' ) ;
70
- return [ toggle , ...( deleteAction ? [ deleteAction ] : [ ] ) ] ;
52
+ const returnActions = [ toggle , ...( deleteAction ? [ deleteAction ] : [ ] ) ] ;
53
+ return isDetailsPage ? returnActions . slice ( 1 ) : returnActions ;
71
54
}
72
55
73
56
get canDelete ( ) {
74
57
return ! this . spec ?. enabled ;
75
58
}
59
+
60
+ get listLocation ( ) {
61
+ return { name : `c-cluster-${ PRODUCT_NAME } -${ PAGE . VEX_MANAGEMENT } ` , } ;
62
+ }
63
+
64
+ get doneOverride ( ) {
65
+ return this . listLocation ;
66
+ }
67
+
68
+ get parentLocationOverride ( ) {
69
+ return this . listLocation ;
70
+ }
71
+
72
+ get fullDetailPageOverride ( ) {
73
+ return true ;
74
+ }
75
+
76
+ get toggle ( ) {
77
+ const isEnabled = ! ! this . spec ?. enabled ;
78
+ return isEnabled
79
+ ? {
80
+ action : 'disable' ,
81
+ label : this . t ( 'imageScanner.vexManagement.buttons.disable' ) || 'Disable' ,
82
+ icon : 'icon-pause' ,
83
+ enabled : true ,
84
+ bulkable : true ,
85
+ invoke : async ( ) => {
86
+ this . spec = { ...( this . spec || { } ) , enabled : false } ;
87
+ await this . save ( ) ;
88
+ }
89
+ }
90
+ : {
91
+ action : 'enable' ,
92
+ label : this . t ( 'imageScanner.vexManagement.buttons.enable' ) || 'Enable' ,
93
+ icon : 'icon-play' ,
94
+ enabled : true ,
95
+ bulkable : true ,
96
+ invoke : async ( ) => {
97
+ this . spec = { ...( this . spec || { } ) , enabled : true } ;
98
+ await this . save ( ) ;
99
+ }
100
+ } ;
101
+ }
76
102
}
0 commit comments