File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
pages/SourcesPage/components/SourcesGrid Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 11import AddIcon from "@mui/icons-material/Add" ;
2+ import RestartAltIcon from "@mui/icons-material/RestartAlt" ;
23import { Button } from '@mui/material' ;
34import { GridToolbarColumnsButton , GridToolbarContainer , GridToolbarFilterButton } from "@mui/x-data-grid" ;
45
56type Props = {
67 onNewClick : ( ) => void ;
8+ onResetColumns ?: ( ) => void ;
79 children ?: React . ReactNode ;
810} ;
911
1012export const GridToolbar = ( props : Props ) => {
11- const { onNewClick, children } = props ;
13+ const { onNewClick, onResetColumns , children } = props ;
1214
1315 return (
1416 < GridToolbarContainer >
1517 < GridToolbarColumnsButton slotProps = { { button : { size : "small" } } } />
1618 < GridToolbarFilterButton slotProps = { { button : { size : "small" } } } />
1719 < Button startIcon = { < AddIcon /> } onClick = { onNewClick } > New</ Button >
20+ { onResetColumns && (
21+ < Button startIcon = { < RestartAltIcon /> } onClick = { onResetColumns } >
22+ Reset Columns
23+ </ Button >
24+ ) }
1825 { children }
1926 </ GridToolbarContainer >
2027 ) ;
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ export const SourcesGrid = () => {
1919 columnVisibility,
2020 columnsWithSizing,
2121 onColumnVisibilityChange,
22- onColumnResize
22+ onColumnResize,
23+ resetColumnSizes
2324 } = useGridState ( 'SOURCES_GRID' , columns , {
2425 Kind : false ,
2526 IncludePattern : false ,
@@ -52,7 +53,7 @@ export const SourcesGrid = () => {
5253 rows = { data ?? [ ] }
5354 pageSizeOptions = { [ ] }
5455 slots = { {
55- toolbar : ( ) => < SourcesGridToolbar />
56+ toolbar : ( ) => < SourcesGridToolbar onResetColumns = { resetColumnSizes } />
5657 } }
5758 columnVisibilityModel = { columnVisibility }
5859 onColumnVisibilityModelChange = { onColumnVisibilityChange }
Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ import { GridToolbar } from "components/GridToolbar/GridToolbar";
22import { useSourceFormContext } from "contexts/SourceForm/SourceForm.context" ;
33import { SourceFormActions } from "contexts/SourceForm/SourceForm.types" ;
44
5- export const SourcesGridToolbar = ( ) => {
5+ type Props = {
6+ onResetColumns : ( ) => void ;
7+ } ;
8+
9+ export const SourcesGridToolbar = ( { onResetColumns } : Props ) => {
610 const { handleOpen, setData, setAction } = useSourceFormContext ( ) ;
711
812 const onNewClick = ( ) => {
@@ -12,6 +16,6 @@ export const SourcesGridToolbar = () => {
1216 } ;
1317
1418 return (
15- < GridToolbar onNewClick = { onNewClick } />
19+ < GridToolbar onNewClick = { onNewClick } onResetColumns = { onResetColumns } />
1620 ) ;
1721} ;
You can’t perform that action at this time.
0 commit comments