Add context menu to playlist songs

This commit is contained in:
Deluan
2020-05-18 13:05:54 -04:00
parent 274eb805f9
commit 94e1b1f65d
4 changed files with 31 additions and 10 deletions
+10
View File
@@ -6,11 +6,13 @@ import {
ListToolbar,
TextField,
useListController,
useRefresh,
} from 'react-admin'
import classnames from 'classnames'
import { Card, useMediaQuery } from '@material-ui/core'
import { makeStyles } from '@material-ui/core/styles'
import { DurationField, SongDetails } from '../common'
import { SongContextMenu } from '../song/SongContextMenu'
const useStyles = makeStyles(
(theme) => ({
@@ -54,6 +56,7 @@ const PlaylistSongs = (props) => {
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
// const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
const controllerProps = useListController(props)
const refresh = useRefresh()
const { bulkActionButtons, expand, className, playlistId } = props
const { data, ids, version, loaded } = controllerProps
@@ -65,6 +68,12 @@ const PlaylistSongs = (props) => {
return <div />
}
const onAddToPlaylist = (playlistId) => {
if (playlistId === props.id) {
refresh()
}
}
return (
<>
<ListToolbar
@@ -106,6 +115,7 @@ const PlaylistSongs = (props) => {
<TextField source="title" sortable={false} />
<TextField source="artist" sortable={false} />
<DurationField source="duration" sortable={false} />
<SongContextMenu onAddToPlaylist={onAddToPlaylist} />
</Datagrid>
)}
</Card>