Hide togglable columns when in Album Grid view mode. Fixes #2064

This commit is contained in:
Deluan 2023-01-16 15:00:33 -05:00 committed by Joe Stump
parent d6fa95655f
commit d2efc27892
No known key found for this signature in database
GPG Key ID: 29151C3EC48A0EB9
2 changed files with 9 additions and 2 deletions

View File

@ -86,6 +86,7 @@ const AlbumListActions = ({
...rest ...rest
}) => { }) => {
const isNotSmall = useMediaQuery((theme) => theme.breakpoints.up('sm')) const isNotSmall = useMediaQuery((theme) => theme.breakpoints.up('sm'))
const albumView = useSelector((state) => state.albumView)
return ( return (
<TopToolbar className={className} {...sanitizeListRestProps(rest)}> <TopToolbar className={className} {...sanitizeListRestProps(rest)}>
{filters && {filters &&
@ -97,7 +98,11 @@ const AlbumListActions = ({
context: 'button', context: 'button',
})} })}
{isNotSmall ? ( {isNotSmall ? (
<ToggleFieldsMenu resource="album" topbarComponent={AlbumViewToggler} /> <ToggleFieldsMenu
resource="album"
topbarComponent={AlbumViewToggler}
hideColumns={albumView.grid}
/>
) : ( ) : (
<AlbumViewToggler showTitle={false} /> <AlbumViewToggler showTitle={false} />
)} )}

View File

@ -30,6 +30,7 @@ const useStyles = makeStyles({
export const ToggleFieldsMenu = ({ export const ToggleFieldsMenu = ({
resource, resource,
topbarComponent: TopBarComponent, topbarComponent: TopBarComponent,
hideColumns,
}) => { }) => {
const [anchorEl, setAnchorEl] = useState(null) const [anchorEl, setAnchorEl] = useState(null)
const dispatch = useDispatch() const dispatch = useDispatch()
@ -82,7 +83,7 @@ export const ToggleFieldsMenu = ({
}} }}
> >
{TopBarComponent && <TopBarComponent />} {TopBarComponent && <TopBarComponent />}
{toggleableColumns ? ( {!hideColumns && toggleableColumns ? (
<div> <div>
<Typography className={classes.title}> <Typography className={classes.title}>
{translate('ra.toggleFieldsMenu.columnsToDisplay')} {translate('ra.toggleFieldsMenu.columnsToDisplay')}
@ -107,4 +108,5 @@ export const ToggleFieldsMenu = ({
ToggleFieldsMenu.propTypes = { ToggleFieldsMenu.propTypes = {
resource: PropTypes.string.isRequired, resource: PropTypes.string.isRequired,
topbarComponent: PropTypes.elementType, topbarComponent: PropTypes.elementType,
hideColumns: PropTypes.bool,
} }