From 3ae1586e10abf46ddba996f3b0a49cae63b0f1d7 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 24 May 2020 11:27:17 -0400 Subject: [PATCH] Add "No playlists available" to context menu --- ui/src/common/AddToPlaylistMenu.js | 22 +++++++++++++++++++++- ui/src/i18n/en.json | 3 ++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ui/src/common/AddToPlaylistMenu.js b/ui/src/common/AddToPlaylistMenu.js index 3e82e64a1..404e2a134 100644 --- a/ui/src/common/AddToPlaylistMenu.js +++ b/ui/src/common/AddToPlaylistMenu.js @@ -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 Loading... } + // TODO: This is temporary, while we don't have the "New Playlist" option in the menu + if (ids.length === 0) { + return ( + { + e.stopPropagation() + onClose && onClose(e) + }} + > + {translate('message.noPlaylistsAvailable')} + + ) + } + const handleItemClick = (e) => { e.preventDefault() const playlistId = e.target.getAttribute('value') diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json index 5e47870cb..fc1bee328 100644 --- a/ui/src/i18n/en.json +++ b/ui/src/i18n/en.json @@ -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",