Remove duplicated code for SongBulkActions

This commit is contained in:
Deluan
2020-10-31 10:23:52 -04:00
parent aabef62b11
commit 1f842b08e2
7 changed files with 26 additions and 36 deletions
+40
View File
@@ -0,0 +1,40 @@
import React, { Fragment, useEffect } from 'react'
import { useUnselectAll } from 'react-admin'
import { addTracks, playNext, playTracks } from '../audioplayer'
import { RiPlayList2Fill, RiPlayListAddFill } from 'react-icons/ri'
import PlayArrowIcon from '@material-ui/icons/PlayArrow'
import { BatchPlayButton } from './index'
import AddToPlaylistButton from './AddToPlaylistButton'
const SongBulkActions = (props) => {
const unselectAll = useUnselectAll()
useEffect(() => {
unselectAll(props.resource)
// eslint-disable-next-line
}, [])
return (
<Fragment>
<BatchPlayButton
{...props}
action={playTracks}
label={'resources.song.actions.playNow'}
icon={<PlayArrowIcon />}
/>
<BatchPlayButton
{...props}
action={playNext}
label={'resources.song.actions.playNext'}
icon={<RiPlayList2Fill />}
/>
<BatchPlayButton
{...props}
action={addTracks}
label={'resources.song.actions.addToQueue'}
icon={<RiPlayListAddFill />}
/>
<AddToPlaylistButton {...props} />
</Fragment>
)
}
export default SongBulkActions