@@ -37,6 +37,7 @@ import DoneIcon from '@mui/icons-material/Done';
3737import CloseIcon from '@mui/icons-material/Close' ;
3838import SettingsIcon from '@mui/icons-material/Settings' ;
3939import AutoMatchIcon from '@mui/icons-material/MotionPhotosAutoOutlined' ;
40+ import ClearIcon from '@mui/icons-material/Clear' ;
4041
4142import orderBy from 'lodash/orderBy'
4243import filter from 'lodash/filter'
@@ -160,6 +161,7 @@ const MapProject = () => {
160161 const [ columnVisibilityModel , setColumnVisibilityModel ] = React . useState ( { } )
161162 const [ columnWidth , setColumnWidth ] = React . useState ( { } )
162163 const [ logs , setLogs ] = React . useState ( { } )
164+ const [ filterModel , setFilterModel ] = React . useState ( { items : [ ] } ) ;
163165
164166 // repo state
165167 const [ repo , setRepo ] = React . useState ( false )
@@ -301,8 +303,26 @@ const MapProject = () => {
301303 headerClassName : headerClass ,
302304 renderHeader : ( ) => {
303305 if ( isValidColumn ) {
306+ const isFiltered = filterModel . items . some ( ( item ) => item . field === column . dataKey && item . value ) ;
304307 return < div >
305- < div > { column . original } </ div >
308+ < div >
309+ < span style = { { flexGrow : 1 } } > { column . original } </ span >
310+ {
311+ isFiltered &&
312+ < Tooltip title = "Clear Filter" >
313+ < IconButton
314+ size = "small"
315+ onClick = { ( e ) => {
316+ e . stopPropagation ( ) ; // prevent sorting on click
317+ const updatedItems = filterModel . items . filter ( ( item ) => item . field !== column . dataKey ) ;
318+ setFilterModel ( { ...filterModel , items : updatedItems } ) ;
319+ } }
320+ >
321+ < ClearIcon fontSize = "small" />
322+ </ IconButton >
323+ </ Tooltip >
324+ }
325+ </ div >
306326 < div > < Chip color = 'warning' variant = 'outlined' size = 'small' label = { column . label } sx = { { fontSize : '12px' , margin : '2px 0' } } /> </ div >
307327 </ div >
308328 }
@@ -1327,6 +1347,8 @@ const MapProject = () => {
13271347 </ Collapse >
13281348 < div style = { { width : '100%' , height : project ?. id ? 'calc(100vh - 259px)' : 'calc(100vh - 250px)' } } >
13291349 < DataGrid
1350+ onFilterModelChange = { ( model ) => setFilterModel ( model ) }
1351+ filterModel = { filterModel }
13301352 resizeThrottleMs = { 100 }
13311353 onCellClick = { doubleClickCallback }
13321354 sx = { {
0 commit comments