quintodrome/ui/src/album/AlbumActions.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
2 KiB
JavaScript
Raw Normal View History

2020-08-21 09:28:20 -08:00
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'
2020-05-15 09:48:33 -08:00
const AlbumActions = ({
albumId,
className,
ids,
data,
exporter,
permanentFilter,
...rest
}) => {
const dispatch = useDispatch()
const translate = useTranslate()
2020-09-06 07:44:15 -08:00
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
2020-09-06 07:44:15 -08:00
onClick={handlePlay}
label={translate('resources.album.actions.playAll')}
>
<PlayArrowIcon />
</Button>
<Button
2020-09-06 07:44:15 -08:00
onClick={handleShuffle}
label={translate('resources.album.actions.shuffle')}
>
<ShuffleIcon />
</Button>
<Button
2020-09-06 07:44:15 -08:00
onClick={handlePlayLater}
label={translate('resources.album.actions.addToQueue')}
>
2020-09-06 07:44:15 -08:00
<AddToQueueIcon />
</Button>
<Button
2020-09-06 07:44:15 -08:00
onClick={handleDownload}
label={translate('resources.album.actions.download')}
>
2020-09-06 07:44:15 -08:00
<CloudDownloadOutlinedIcon />
</Button>
</TopToolbar>
)
}
AlbumActions.defaultProps = {
selectedIds: [],
onUnselectItems: () => null,
}
2020-05-15 09:48:33 -08:00
export default AlbumActions