quintodrome/ui/src/playlist/PlaylistSongBulkActions.js

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

32 lines
850 B
JavaScript
Raw Normal View History

2020-05-16 14:10:08 -08:00
import React, { Fragment, useEffect } from 'react'
2020-11-26 13:00:53 -09:00
import {
BulkDeleteButton,
useUnselectAll,
ResourceContextProvider,
} from 'react-admin'
2020-05-16 14:10:08 -08:00
import PropTypes from 'prop-types'
2020-11-26 13:00:53 -09:00
// Replace original resource with "fake" one for removing tracks from playlist
const PlaylistSongBulkActions = ({ playlistId, resource, ...rest }) => {
2020-05-16 14:10:08 -08:00
const unselectAll = useUnselectAll()
useEffect(() => {
unselectAll('playlistTrack')
// eslint-disable-next-line
}, [])
2020-11-26 13:00:53 -09:00
const mappedResource = `playlist/${playlistId}/tracks`
2020-05-16 14:10:08 -08:00
return (
2020-11-26 13:00:53 -09:00
<ResourceContextProvider value={mappedResource}>
<Fragment>
<BulkDeleteButton {...rest} resource={mappedResource} />
</Fragment>
</ResourceContextProvider>
2020-05-16 14:10:08 -08:00
)
}
PlaylistSongBulkActions.propTypes = {
playlistId: PropTypes.string.isRequired,
}
export default PlaylistSongBulkActions