Skip to content

Commit

Permalink
418 FE deps update fix UI bugs and unmerging issue (#422)
Browse files Browse the repository at this point in the history
* 418 FE deps update fix UI bugs and unmerging issue

* codacy issue: restore newlines

* simplify Alert component (linting)
  • Loading branch information
jaydonkrooss committed Mar 26, 2024
1 parent c7c79b1 commit f3ef65e
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 140 deletions.
46 changes: 17 additions & 29 deletions ccm_web/client/src/components/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,29 @@ import React from 'react'
import { styled } from '@mui/material/styles'
import { Grid, Paper, Typography } from '@mui/material'

const PREFIX = 'Alert'
const StyledGrid = styled(Grid)(() => ({
margin: 'auto'

const classes = {
padding: `${PREFIX}-padding`,
standalone: `${PREFIX}-standalone`,
dialog: `${PREFIX}-dialog`
}
}))

const StyledGrid = styled(Grid)((
const StyledCorePaper = styled(Paper)((
{
theme
}
) => ({
[`& .${classes.padding}`]: {
padding: theme.spacing(1)
},

[`&.${classes.standalone}`]: {
textAlign: 'center',
padding: theme.spacing(1),
margin: 'auto',
marginTop: 30,
marginBottom: 15,
'& ol': {
margin: 'auto'
},

[`& .${classes.dialog}`]: {
textAlign: 'center',
margin: 'auto',
marginTop: 30,
marginBottom: 15,
'& ol': {
margin: 'auto'
},
'& li': {
textAlign: 'left',
marginBottom: 10
}
'& li': {
textAlign: 'left',
marginBottom: 10
}
}))
}));

interface AlertProps {
children: React.ReactNode
Expand All @@ -49,16 +37,16 @@ export default function Alert (props: AlertProps): JSX.Element {
const { title, icon, embedded, children } = props

const core = (
<Paper className={`${classes.dialog} ${classes.padding}`} role='alert'>
<StyledCorePaper role='alert'>
<Typography gutterBottom>{title}</Typography>
{icon}
{children}
</Paper>
</StyledCorePaper>
)

if (embedded === true) return core
return (
<StyledGrid item xs={12} sm={9} md={6} className={classes.standalone}>
<StyledGrid item xs={12} sm={9} md={6}>
{core}
</StyledGrid>
)
Expand Down
4 changes: 0 additions & 4 deletions ccm_web/client/src/components/CustomTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ function CustomTable<T extends TableEntity> (props: TableProps<T>): JSX.Element
count={tableRows.length}
rowsPerPage={rowsPerPage}
page={page}
SelectProps={{
inputProps: { 'aria-label': 'rows per page' },
native: true
}}
onPageChange={handleChangePage}
ActionsComponent={TablePaginationActions}
aria-live='polite'
Expand Down
10 changes: 5 additions & 5 deletions ccm_web/client/src/components/ErrorAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const classes = {
dialogIcon: `${PREFIX}-dialogIcon`
}

const StyledAlert = styled(Alert)((
const StyledErrorIcon = styled(ErrorIcon)((
{
theme
}
) => ({
[`& .${classes.dialogIcon}`]: {
[`&.${classes.dialogIcon}`]: {
color: theme.palette.error.main
}
}))
Expand All @@ -42,14 +42,14 @@ export default function ErrorAlert (props: ErrorAlertProps): JSX.Element {
: <ol>{messages.map((m, i) => <li key={i}>{m}</li>)}</ol>

return (
<StyledAlert
<Alert
title={title !== undefined ? title : 'Some errors occurred'}
icon={icon !== undefined ? icon : <ErrorIcon className={classes.dialogIcon} fontSize='large' />}
icon={icon !== undefined ? icon : <StyledErrorIcon className={classes.dialogIcon} fontSize='large' />}
embedded={embedded}
>
{Boolean(messages?.length) && preface}
{messageBlock}
{tryAgain !== undefined && <Button color='primary' onClick={props.tryAgain}>Try Again</Button>}
</StyledAlert>
</Alert>
)
}
3 changes: 2 additions & 1 deletion ccm_web/client/src/components/InlineTextEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function InlineTextEdit (props: InlineTextEditProps): JSX.Element {
<Grid item md={9} sm={7} xs={7}>
<TextField
className={classes.buttonSep}
variant='standard'
aria-readonly={false}
onClick={toggleEdit}
fullWidth={true}
Expand Down Expand Up @@ -149,7 +150,7 @@ function InlineTextEdit (props: InlineTextEditProps): JSX.Element {
)
: (
<>
<Typography className={classes.buttonSep} variant='inherit'>{props.text}</Typography>
<Typography className={classes.buttonSep} variant='inherit' component="span">{props.text}</Typography>
<Button onClick={toggleEdit} disabled={props.isSaving} aria-label='Edit course name'>
<EditIcon className={classes.editIcon} style={{ fontSize: props.fontSize }} />
</Button>
Expand Down
19 changes: 12 additions & 7 deletions ccm_web/client/src/components/SectionSelectorWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Root = styled('div')((
[`& .${classes.listContainer}`]: {
overflow: 'auto',
marginBottom: '5px',
'&& .Mui-disabled': {
'& .Mui-disabled': {
opacity: 1,
'& > .MuiListItemAvatar-root': {
opacity: theme.palette.action.disabledOpacity
Expand All @@ -85,7 +85,12 @@ const Root = styled('div')((

[`& .${classes.listItemRoot}`]: {
paddingTop: '0px',
paddingBottom: '0px'
paddingBottom: '0px',
paddingRight: '0px',
display: 'block',
'& > .MuiListItemSecondaryAction-root': {
position: 'relative',
},
},

[`& .${classes.listButton}`]: {
Expand Down Expand Up @@ -174,7 +179,8 @@ const Root = styled('div')((
},

[`& .${classes.button}`]: {
margin: theme.spacing(1)
margin: theme.spacing(1),
marginLeft: '24px'
}
}))

Expand Down Expand Up @@ -354,8 +360,8 @@ function SectionSelectorWidget (props: ISectionSelectorWidgetProps): JSX.Element

const getSearchTypeAdornment = (): JSX.Element => {
return (
<FormControl className={classes.searchEndAdnornment}>
<InputLabel id="demo-simple-select-label">Search By</InputLabel>
<FormControl variant="standard" className={classes.searchEndAdnornment}>
<InputLabel id="demo-simple-select-label">Search By</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
Expand Down Expand Up @@ -419,7 +425,6 @@ function SectionSelectorWidget (props: ISectionSelectorWidgetProps): JSX.Element
</Typography>
)
}
{unmergeButton(section)}
<span style={props.showCourseName === true ? { float: 'right' } : undefined}>
{`${section.total_students ?? '?'} students`}
</span>
Expand Down Expand Up @@ -594,7 +599,7 @@ function SectionSelectorWidget (props: ISectionSelectorWidgetProps): JSX.Element
divider
disableGutters
classes={{ root: classes.listItemRoot }}
selected={isSelected}
secondaryAction={unmergeButton(section)}
className={(section.locked !== true && props.highlightUnlocked === true) ? classes.highlighted : undefined}
>
<ButtonBase
Expand Down
2 changes: 1 addition & 1 deletion ccm_web/client/src/components/TablePagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const classes = {
}

const Root = styled('div')(({ theme }) => ({
[`& .${classes.root}`]: {
[`&.${classes.root}`]: {
flexShrink: 0,
marginLeft: theme.spacing(2.5)
}
Expand Down
1 change: 1 addition & 0 deletions ccm_web/client/src/components/WorkflowStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const StyledMUIStepper = styled(MUIStepper)((
) => ({
[`&.${classes.stepper}`]: {
textAlign: 'center',
padding: 24,
paddingTop: theme.spacing(2)
}
}))
Expand Down
2 changes: 1 addition & 1 deletion ccm_web/client/src/pages/BulkSectionCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Root = styled('div')((
theme
}
) => ({
[`& .${classes.root}`]: {
[`&.${classes.root}`]: {
textAlign: 'left'
},

Expand Down
2 changes: 1 addition & 1 deletion ccm_web/client/src/pages/FormatThirdPartyGradebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Root = styled('div')((
theme
}
) => ({
[`& .${classes.root}`]: {
[`&.${classes.root}`]: {
textAlign: 'left'
},

Expand Down
2 changes: 1 addition & 1 deletion ccm_web/client/src/pages/GradebookCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Root = styled('div')((
theme
}
) => ({
[`& .${classes.root}`]: {
[`&.${classes.root}`]: {
textAlign: 'left'
},

Expand Down
2 changes: 1 addition & 1 deletion ccm_web/client/src/pages/MergeSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Root = styled('div')((
theme
}
) => ({
[`& .${classes.root}`]: {
[`&.${classes.root}`]: {
textAlign: 'left'
},

Expand Down

0 comments on commit f3ef65e

Please sign in to comment.