Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const BatchPlayButton = ({
resource,
selectedIds,
action,
label,
icon,
className,
}) => {
const dispatch = useDispatch()
const translate = useTranslate()
const dataProvider = useDataProvider()
const unselectAll = useUnselectAll()
const notify = useNotify()
const addToQueue = () => {
dataProvider
.getMany(resource, { ids: selectedIds })
.then((response) => {
// Add tracks to a map for easy lookup by ID, needed for the next step
const tracks = response.data.reduce(
(acc, cur) => ({ ...acc, [cur.id]: cur }),
{}
)
// Add the tracks to the queue in the selection order
dispatch(action(tracks, selectedIds))
})
.catch(() => {
notify('ra.page.error', 'warning')
export const SongBulkActions = (props) => {
const classes = useStyles()
const unselectAll = useUnselectAll()
useEffect(() => {
unselectAll(props.resource)
}, [unselectAll, props.resource])
return (
}
className={classes.button}
/>
const ResetViewsButton = ({ resource, selectedIds }) => {
const notify = useNotify();
const unselectAll = useUnselectAll();
const refresh = useRefresh();
const [updateMany, { loading }] = useUpdateMany(
resource,
selectedIds,
{ views: 0 },
{
onSuccess: () => {
notify(
'ra.notification.updated',
'info',
{ smart_count: selectedIds.length },
true
);
unselectAll(resource);
refresh();
},
const PlaylistSongBulkActions = ({
playlistId,
resource,
onUnselectItems,
...rest
}) => {
const unselectAll = useUnselectAll()
useEffect(() => {
unselectAll('playlistTrack')
}, [unselectAll])
const mappedResource = `playlist/${playlistId}/tracks`
return (
)
export const AddToPlaylistButton = ({ resource, selectedIds, className }) => {
const translate = useTranslate()
const dispatch = useDispatch()
const unselectAll = useUnselectAll()
const handleClick = () => {
dispatch(
openAddToPlaylist({ selectedIds, onSuccess: () => unselectAll(resource) })
)
}
return (
<button label="{translate('resources.song.actions.addToPlaylist')}" aria-haspopup="true" aria-controls="simple-menu">
</button>