Add "No playlists available" to context menu

This commit is contained in:
Deluan 2020-05-24 11:27:17 -04:00
parent 5c46f7822f
commit 3ae1586e10
2 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,10 @@
import React from 'react'
import { useDataProvider, useGetList, useNotify } from 'react-admin'
import {
useDataProvider,
useGetList,
useNotify,
useTranslate,
} from 'react-admin'
import { MenuItem } from '@material-ui/core'
import PropTypes from 'prop-types'
@ -24,6 +29,7 @@ export const addAlbumToPlaylist = (dataProvider, albumId, playlistId) =>
const AddToPlaylistMenu = React.forwardRef(
({ selectedIds, albumId, onClose, onItemAdded }, ref) => {
const notify = useNotify()
const translate = useTranslate()
const dataProvider = useDataProvider()
const { ids, data, loaded } = useGetList(
'playlist',
@ -36,6 +42,20 @@ const AddToPlaylistMenu = React.forwardRef(
return <MenuItem>Loading...</MenuItem>
}
// TODO: This is temporary, while we don't have the "New Playlist" option in the menu
if (ids.length === 0) {
return (
<MenuItem
onClick={(e) => {
e.stopPropagation()
onClose && onClose(e)
}}
>
{translate('message.noPlaylistsAvailable')}
</MenuItem>
)
}
const handleItemClick = (e) => {
e.preventDefault()
const playlistId = e.target.getAttribute('value')

View File

@ -238,7 +238,8 @@
"note": "NOTE",
"transcodingDisabled": "Changing the transcoding configuration through the web interface is disabled for security reasons. If you would like to change (edit or add) transcoding options, restart the server with the %{config} configuration option.",
"transcodingEnabled": "Navidrome is currently running with %{config}, making it possible to run system commands from the transcoding settings using the web interface. We recommend to disable it for security reasons and only enable it when configuring Transcoding options.",
"songsAddedToPlaylist": "Added 1 song to playlist |||| Added %{smart_count} songs to playlist"
"songsAddedToPlaylist": "Added 1 song to playlist |||| Added %{smart_count} songs to playlist",
"noPlaylistsAvailable": "None available"
},
"menu": {
"library": "Library",