quintodrome/ui/src/common/AddToPlaylistButton.js

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

32 lines
849 B
JavaScript
Raw Normal View History

import React from 'react'
import { useDispatch } from 'react-redux'
import { Button, useTranslate, useUnselectAll } from 'react-admin'
2020-05-15 16:47:15 -08:00
import PlaylistAddIcon from '@material-ui/icons/PlaylistAdd'
import { openAddToPlaylist } from '../dialogs/dialogState'
2020-05-15 16:47:15 -08:00
2020-10-31 06:12:38 -08:00
const AddToPlaylistButton = ({ resource, selectedIds }) => {
2020-05-15 16:47:15 -08:00
const translate = useTranslate()
const dispatch = useDispatch()
2020-05-15 16:47:15 -08:00
const unselectAll = useUnselectAll()
const handleClick = () => {
dispatch(
openAddToPlaylist({ selectedIds, onSuccess: () => unselectAll(resource) })
)
2020-05-15 16:47:15 -08:00
}
return (
<Button
aria-controls="simple-menu"
aria-haspopup="true"
onClick={handleClick}
color="secondary"
label={translate('resources.song.actions.addToPlaylist')}
>
<PlaylistAddIcon />
</Button>
2020-05-15 16:47:15 -08:00
)
}
export default AddToPlaylistButton