80 lines
2.0 KiB
JavaScript
80 lines
2.0 KiB
JavaScript
import React from 'react'
|
|
import { useDispatch } from 'react-redux'
|
|
import {
|
|
Button,
|
|
sanitizeListRestProps,
|
|
TopToolbar,
|
|
useTranslate,
|
|
} from 'react-admin'
|
|
import PlayArrowIcon from '@material-ui/icons/PlayArrow'
|
|
import ShuffleIcon from '@material-ui/icons/Shuffle'
|
|
import CloudDownloadOutlinedIcon from '@material-ui/icons/CloudDownloadOutlined'
|
|
import AddToQueueIcon from '@material-ui/icons/AddToQueue'
|
|
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
|
|
import subsonic from '../subsonic'
|
|
|
|
const AlbumActions = ({
|
|
albumId,
|
|
className,
|
|
ids,
|
|
data,
|
|
exporter,
|
|
permanentFilter,
|
|
...rest
|
|
}) => {
|
|
const dispatch = useDispatch()
|
|
const translate = useTranslate()
|
|
|
|
const handlePlay = React.useCallback(() => {
|
|
dispatch(playTracks(data, ids))
|
|
}, [dispatch, data, ids])
|
|
|
|
const handlePlayLater = React.useCallback(() => {
|
|
dispatch(addTracks(data, ids))
|
|
}, [dispatch, data, ids])
|
|
|
|
const handleShuffle = React.useCallback(() => {
|
|
dispatch(shuffleTracks(data, ids))
|
|
}, [dispatch, data, ids])
|
|
|
|
const handleDownload = React.useCallback(() => {
|
|
subsonic.download(albumId)
|
|
}, [albumId])
|
|
|
|
return (
|
|
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
|
|
<Button
|
|
onClick={handlePlay}
|
|
label={translate('resources.album.actions.playAll')}
|
|
>
|
|
<PlayArrowIcon />
|
|
</Button>
|
|
<Button
|
|
onClick={handleShuffle}
|
|
label={translate('resources.album.actions.shuffle')}
|
|
>
|
|
<ShuffleIcon />
|
|
</Button>
|
|
<Button
|
|
onClick={handlePlayLater}
|
|
label={translate('resources.album.actions.addToQueue')}
|
|
>
|
|
<AddToQueueIcon />
|
|
</Button>
|
|
<Button
|
|
onClick={handleDownload}
|
|
label={translate('resources.album.actions.download')}
|
|
>
|
|
<CloudDownloadOutlinedIcon />
|
|
</Button>
|
|
</TopToolbar>
|
|
)
|
|
}
|
|
|
|
AlbumActions.defaultProps = {
|
|
selectedIds: [],
|
|
onUnselectItems: () => null,
|
|
}
|
|
|
|
export default AlbumActions
|