Skip to content

Commit

Permalink
Front-end Clean-up (#1239)
Browse files Browse the repository at this point in the history
Front-end clean-up on the following interfaces:

* Taxonomy Displays
* Project team members list (autocomplete)
* Project List Page filters
* General Layout Updates / Formatting

---------

Co-authored-by: Nick Phura <[email protected]>
Co-authored-by: Alfred Rosenthal <[email protected]>
  • Loading branch information
3 people authored Mar 13, 2024
1 parent decf49e commit ce20bbb
Show file tree
Hide file tree
Showing 34 changed files with 453 additions and 576 deletions.
6 changes: 3 additions & 3 deletions app/src/components/boundary/InferredLocationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const InferredLocationDetails = (props: IInferredLocationDetailsProps) => {
<Typography component="dt">
{type} ({layerNames.length})
</Typography>
<Box>
<Typography component="dd">
{layerNames.map((name: string, index: number) => (
<Typography
key={name}
component="dd"
component="span"
sx={{
display: 'inline-block',
mr: '5px'
Expand All @@ -36,7 +36,7 @@ const InferredLocationDetails = (props: IInferredLocationDetailsProps) => {
{index < layerNames.length - 1 && ', '}
</Typography>
))}
</Box>
</Typography>
</Box>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ const TaxonomyDataGridEditCell = <DataGridType extends GridValidRowModel, ValueT
const response = await biohubApi.taxonomy.searchSpeciesByTerms([searchTerm]);
const options = response.map((item) => ({
value: item.tsn as ValueType,
label: item.scientificName,
subtext: item.commonName || undefined
label: item.commonName ? `${item.commonName} (${item.scientificName})` : item.scientificName
}));
onSearchResults(options);
},
Expand Down
5 changes: 1 addition & 4 deletions app/src/components/layout/PageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Box from '@mui/material/Box';
import { grey } from '@mui/material/colors';
import Container from '@mui/material/Container';
import Paper from '@mui/material/Paper';
import Stack from '@mui/material/Stack';
Expand All @@ -21,14 +20,12 @@ const PageHeader = (props: IPageHeader) => {

return (
<Paper
elevation={0}
square={true}
id="pageTitle"
sx={{
position: { sm: 'relative', lg: 'sticky' },
top: 0,
zIndex: 1002,
borderBottom: '1px solid' + grey[300]
zIndex: 1002
}}>
<Container maxWidth={'xl'} sx={{ py: { xs: 2, sm: 3 } }}>
{breadCrumbJSX}
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/search-filter/ProjectAdvancedFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ const ProjectAdvancedFilters = () => {
<Grid item xs={12}>
<CustomTextField name="keyword" label="Keyword (or any portion of any word)" />
</Grid>
<Grid item xs={12} md={6}>
<Grid item xs={12} md={4}>
<CustomTextField name="project_name" label="Project Name" />
</Grid>
<Grid item xs={12} md={6}>
<Grid item xs={12} md={4}>
<MultiAutocompleteFieldVariableSize
id="itis_tsns"
label="Species"
Expand Down
2 changes: 1 addition & 1 deletion app/src/features/admin/users/AccessRequestList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const AccessRequestList: React.FC<IAccessRequestListProps> = (props) => {
)
}}
/>
<Paper elevation={0}>
<Paper>
<Toolbar>
<Typography variant="h4" component="h2">
Access Requests{' '}
Expand Down
2 changes: 1 addition & 1 deletion app/src/features/admin/users/ActiveUsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const ActiveUsersList: React.FC<IActiveUsersListProps> = (props) => {

return (
<>
<Paper elevation={0}>
<Paper>
<Toolbar style={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="h4" component="h2">
Active Users{' '}
Expand Down
24 changes: 11 additions & 13 deletions app/src/features/admin/users/ManageUsersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,17 @@ const ManageUsersPage: React.FC = () => {
return (
<>
<PageHeader title="Manage Users" />
<Container maxWidth="xl">
<Box py={3}>
<AccessRequestList
accessRequests={accessRequests}
codes={codes}
refresh={() => {
refreshAccessRequests();
refreshActiveUsers();
}}
/>
<Box mt={3}>
<ActiveUsersList activeUsers={activeUsers} codes={codes} refresh={refreshActiveUsers} />
</Box>
<Container maxWidth="xl" sx={{ py: 3 }}>
<AccessRequestList
accessRequests={accessRequests}
codes={codes}
refresh={() => {
refreshAccessRequests();
refreshActiveUsers();
}}
/>
<Box mt={3}>
<ActiveUsersList activeUsers={activeUsers} codes={codes} refresh={refreshActiveUsers} />
</Box>
</Container>
</>
Expand Down
7 changes: 2 additions & 5 deletions app/src/features/admin/users/UsersDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Box from '@mui/material/Box';
import CircularProgress from '@mui/material/CircularProgress';
import Container from '@mui/material/Container';
import React, { useEffect, useState } from 'react';
Expand Down Expand Up @@ -41,10 +40,8 @@ const UsersDetailPage: React.FC = () => {
<>
<UsersDetailHeader userDetails={selectedUser} />

<Container maxWidth="xl">
<Box my={3}>
<UsersDetailProjects userDetails={selectedUser} />
</Box>
<Container maxWidth="xl" sx={{ py: 3 }}>
<UsersDetailProjects userDetails={selectedUser} />
</Container>
</>
);
Expand Down
30 changes: 3 additions & 27 deletions app/src/features/admin/users/UsersDetailProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import { makeStyles } from '@mui/styles';
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { useParams } from 'react-router';
import { Link as RouterLink } from 'react-router-dom';
Expand All @@ -28,28 +27,6 @@ import { CodeSet, IGetAllCodeSetsResponse } from '../../../interfaces/useCodesAp
import { IGetUserProjectsListResponse } from '../../../interfaces/useProjectApi.interface';
import { ISystemUser } from '../../../interfaces/useUserApi.interface';

const useStyles = makeStyles(() => ({
actionButton: {
minWidth: '6rem',
'& + button': {
marginLeft: '0.5rem'
}
},
projectMembersTable: {
tableLayout: 'fixed',
'& td': {
verticalAlign: 'middle'
}
},
toolbarCount: {
fontWeight: 400
},
linkButton: {
textAlign: 'left',
fontWeight: 700
}
}));

export interface IProjectDetailsProps {
userDetails: ISystemUser;
}
Expand All @@ -64,7 +41,6 @@ const UsersDetailProjects: React.FC<IProjectDetailsProps> = (props) => {
const urlParams = useParams();
const biohubApi = useBiohubApi();
const dialogContext = useContext(DialogContext);
const classes = useStyles();

const [codes, setCodes] = useState<IGetAllCodeSetsResponse>();
const [isLoadingCodes, setIsLoadingCodes] = useState(true);
Expand Down Expand Up @@ -177,18 +153,18 @@ const UsersDetailProjects: React.FC<IProjectDetailsProps> = (props) => {
}

return (
<Paper elevation={0}>
<Paper>
<Toolbar>
<Typography data-testid="projects_header" variant="h4" component="h2">
Assigned Projects &zwnj;
<Typography className={classes.toolbarCount} component="span" variant="inherit" color="textSecondary">
<Typography component="span" variant="inherit" color="textSecondary">
({assignedProjects?.length})
</Typography>
</Typography>
</Toolbar>
<Divider></Divider>
<Box p={2}>
<Table className={classes.projectMembersTable}>
<Table sx={{ tableLayout: 'fixed' }}>
<TableHead>
<TableRow>
<TableCell>Project Name</TableCell>
Expand Down
66 changes: 32 additions & 34 deletions app/src/features/funding-sources/list/FundingSourcesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,41 +110,39 @@ const FundingSourcesListPage: React.FC = () => {
}
/>

<Container maxWidth="xl">
<Box py={3}>
<Paper elevation={0}>
<Toolbar style={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="h4" component="h2" data-testid="funding-source-list-found">
Records Found &zwnj;
<Typography
component="span"
color="textSecondary"
lineHeight="inherit"
fontSize="inherit"
fontWeight={400}>
({Number(fundingSourceDataLoader.data?.length ?? 0).toLocaleString()})
</Typography>
<Container maxWidth="xl" sx={{ py: 3 }}>
<Paper>
<Toolbar style={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="h4" component="h2" data-testid="funding-source-list-found">
Records Found &zwnj;
<Typography
component="span"
color="textSecondary"
lineHeight="inherit"
fontSize="inherit"
fontWeight={400}>
({Number(fundingSourceDataLoader.data?.length ?? 0).toLocaleString()})
</Typography>
</Toolbar>
<Divider></Divider>
<Box p={2}>
<FundingSourcesTable
fundingSources={fundingSourceDataLoader.data ?? []}
onView={(fundingSourceId) => {
openViewModal(fundingSourceId);
}}
onEdit={(fundingSourceId) => {
setFundingSourceId(fundingSourceId);
setIsEditModalOpen(true);
}}
onDelete={(fundingSourceId) => {
setFundingSourceId(fundingSourceId);
setIsDeleteModalOpen(true);
}}
/>
</Box>
</Paper>
</Box>
</Typography>
</Toolbar>
<Divider></Divider>
<Box p={2}>
<FundingSourcesTable
fundingSources={fundingSourceDataLoader.data ?? []}
onView={(fundingSourceId) => {
openViewModal(fundingSourceId);
}}
onEdit={(fundingSourceId) => {
setFundingSourceId(fundingSourceId);
setIsEditModalOpen(true);
}}
onDelete={(fundingSourceId) => {
setFundingSourceId(fundingSourceId);
setIsDeleteModalOpen(true);
}}
/>
</Box>
</Paper>
</Container>
</>
);
Expand Down
25 changes: 18 additions & 7 deletions app/src/features/projects/components/ProjectUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
import Box from '@mui/material/Box';
import CircularProgress from '@mui/material/CircularProgress';
import Collapse from '@mui/material/Collapse';
import grey from '@mui/material/colors/grey';
import TextField from '@mui/material/TextField';
import Typography from '@mui/material/Typography';
import AlertBar from 'components/alert/AlertBar';
Expand Down Expand Up @@ -204,13 +205,23 @@ const ProjectUserForm = (props: IProjectUserFormProps) => {
)}
renderOption={(renderProps, renderOption) => {
return (
<Box component="li" {...renderProps} key={renderOption.system_user_id}>
<UserCard
name={renderOption.display_name}
email={renderOption.email}
agency={renderOption.agency}
type={renderOption.identity_source}
/>
<Box
component="li"
sx={{
'& + li': {
borderTop: '1px solid' + grey[300]
}
}}
key={renderOption.system_user_id}
{...renderProps}>
<Box py={0.5} width="100%">
<UserCard
name={renderOption.display_name}
email={renderOption.email}
agency={renderOption.agency}
type={renderOption.identity_source}
/>
</Box>
</Box>
);
}}
Expand Down
47 changes: 22 additions & 25 deletions app/src/features/projects/create/CreateProjectPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LoadingButton } from '@mui/lab';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import CircularProgress from '@mui/material/CircularProgress';
import Container from '@mui/material/Container';
Expand Down Expand Up @@ -197,30 +196,28 @@ const CreateProjectPage = () => {
}
/>

<Container maxWidth="xl">
<Box py={3}>
<Paper elevation={0} sx={{ p: 5 }}>
<EditProjectForm
initialProjectData={initialProjectData}
handleSubmit={(formikData) => createProject(formikData as ICreateProjectRequest)}
formikRef={formikRef as unknown as React.RefObject<FormikProps<IUpdateProjectRequest>>}
/>
<Stack mt={4} flexDirection="row" justifyContent="flex-end" gap={1}>
<LoadingButton
loading={isSaving}
type="submit"
color="primary"
variant="contained"
onClick={() => formikRef.current?.submitForm()}
data-testid="submit-project-button">
Save and Exit
</LoadingButton>
<Button disabled={isSaving} color="primary" variant="outlined" onClick={handleCancel}>
Cancel
</Button>
</Stack>
</Paper>
</Box>
<Container maxWidth="xl" sx={{ py: 3 }}>
<Paper sx={{ p: 5 }}>
<EditProjectForm
initialProjectData={initialProjectData}
handleSubmit={(formikData) => createProject(formikData as ICreateProjectRequest)}
formikRef={formikRef as unknown as React.RefObject<FormikProps<IUpdateProjectRequest>>}
/>
<Stack mt={4} flexDirection="row" justifyContent="flex-end" gap={1}>
<LoadingButton
loading={isSaving}
type="submit"
color="primary"
variant="contained"
onClick={() => formikRef.current?.submitForm()}
data-testid="submit-project-button">
Save and Exit
</LoadingButton>
<Button disabled={isSaving} color="primary" variant="outlined" onClick={handleCancel}>
Cancel
</Button>
</Stack>
</Paper>
</Container>
</>
);
Expand Down
Loading

0 comments on commit ce20bbb

Please sign in to comment.