+ {pls.name}
+
+ }
+ sidebarIsOpen={sidebarIsOpen}
+ dense={false}
+ />
+ )
+ }
+
+ const user = localStorage.getItem('username')
+ const myPlaylists = []
+ const sharedPlaylists = []
+
+ if (loaded) {
+ const allPlaylists = Object.keys(data).map((id) => data[id])
+
+ allPlaylists.forEach((pls) => {
+ if (user === pls.owner) {
+ myPlaylists.push(pls)
+ } else {
+ sharedPlaylists.push(pls)
+ }
+ })
+ }
+
+ const onPlaylistConfig = useCallback(
+ () => history.push('/playlist'),
+ [history]
+ )
+
+ return (
+ <>
+ handleToggle('menuPlaylists')}
+ isOpen={state.menuPlaylists}
+ sidebarIsOpen={sidebarIsOpen}
+ name={'menu.playlists'}
+ icon={}
+ dense={dense}
+ actionIcon={}
+ onAction={onPlaylistConfig}
+ >
+ {myPlaylists.map(renderPlaylistMenuItemLink)}
+
+ {sharedPlaylists?.length > 0 && (
+ handleToggle('menuSharedPlaylists')}
+ isOpen={state.menuSharedPlaylists}
+ sidebarIsOpen={sidebarIsOpen}
+ name={'menu.sharedPlaylists'}
+ icon={}
+ dense={dense}
+ >
+ {sharedPlaylists.map(renderPlaylistMenuItemLink)}
+
+ )}
+ >
+ )
+}
+
+export default PlaylistsSubMenu
diff --git a/ui/src/layout/SubMenu.js b/ui/src/layout/SubMenu.js
index c62f08690..2d62cdc99 100644
--- a/ui/src/layout/SubMenu.js
+++ b/ui/src/layout/SubMenu.js
@@ -1,14 +1,15 @@
import React, { Fragment } from 'react'
import ExpandMore from '@material-ui/icons/ExpandMore'
+import ArrowRightOutlined from '@material-ui/icons/ArrowRightOutlined'
import List from '@material-ui/core/List'
import MenuItem from '@material-ui/core/MenuItem'
import ListItemIcon from '@material-ui/core/ListItemIcon'
import Typography from '@material-ui/core/Typography'
-import Divider from '@material-ui/core/Divider'
import Collapse from '@material-ui/core/Collapse'
import Tooltip from '@material-ui/core/Tooltip'
import { makeStyles } from '@material-ui/core/styles'
import { useTranslate } from 'react-admin'
+import { IconButton, useMediaQuery } from '@material-ui/core'
const useStyles = makeStyles(
(theme) => ({
@@ -25,6 +26,18 @@ const useStyles = makeStyles(
paddingLeft: theme.spacing(2),
},
},
+ actionIcon: {
+ opacity: 0,
+ },
+ menuHeader: {
+ width: '100%',
+ },
+ headerWrapper: {
+ display: 'flex',
+ '&:hover $actionIcon': {
+ opacity: 1,
+ },
+ },
}),
{
name: 'NDSubMenu',
@@ -39,19 +52,43 @@ const SubMenu = ({
icon,
children,
dense,
+ onAction,
+ actionIcon,
}) => {
const translate = useTranslate()
const classes = useStyles()
+ const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('sm'))
+
+ const handleOnClick = (e) => {
+ e.stopPropagation()
+ onAction(e)
+ }
const header = (
-
+
+
+
)
return (
@@ -74,10 +111,14 @@ const SubMenu = ({
>
{children}
-
)
}
+SubMenu.defaultProps = {
+ action: null,
+ actionIcon: ,
+}
+
export default SubMenu
diff --git a/ui/src/playlist/PlaylistCreate.js b/ui/src/playlist/PlaylistCreate.js
index f224669ee..ef5e1acb4 100644
--- a/ui/src/playlist/PlaylistCreate.js
+++ b/ui/src/playlist/PlaylistCreate.js
@@ -6,17 +6,31 @@ import {
BooleanInput,
required,
useTranslate,
+ useRefresh,
+ useNotify,
+ useRedirect,
} from 'react-admin'
import { Title } from '../common'
const PlaylistCreate = (props) => {
+ const { basePath } = props
+ const refresh = useRefresh()
+ const notify = useNotify()
+ const redirect = useRedirect()
const translate = useTranslate()
const resourceName = translate('resources.playlist.name', { smart_count: 1 })
const title = translate('ra.page.create', {
name: `${resourceName}`,
})
+
+ const onSuccess = () => {
+ notify('ra.notification.created', 'info', { smart_count: 1 })
+ redirect('list', basePath)
+ refresh()
+ }
+
return (
- } {...props}>
+ } {...props} onSuccess={onSuccess}>