11import type { FC } from 'react' ;
22import {
33 actionsCellProps ,
4- cellIsStickyProps ,
54 getNameCellProps ,
5+ nameCellProps ,
66} from '@console/app/src/components/data-view/ConsoleDataView' ;
77import {
88 ConsoleDataViewColumn ,
99 ConsoleDataViewRow ,
1010} from '@console/app/src/components/data-view/types' ;
11- import { K8sModel } from '@console/dynamic-plugin-sdk/src/api/common-types' ;
11+ import { useColumnWidthSettings } from '@console/app/src/components/data-view/useResizableColumnProps' ;
12+ import type { K8sModel } from '@console/dynamic-plugin-sdk/src/api/common-types' ;
1213import { RowProps , TableColumn } from '@console/dynamic-plugin-sdk/src/extensions/console-types' ;
1314import { getGroupVersionKindForModel } from '@console/dynamic-plugin-sdk/src/utils/k8s/k8s-ref' ;
1415import LazyActionMenu , {
@@ -159,23 +160,29 @@ export const getWorkloadDataViewRows = <T extends K8sResourceKind>(
159160 } ) ;
160161} ;
161162
162- export const useWorkloadColumns = < T extends K8sResourceKind > ( ) : TableColumn < T > [ ] => {
163+ export const useWorkloadColumns = < T extends K8sResourceKind > (
164+ model : K8sModel ,
165+ ) : { columns : TableColumn < T > [ ] ; resetAllColumnWidths : ( ) => void } => {
163166 const { t } = useTranslation ( ) ;
167+ const { getResizableProps, resetAllColumnWidths } = useColumnWidthSettings ( model ) ;
168+
164169 const columns = useMemo ( ( ) => {
165170 return [
166171 {
167172 title : t ( 'public~Name' ) ,
168173 id : tableColumnInfo [ 0 ] . id ,
169174 sort : 'metadata.name' ,
175+ resizableProps : getResizableProps ( tableColumnInfo [ 0 ] . id ) ,
170176 props : {
171- ...cellIsStickyProps ,
177+ ...nameCellProps ,
172178 modifier : 'nowrap' ,
173179 } ,
174180 } ,
175181 {
176182 title : t ( 'public~Namespace' ) ,
177183 id : tableColumnInfo [ 1 ] . id ,
178184 sort : 'metadata.namespace' ,
185+ resizableProps : getResizableProps ( tableColumnInfo [ 1 ] . id ) ,
179186 props : {
180187 modifier : 'nowrap' ,
181188 } ,
@@ -184,6 +191,7 @@ export const useWorkloadColumns = <T extends K8sResourceKind>(): TableColumn<T>[
184191 title : t ( 'public~Status' ) ,
185192 id : tableColumnInfo [ 2 ] . id ,
186193 sort : 'status.replicas' ,
194+ resizableProps : getResizableProps ( tableColumnInfo [ 2 ] . id ) ,
187195 props : {
188196 modifier : 'nowrap' ,
189197 } ,
@@ -192,30 +200,31 @@ export const useWorkloadColumns = <T extends K8sResourceKind>(): TableColumn<T>[
192200 title : t ( 'public~Labels' ) ,
193201 id : tableColumnInfo [ 3 ] . id ,
194202 sort : 'metadata.labels' ,
203+ resizableProps : getResizableProps ( tableColumnInfo [ 3 ] . id ) ,
195204 props : {
196205 modifier : 'nowrap' ,
197- width : 20 ,
198206 } ,
199207 } ,
200208 {
201209 title : t ( 'public~Pod selector' ) ,
202210 id : tableColumnInfo [ 4 ] . id ,
203211 sort : 'spec.selector' ,
212+ resizableProps : getResizableProps ( tableColumnInfo [ 4 ] . id ) ,
204213 props : {
205214 modifier : 'nowrap' ,
206- width : 20 ,
207215 } ,
208216 } ,
209217 {
210218 title : '' ,
211219 id : tableColumnInfo [ 5 ] . id ,
212220 props : {
213- ...cellIsStickyProps ,
221+ ...actionsCellProps ,
214222 } ,
215223 } ,
216224 ] ;
217- } , [ t ] ) ;
218- return columns ;
225+ } , [ t , getResizableProps ] ) ;
226+
227+ return { columns, resetAllColumnWidths } ;
219228} ;
220229
221230type ReplicasCountProps = {
0 commit comments