11import SteveModel from '@shell/plugins/steve/steve-class' ;
2+ import { PRODUCT_NAME , PAGE } from "@sbombastic-image-vulnerability-scanner/types" ;
23import { insertAt } from '@shell/utils/array' ;
34
45export default class SbombasticRancherIoVexhub extends SteveModel {
56 get _availableActions ( ) {
67 let out = super . _availableActions || [ ] ;
78
9+ // Check if we are in the details page
10+ const isDetailsPage = this . $rootState . targetRoute && 'id' in this . $rootState . targetRoute . params ;
11+
812 // Remove download actions and View in API, keep edit YAML and clone
913 const remove = new Set ( [
1014 'download' ,
@@ -17,30 +21,7 @@ export default class SbombasticRancherIoVexhub extends SteveModel {
1721 out = out . filter ( ( a ) => ! a ?. action || ! remove . has ( a . action ) ) ;
1822
1923 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 ;
4425
4526 if ( isEnabled ) {
4627 // For enabled items: Disable, then other actions
@@ -57,20 +38,65 @@ export default class SbombasticRancherIoVexhub extends SteveModel {
5738 }
5839
5940 // Ensure all actions are enabled
60- return reordered . map ( action => {
41+ const returnActions = reordered . map ( action => {
6142 if ( action && action . enabled === false ) {
6243 return { ...action , enabled : true } ;
6344 }
6445 return action ;
6546 } ) ;
47+ return isDetailsPage ? returnActions . slice ( 1 ) : returnActions ;
6648 }
6749
6850 // When disabled: Enable, then Delete
6951 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 ;
7154 }
7255
7356 get canDelete ( ) {
7457 return ! this . spec ?. enabled ;
7558 }
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+ }
76102}
0 commit comments