@@ -40,83 +40,91 @@ function DeployableItemsList<T extends DeployableItem, S extends BaseStats>({
40
40
}
41
41
} ;
42
42
43
-
44
43
// Handle row click for navigation
45
- // Handle row click for navigation
46
- const handleRowClick = ( item : T ) => {
47
- // Skip navigation if the route is just '#' (for non-navigable items)
48
- if ( config . buildDetailRoute ( { } ) === '#' ) return ;
49
-
50
- // Build the route using the config and navigate
51
- const route = config . buildDetailRoute ( {
52
- environmentId : environment . environmentId ,
53
- itemId : item [ config . idField ] as string ,
54
- ...additionalParams
55
- } ) ;
56
-
57
- history . push ( route ) ;
58
- } ;
59
-
60
- // Generate columns based on config
61
- let columns = [ ...config . columns ] ;
62
-
63
- // Add managed column if enabled
64
- if ( config . enableManaged ) {
65
- columns . push ( {
66
- title : 'Managed' ,
67
- key : 'managed' ,
68
- render : ( _ , record : T ) => (
69
- < Space >
70
- < Tag color = { record . managed ? 'green' : 'default' } >
71
- { record . managed ? 'Managed' : 'Unmanaged' }
72
- </ Tag >
73
- { onToggleManaged && (
74
- < Switch
75
- size = "small"
76
- checked = { ! ! record . managed }
77
- loading = { refreshing }
78
- onClick = { ( checked , e ) => {
79
- e . stopPropagation ( ) ; // Stop row click event
80
- onToggleManaged ( record , checked ) ;
81
- } }
82
- onChange = { ( ) => { } }
83
- />
84
- ) }
85
- </ Space >
86
- ) ,
44
+ const handleRowClick = ( item : T ) => {
45
+ // Skip navigation if the route is just '#' (for non-navigable items)
46
+ if ( config . buildDetailRoute ( { } ) === '#' ) return ;
47
+
48
+ // Build the route using the config and navigate
49
+ const route = config . buildDetailRoute ( {
50
+ environmentId : environment . environmentId ,
51
+ itemId : item [ config . idField ] as string ,
52
+ ...additionalParams
87
53
} ) ;
88
- }
54
+
55
+ history . push ( route ) ;
56
+ } ;
89
57
90
- // Add deploy action column if enabled
91
- if ( config . deploy ?. enabled ) {
92
- columns . push ( {
93
- title : 'Actions' ,
94
- key : 'actions' ,
95
- render : ( _ , record : T ) => (
96
- < Space >
97
- < Tooltip title = { `Deploy this ${ config . singularLabel . toLowerCase ( ) } to another environment` } >
98
- < Button
99
- icon = { < CloudUploadOutlined /> }
100
- onClick = { ( e ) => {
101
- e . stopPropagation ( ) ; // Prevent row click navigation
102
- openDeployModal ( record , config , environment ) ;
103
- } }
104
- type = "primary"
105
- ghost
106
- >
107
- Deploy
108
- </ Button >
109
- </ Tooltip >
110
- </ Space >
111
- ) ,
112
- } ) ;
113
- }
58
+ // Determine columns - Use new getColumns method if available, fall back to old approach
59
+ const columns = config . getColumns ?
60
+ config . getColumns ( {
61
+ environment,
62
+ refreshing,
63
+ onToggleManaged,
64
+ openDeployModal,
65
+ additionalParams
66
+ } ) :
67
+ generateLegacyColumns ( ) ;
68
+
69
+ // Legacy column generation for backward compatibility
70
+ function generateLegacyColumns ( ) {
71
+ let legacyColumns = [ ...config . columns ] ;
72
+
73
+ // Add managed column if enabled
74
+ if ( config . enableManaged ) {
75
+ legacyColumns . push ( {
76
+ title : 'Managed' ,
77
+ key : 'managed' ,
78
+ render : ( _ , record : T ) => (
79
+ < Space >
80
+ < Tag color = { record . managed ? 'green' : 'default' } >
81
+ { record . managed ? 'Managed' : 'Unmanaged' }
82
+ </ Tag >
83
+ { onToggleManaged && (
84
+ < Switch
85
+ size = "small"
86
+ checked = { ! ! record . managed }
87
+ loading = { refreshing }
88
+ onClick = { ( checked , e ) => {
89
+ e . stopPropagation ( ) ; // Stop row click event
90
+ onToggleManaged ( record , checked ) ;
91
+ } }
92
+ onChange = { ( ) => { } }
93
+ />
94
+ ) }
95
+ </ Space >
96
+ ) ,
97
+ } ) ;
98
+ }
114
99
115
- const hasAudit = config . audit ?. enabled ;
100
+ // Add deploy action column if enabled
101
+ if ( config . deploy ?. enabled ) {
102
+ legacyColumns . push ( {
103
+ title : 'Actions' ,
104
+ key : 'actions' ,
105
+ render : ( _ , record : T ) => (
106
+ < Space >
107
+ < Tooltip title = { `Deploy this ${ config . singularLabel . toLowerCase ( ) } to another environment` } >
108
+ < Button
109
+ icon = { < CloudUploadOutlined /> }
110
+ onClick = { ( e ) => {
111
+ e . stopPropagation ( ) ; // Prevent row click navigation
112
+ openDeployModal ( record , config , environment ) ;
113
+ } }
114
+ type = "primary"
115
+ ghost
116
+ >
117
+ Deploy
118
+ </ Button >
119
+ </ Tooltip >
120
+ </ Space >
121
+ ) ,
122
+ } ) ;
123
+ }
116
124
117
- // Add audit column if enabled - SEPARATE CONDITION
125
+ // Add audit column if enabled
118
126
if ( config . audit ?. enabled ) {
119
- columns . push ( {
127
+ legacyColumns . push ( {
120
128
title : 'Audit' ,
121
129
key : 'audit' ,
122
130
render : ( _ , record : T ) => (
@@ -131,6 +139,9 @@ const handleRowClick = (item: T) => {
131
139
) ,
132
140
} ) ;
133
141
}
142
+
143
+ return legacyColumns ;
144
+ }
134
145
135
146
if ( loading ) {
136
147
return (
@@ -151,19 +162,18 @@ const handleRowClick = (item: T) => {
151
162
152
163
const hasNavigation = config . buildDetailRoute ( { } ) !== '#' ;
153
164
154
-
155
165
return (
156
166
< Table
157
- columns = { columns }
158
- dataSource = { items }
159
- rowKey = { config . idField }
160
- pagination = { { pageSize : 10 } }
161
- size = "middle"
162
- onRow = { ( record ) => ( {
163
- onClick : hasNavigation ? ( ) => handleRowClick ( record ) : undefined ,
164
- style : hasNavigation ? { cursor : 'pointer' } : undefined ,
165
- } ) }
166
- />
167
+ columns = { columns }
168
+ dataSource = { items }
169
+ rowKey = { config . idField }
170
+ pagination = { { pageSize : 10 } }
171
+ size = "middle"
172
+ onRow = { ( record ) => ( {
173
+ onClick : hasNavigation ? ( ) => handleRowClick ( record ) : undefined ,
174
+ style : hasNavigation ? { cursor : 'pointer' } : undefined ,
175
+ } ) }
176
+ />
167
177
) ;
168
178
}
169
179
0 commit comments