Alwasy show context menu on mobile views

This commit is contained in:
Deluan
2020-05-22 21:47:48 -04:00
parent 52a46e61e0
commit 0a3e6c66c1
3 changed files with 40 additions and 15 deletions
+1
View File
@@ -124,6 +124,7 @@ const AlbumSongs = (props) => {
{...controllerProps}
hasBulkActions={hasBulkActions}
multiDisc={multiDisc}
contextVisible={isXsmall}
>
{isDesktop && (
<TextField
+29 -8
View File
@@ -2,9 +2,14 @@ import React, { useState, isValidElement, cloneElement } from 'react'
import { Datagrid, DatagridBody, DatagridRow, useTranslate } from 'react-admin'
import { TableCell, TableRow, Typography } from '@material-ui/core'
import PropTypes from 'prop-types'
import RangeField from './RangeField'
export const SongDatagridRow = ({ record, children, multiDisc, ...rest }) => {
export const SongDatagridRow = ({
record,
children,
multiDisc,
contextVisible,
...rest
}) => {
const translate = useTranslate()
const [visible, setVisible] = useState(false)
return (
@@ -37,7 +42,10 @@ export const SongDatagridRow = ({ record, children, multiDisc, ...rest }) => {
child &&
isValidElement(child) &&
child.type.name === 'SongContextMenu'
? cloneElement(child, { visible, ...rest })
? cloneElement(child, {
visible: contextVisible || visible,
...rest,
})
: child
)}
</DatagridRow>
@@ -45,16 +53,29 @@ export const SongDatagridRow = ({ record, children, multiDisc, ...rest }) => {
)
}
RangeField.propTypes = {
SongDatagridRow.propTypes = {
record: PropTypes.object,
children: PropTypes.node,
multiDisc: PropTypes.bool,
contextVisible: PropTypes.bool,
}
export const SongDatagrid = (props) => {
const multiDisc = props.multiDisc
export const SongDatagrid = ({ multiDisc, contextVisible, ...rest }) => {
const SongDatagridBody = (props) => (
<DatagridBody {...props} row={<SongDatagridRow multiDisc={multiDisc} />} />
<DatagridBody
{...props}
row={
<SongDatagridRow
multiDisc={multiDisc}
contextVisible={contextVisible}
/>
}
/>
)
return <Datagrid {...props} body={<SongDatagridBody />} />
return <Datagrid {...rest} body={<SongDatagridBody />} />
}
SongDatagrid.propTypes = {
contextVisible: PropTypes.bool,
multiDisc: PropTypes.bool,
}
+10 -7
View File
@@ -55,13 +55,6 @@ const useStylesListToolbar = makeStyles({
},
})
const SongsDatagridBody = (props) => (
<DatagridBody {...props} row={<SongDatagridRow />} />
)
const SongsDatagrid = (props) => (
<Datagrid {...props} body={<SongsDatagridBody />} />
)
const PlaylistSongs = (props) => {
const classes = useStyles(props)
const classesToolbar = useStylesListToolbar(props)
@@ -86,6 +79,16 @@ const PlaylistSongs = (props) => {
}
}
const SongsDatagridBody = (props) => (
<DatagridBody
{...props}
row={<SongDatagridRow contextVisible={isXsmall} />}
/>
)
const SongsDatagrid = (props) => (
<Datagrid {...props} body={<SongsDatagridBody />} />
)
return (
<>
<ListToolbar