Skip to content

Commit

Permalink
Update Users Uploads and Sources tables
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-zakrzewski committed May 1, 2024
1 parent 6b4ab01 commit f22653b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ class SourceTable extends React.Component<Props, SourceTableState> {
// https://docs.mongodb.com/manual/text-search/
search: false,
filtering: false,
sorting: false,
emptyRowsWhenPaging: false,
padding: 'dense',
draggable: false, // No need to be able to drag and drop headers.
Expand Down
39 changes: 13 additions & 26 deletions verification/curator-service/ui/src/components/UploadsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
import MaterialTable, { QueryResult } from '@material-table/core';
import { Paper, TablePagination, Typography } from '@mui/material';
import { Paper, Typography } from '@mui/material';
import { useRef, useState } from 'react';

import { styled } from '@mui/material/styles';

import { Link } from 'react-router-dom';
import MuiAlert from '@mui/material/Alert';
import axios from 'axios';
import renderDate from './util/date';
import { makeStyles } from 'tss-react/mui';

const Alert = styled(MuiAlert)(({ theme }) => ({
borderRadius: theme.spacing(1),
marginTop: theme.spacing(2),
}));

const Spacer = styled('span')(() => ({
flex: 1,
}));

const TablePaginationBar = styled('div')(({ theme }) => ({
alignItems: 'center',
backgroundColor: theme.palette.background.default,
display: 'flex',
height: '64px',
}));

interface UploadSummary {
numCreated?: number;
numUpdated?: number;
Expand Down Expand Up @@ -64,6 +52,12 @@ interface TableRow {
accepted: boolean;
}

const useStyles = makeStyles()(() => ({
uploadsSection: {
marginTop: '66px',
},
}));

const UploadsTable = () => {
// eslint-disable-next-line
const tableRef = useRef<any>(null);
Expand All @@ -72,16 +66,19 @@ const UploadsTable = () => {
const [error, setError] = useState('');
const [pageSize, setPageSize] = useState(10);

const { classes } = useStyles();

return (
<div>
<Paper>
<Paper className={classes?.uploadsSection}>
{error && (
<Alert variant="filled" severity="error">
{error}
</Alert>
)}
<MaterialTable
tableRef={tableRef}
title={<Typography>Uploads</Typography>}
columns={[
{
title: 'ID',
Expand Down Expand Up @@ -203,15 +200,6 @@ const UploadsTable = () => {
Container: (props): JSX.Element => (
<Paper elevation={0} {...props}></Paper>
),
Pagination: (props): JSX.Element => {
return (
<TablePaginationBar>
<Typography>Uploads</Typography>
<Spacer />
<TablePagination {...props} />
</TablePaginationBar>
);
},
}}
style={{ fontFamily: 'Inter' }}
options={{
Expand All @@ -225,8 +213,7 @@ const UploadsTable = () => {
draggable: false, // No need to be able to drag and drop headers.
pageSize: pageSize,
pageSizeOptions: [5, 10, 20, 50, 100],
paginationPosition: 'top',
toolbar: false,
paginationPosition: 'bottom',
maxBodyHeight: 'calc(100vh - 15em)',
headerStyle: {
zIndex: 1,
Expand Down
22 changes: 8 additions & 14 deletions verification/curator-service/ui/src/components/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
DialogTitle,
Menu,
Paper,
TablePagination,
Typography,
FormControl,
MenuItem,
Expand Down Expand Up @@ -67,6 +66,9 @@ const useStyles = makeStyles()((theme: Theme) => ({
display: 'flex',
height: '64px',
},
usersSection: {
marginTop: '66px',
},
}));

const rowMenuStyles = makeStyles()((theme: Theme) => ({
Expand Down Expand Up @@ -284,7 +286,7 @@ const Users = ({ onUserChange }: UsersProps) => {
};

return (
<Paper>
<Paper className={classes?.usersSection}>
{error && (
<MuiAlert
classes={{ root: classes.alert }}
Expand All @@ -296,6 +298,7 @@ const Users = ({ onUserChange }: UsersProps) => {
)}
<MaterialTable
tableRef={tableRef}
title={<Typography>Users</Typography>}
columns={[
...((user?.roles ?? []).includes(Role.Admin)
? [
Expand Down Expand Up @@ -390,30 +393,21 @@ const Users = ({ onUserChange }: UsersProps) => {
Container: (props): JSX.Element => (
<Paper elevation={0} {...props}></Paper>
),
Pagination: (props): JSX.Element => {
return (
<div className={classes.tablePaginationBar}>
<Typography>Users</Typography>
<span className={classes.spacer}></span>
<TablePagination {...props}></TablePagination>
</div>
);
},
}}
style={{ fontFamily: 'Inter' }}
options={{
search: false,
filtering: false,
sorting: false,
padding: 'dense',
draggable: false, // No need to be able to drag and drop headers.
pageSize: pageSize,
pageSizeOptions: [5, 10, 20, 50, 100],
paginationPosition: 'top',
toolbar: false,
paginationPosition: 'bottom',
// toolbar: false,
headerStyle: {
zIndex: 1,
},
emptyRowsWhenPaging: false,
}}
onRowsPerPageChange={(newPageSize: number) => {
setPageSize(newPageSize);
Expand Down

0 comments on commit f22653b

Please sign in to comment.