11import  {  IconButton  }  from  '@mui/material' ; 
2- import  {  DataGrid ,  GridColDef  }  from  '@mui/x-data-grid' ; 
2+ import  {  DataGrid ,  GridColDef ,   GridRowSelectionModel  }  from  '@mui/x-data-grid' ; 
33import  {  IEnvironmentData  }  from  './types' ; 
44import  {  memo ,  useMemo  }  from  'react' ; 
55import  CheckIcon  from  '@mui/icons-material/Check' ; 
@@ -84,8 +84,13 @@ const columns: GridColDef[] = [
8484
8585export  interface  IEnvironmentListProps  { 
8686  images : IEnvironmentData [ ] ; 
87-   default_cpu_limit : string ; 
88-   default_mem_limit : string ; 
87+   default_cpu_limit ?: string ; 
88+   default_mem_limit ?: string ; 
89+   hideRemoveButton ?: boolean ; 
90+   pageSize ?: number ; 
91+   selectable ?: boolean ; 
92+   rowSelectionModel ?: GridRowSelectionModel ; 
93+   setRowSelectionModel ?: ( selected : GridRowSelectionModel )  =>  void ; 
8994} 
9095
9196function  _EnvironmentList ( props : IEnvironmentListProps )  { 
@@ -95,12 +100,11 @@ function _EnvironmentList(props: IEnvironmentListProps) {
95100      newItem . cpu_limit  = 
96101        newItem . cpu_limit . length  >  0 
97102          ? newItem . cpu_limit 
98-           : props . default_cpu_limit ; 
103+           : props . default_cpu_limit   ??   '2' ; 
99104      newItem . mem_limit  = 
100105        newItem . mem_limit . length  >  0 
101106          ? newItem . mem_limit 
102-           : props . default_mem_limit ; 
103-       // newItem.status = 'building'; 
107+           : props . default_mem_limit  ??  '2' ; 
104108      return  newItem ; 
105109    } ) ; 
106110  } ,  [ props ] ) ; 
@@ -113,12 +117,21 @@ function _EnvironmentList(props: IEnvironmentListProps) {
113117        initialState = { { 
114118          pagination : { 
115119            paginationModel : { 
116-               pageSize : 100 
120+               pageSize : props . pageSize   ??   100 
117121            } 
118122          } 
119123        } } 
120-         pageSizeOptions = { [ 100 ] } 
121-         disableRowSelectionOnClick 
124+         pageSizeOptions = { [ props . pageSize  ??  100 ] } 
125+         disableRowSelectionOnClick = { ! Boolean ( props . selectable ) } 
126+         sx = { { 
127+           '& .MuiDataGrid-virtualScroller::-webkit-scrollbar' : { 
128+             overflow : rows . length  >  0  ? 'auto'  : 'hidden' 
129+           } 
130+         } } 
131+         columnVisibilityModel = { {  remove : ! Boolean ( props . hideRemoveButton )  } } 
132+         checkboxSelection = { Boolean ( props . selectable ) } 
133+         rowSelectionModel = { props . rowSelectionModel } 
134+         onRowSelectionModelChange = { props . setRowSelectionModel } 
122135      /> 
123136    </ Box > 
124137  ) ; 
0 commit comments