fixed compile errors
This commit is contained in:
committed by
Deluan Quintão
parent
e6d4cfba96
commit
eb7d2dcaa1
@@ -1,27 +1,27 @@
|
|||||||
import React, {useState} from 'react'
|
import React, { useState } from 'react'
|
||||||
import IconButton from '@material-ui/core/IconButton'
|
import IconButton from '@material-ui/core/IconButton'
|
||||||
import Menu from '@material-ui/core/Menu'
|
import Menu from '@material-ui/core/Menu'
|
||||||
import MenuItem from '@material-ui/core/MenuItem'
|
import MenuItem from '@material-ui/core/MenuItem'
|
||||||
import MoreVertIcon from '@material-ui/icons/MoreVert'
|
import MoreVertIcon from '@material-ui/icons/MoreVert'
|
||||||
import { useDataProvider, useTranslate } from 'react-admin';
|
import { useDataProvider, useTranslate } from 'react-admin'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import { playAlbum, shuffleAlbum } from '../audioplayer'
|
import { playAlbum, shuffleAlbum } from '../audioplayer'
|
||||||
|
|
||||||
const AlbumContextMenu = (props) => {
|
const AlbumContextMenu = (props) => {
|
||||||
const dataProvider = useDataProvider();
|
const dataProvider = useDataProvider()
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
const [anchorEl, setAnchorEl] = useState(null)
|
const [anchorEl, setAnchorEl] = useState(null)
|
||||||
const open = Boolean(anchorEl)
|
const open = Boolean(anchorEl)
|
||||||
const options = {
|
const options = {
|
||||||
play: {
|
play: {
|
||||||
label: translate('resources.album.actions.playAll'),
|
label: translate('resources.album.actions.playAll'),
|
||||||
action: (data, id) => (playAlbum(id, data))
|
action: (data, id) => playAlbum(id, data),
|
||||||
},
|
},
|
||||||
shuffle: {
|
shuffle: {
|
||||||
label: translate('resources.album.actions.shuffle'),
|
label: translate('resources.album.actions.shuffle'),
|
||||||
action: (data) => (shuffleAlbum(data))
|
action: (data) => shuffleAlbum(data),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClick = (e) => {
|
const handleClick = (e) => {
|
||||||
@@ -37,15 +37,20 @@ const AlbumContextMenu = (props) => {
|
|||||||
const handleItemClick = (e) => {
|
const handleItemClick = (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setAnchorEl(null)
|
setAnchorEl(null)
|
||||||
const key = e.target.getAttribute('value')
|
const key = e.target.getAttribute('value')
|
||||||
dataProvider.getList('albumSong', {
|
dataProvider
|
||||||
pagination: { page: 0, perPage: 1000 },
|
.getList('albumSong', {
|
||||||
sort: { field: 'trackNumber', order: 'ASC' },
|
pagination: { page: 0, perPage: 1000 },
|
||||||
filter: { album_id: props.id },
|
sort: { field: 'trackNumber', order: 'ASC' },
|
||||||
}).then((response) => {
|
filter: { album_id: props.id },
|
||||||
const adata = (response.data).reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {})
|
})
|
||||||
dispatch(options[key].action(adata, response.data[0].id))
|
.then((response) => {
|
||||||
})
|
const adata = response.data.reduce(
|
||||||
|
(acc, cur) => ({ ...acc, [cur.id]: cur }),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
dispatch(options[key].action(adata, response.data[0].id))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -63,7 +68,7 @@ const AlbumContextMenu = (props) => {
|
|||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
keepMounted
|
keepMounted
|
||||||
open={open}
|
open={open}
|
||||||
onClose={handleOnClose}
|
onClose={handleOnClose}
|
||||||
>
|
>
|
||||||
{Object.keys(options).map((key) => (
|
{Object.keys(options).map((key) => (
|
||||||
<MenuItem value={key} key={key} onClick={handleItemClick}>
|
<MenuItem value={key} key={key} onClick={handleItemClick}>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
|
|||||||
import { linkToRecord, Loading } from 'react-admin'
|
import { linkToRecord, Loading } from 'react-admin'
|
||||||
import subsonic from '../subsonic'
|
import subsonic from '../subsonic'
|
||||||
import { ArtistLinkField } from './ArtistLinkField'
|
import { ArtistLinkField } from './ArtistLinkField'
|
||||||
import GridMenu from './GridMenu.js'
|
import AlbumContextMenu from './AlbumContextMenu.js'
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -81,7 +81,7 @@ const LoadedAlbumGrid = ({ ids, data, basePath, width }) => {
|
|||||||
</ArtistLinkField>
|
</ArtistLinkField>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
actionIcon={<GridMenu id={id} />}
|
actionIcon={<AlbumContextMenu id={id} />}
|
||||||
/>
|
/>
|
||||||
</GridListTile>
|
</GridListTile>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user