Remove duplicated code for SongBulkActions
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
import React from 'react'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { Button, useTranslate, useUnselectAll } from 'react-admin'
|
||||
import PlaylistAddIcon from '@material-ui/icons/PlaylistAdd'
|
||||
import { openAddToPlaylist } from '../dialogs/dialogState'
|
||||
|
||||
const AddToPlaylistButton = ({ resource, selectedIds }) => {
|
||||
const translate = useTranslate()
|
||||
const dispatch = useDispatch()
|
||||
const unselectAll = useUnselectAll()
|
||||
|
||||
const handleClick = () => {
|
||||
dispatch(
|
||||
openAddToPlaylist({ selectedIds, onSuccess: () => unselectAll(resource) })
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
aria-controls="simple-menu"
|
||||
aria-haspopup="true"
|
||||
onClick={handleClick}
|
||||
color="secondary"
|
||||
label={translate('resources.song.actions.addToPlaylist')}
|
||||
>
|
||||
<PlaylistAddIcon />
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
export default AddToPlaylistButton
|
||||
@@ -1,20 +0,0 @@
|
||||
import React, { Fragment } from 'react'
|
||||
import { BatchPlayButton } from '../common'
|
||||
import AddToPlaylistButton from './AddToPlaylistButton'
|
||||
import { RiPlayList2Fill } from 'react-icons/ri'
|
||||
import { playNext } from '../audioplayer'
|
||||
|
||||
export const SongBulkActions = (props) => {
|
||||
return (
|
||||
<Fragment>
|
||||
<BatchPlayButton
|
||||
{...props}
|
||||
action={playNext}
|
||||
label={'resources.song.actions.playNext'}
|
||||
icon={<RiPlayList2Fill />}
|
||||
/>
|
||||
<BatchPlayButton {...props} />
|
||||
<AddToPlaylistButton {...props} />
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from '../common'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { setTrack } from '../audioplayer'
|
||||
import { SongBulkActions } from './SongBulkActions'
|
||||
import { SongBulkActions } from '../common'
|
||||
import { SongListActions } from './SongListActions'
|
||||
import { AlbumLinkField } from './AlbumLinkField'
|
||||
import AddToPlaylistDialog from '../dialogs/AddToPlaylistDialog'
|
||||
|
||||
Reference in New Issue
Block a user