feat: display loader when fetching data
This commit is contained in:
@@ -9,7 +9,7 @@ import TableContainer from '@mui/material/TableContainer';
|
||||
import TableHead from '@mui/material/TableHead';
|
||||
import TablePagination from '@mui/material/TablePagination';
|
||||
import TableRow from '@mui/material/TableRow';
|
||||
import { Accordion, AccordionSummary, AccordionDetails, Typography, Box, TextField, Tooltip } from '@mui/material';
|
||||
import { Accordion, AccordionSummary, AccordionDetails, Typography, Box, TextField, Tooltip, CircularProgress } from '@mui/material';
|
||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||
import SearchIcon from '@mui/icons-material/Search';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
@@ -134,6 +134,7 @@ export const RunsTable: React.FC<RunsTableProps> = ({
|
||||
|
||||
const [rows, setRows] = useState<Data[]>([]);
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
const [paginationStates, setPaginationStates] = useState<PaginationState>({});
|
||||
|
||||
@@ -224,6 +225,8 @@ export const RunsTable: React.FC<RunsTableProps> = ({
|
||||
}
|
||||
} catch (error) {
|
||||
notify('error', t('runstable.notifications.fetch_error'));
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [notify, t]);
|
||||
|
||||
@@ -231,6 +234,7 @@ export const RunsTable: React.FC<RunsTableProps> = ({
|
||||
let mounted = true;
|
||||
|
||||
if (rows.length === 0 || rerenderRuns) {
|
||||
setIsLoading(true);
|
||||
fetchRuns().then(() => {
|
||||
if (mounted) {
|
||||
setRerenderRuns(false);
|
||||
@@ -378,7 +382,9 @@ export const RunsTable: React.FC<RunsTableProps> = ({
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{Object.keys(groupedRows).length === 0 ? (
|
||||
{isLoading? (
|
||||
<CircularProgress size={32} />
|
||||
) : Object.keys(groupedRows).length === 0 ? (
|
||||
<Box
|
||||
display="flex"
|
||||
flexDirection="column"
|
||||
|
||||
Reference in New Issue
Block a user