Grids: refresh button (small icon, right of the filters button)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Samer Salameh 2026-11-24 12:06:33 +03:00
parent dc72cf2869
commit 31771e3c73
2 changed files with 17 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import {
import CheckIcon from '@mui/icons-material/Check'; import CheckIcon from '@mui/icons-material/Check';
import ContentCopyIcon from '@mui/icons-material/ContentCopy'; import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import FilterListIcon from '@mui/icons-material/FilterList'; import FilterListIcon from '@mui/icons-material/FilterList';
import RefreshIcon from '@mui/icons-material/Refresh';
import MoreVertIcon from '@mui/icons-material/MoreVert'; import MoreVertIcon from '@mui/icons-material/MoreVert';
import EditOutlined from '@mui/icons-material/EditOutlined'; import EditOutlined from '@mui/icons-material/EditOutlined';
import VisibilityOutlined from '@mui/icons-material/VisibilityOutlined'; import VisibilityOutlined from '@mui/icons-material/VisibilityOutlined';
@ -145,8 +146,21 @@ export function DataGrid<T>({ meta }: DataGridProps<T>) {
const columns = meta.visualLtr && rtl ? [...meta.columns].reverse() : meta.columns; const columns = meta.visualLtr && rtl ? [...meta.columns].reverse() : meta.columns;
const actionsBefore = !!meta.visualLtr && !rtl; const actionsBefore = !!meta.visualLtr && !rtl;
// reloads the current page with the same filters (nothing to load while a required filter is missing)
const hasFilterCard = !!meta.status || filterDefs.length > 0;
const refreshButton = (
<Tooltip title={t('grid.refresh')}>
<span>
<IconButton size="small" aria-label={t('grid.refresh')} color="primary" disabled={!canLoad || q.isFetching} onClick={() => void q.refetch()}>
<RefreshIcon fontSize="small" />
</IconButton>
</span>
</Tooltip>
);
return ( return (
<Stack spacing={1.5}> <Stack spacing={1.5}>
{!hasFilterCard && <Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>{refreshButton}</Box>}
{/* filter card: status chips + filter button, then the applied filters with "clear all" (same look on every list) */} {/* filter card: status chips + filter button, then the applied filters with "clear all" (same look on every list) */}
{(meta.status || filterDefs.length > 0) && ( {(meta.status || filterDefs.length > 0) && (
<Paper variant="outlined" sx={{ p: 2 }}> <Paper variant="outlined" sx={{ p: 2 }}>
@ -178,6 +192,7 @@ export function DataGrid<T>({ meta }: DataGridProps<T>) {
})} })}
</Stack> </Stack>
) : <Box sx={{ flex: 1 }} />} ) : <Box sx={{ flex: 1 }} />}
{refreshButton}
{filterDefs.length > 0 && ( {filterDefs.length > 0 && (
<Badge <Badge
badgeContent={drawerCount} badgeContent={drawerCount}

View File

@ -114,7 +114,8 @@ export const ui = {
'grid.displayedRows': { en: '{from}-{to} of {count}', ar: '{from}-{to} من {count}' }, 'grid.displayedRows': { en: '{from}-{to} of {count}', ar: '{from}-{to} من {count}' },
'grid.filterTitle': { en: 'Filter results', ar: 'تصفية النتائج' }, 'grid.filterTitle': { en: 'Filter results', ar: 'تصفية النتائج' },
'grid.status': { en: 'Status', ar: 'الحالة' }, 'grid.status': { en: 'Status', ar: 'الحالة' },
'grid.clearAll': { en: 'Clear all', ar: 'مسح الكل' }, 'grid.refresh': { en: 'Refresh', ar: 'تحديث' },
'grid.clearAll':{ en: 'Clear all', ar: 'مسح الكل' },
'grid.requireFilter': { en: 'Choose at least one filter to load this list.', ar: 'اختر معياراً واحداً على الأقل لتحميل هذه القائمة.' }, 'grid.requireFilter': { en: 'Choose at least one filter to load this list.', ar: 'اختر معياراً واحداً على الأقل لتحميل هذه القائمة.' },
// dialogs / overlay // dialogs / overlay