mirror of
https://github.com/navidrome/navidrome.git
synced 2025-08-10 00:52:20 +00:00
Remove duplicated code for SongBulkActions
This commit is contained in:
31
ui/src/common/AddToPlaylistButton.js
Normal file
31
ui/src/common/AddToPlaylistButton.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
Reference in New Issue
Block a user