mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-05 18:03:10 +03:00
replaced GridButton with GridMenu
This commit is contained in:
parent
e539ddceb9
commit
2a5d2d70ba
@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
|
|||||||
import { linkToRecord, Loading } from 'react-admin'
|
import { linkToRecord, Loading } from 'react-admin'
|
||||||
import subsonic from '../subsonic'
|
import subsonic from '../subsonic'
|
||||||
import { ArtistLinkField } from './ArtistLinkField'
|
import { ArtistLinkField } from './ArtistLinkField'
|
||||||
import GridButton from './GridButton.js'
|
import GridMenu from './GridMenu.js'
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@ -22,7 +22,7 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
height: '100%',
|
height: '100%',
|
||||||
},
|
},
|
||||||
tileBar: {
|
tileBar: {
|
||||||
textAlign: 'center',
|
textAlign: 'left',
|
||||||
background:
|
background:
|
||||||
'linear-gradient(to top, rgba(0,0,0,1) 0%,rgba(0,0,0,0.4) 70%,rgba(0,0,0,0) 100%)',
|
'linear-gradient(to top, rgba(0,0,0,1) 0%,rgba(0,0,0,0.4) 70%,rgba(0,0,0,0) 100%)',
|
||||||
},
|
},
|
||||||
@ -30,7 +30,7 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
textOverflow: 'ellipsis',
|
textOverflow: 'ellipsis',
|
||||||
textAlign: 'center',
|
textAlign: 'left',
|
||||||
fontSize: '1em',
|
fontSize: '1em',
|
||||||
},
|
},
|
||||||
artistLink: {
|
artistLink: {
|
||||||
@ -81,9 +81,7 @@ const LoadedAlbumGrid = ({ ids, data, basePath, width }) => {
|
|||||||
</ArtistLinkField>
|
</ArtistLinkField>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
actionIcon={
|
actionIcon={<GridMenu id={id} />}
|
||||||
<GridButton id={id}/>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</GridListTile>
|
</GridListTile>
|
||||||
))}
|
))}
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import { useDispatch } from 'react-redux'
|
|
||||||
import { playAlbum } from '../audioplayer'
|
|
||||||
import { useGetList} from 'react-admin'
|
|
||||||
import IconButton from '@material-ui/core/IconButton'
|
|
||||||
import PlayIcon from '@material-ui/icons/PlayCircleFilled'
|
|
||||||
|
|
||||||
const GridButton = (props) => {
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
const { ids, data, loading, error } = useGetList(
|
|
||||||
'albumSong',
|
|
||||||
{ },
|
|
||||||
{ field: 'trackNumber', order: 'ASC' },
|
|
||||||
{ album_id: props.id},
|
|
||||||
)
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return (
|
|
||||||
<IconButton>
|
|
||||||
<PlayIcon/>
|
|
||||||
</IconButton>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
return (
|
|
||||||
<IconButton>
|
|
||||||
<PlayIcon/>
|
|
||||||
</IconButton>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<IconButton onClick={(e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
e.stopPropagation()
|
|
||||||
dispatch(playAlbum(ids[0], data))
|
|
||||||
}}>
|
|
||||||
<PlayIcon/>
|
|
||||||
</IconButton>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default GridButton
|
|
91
ui/src/album/GridMenu.js
Normal file
91
ui/src/album/GridMenu.js
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import IconButton from '@material-ui/core/IconButton'
|
||||||
|
import Menu from '@material-ui/core/Menu'
|
||||||
|
import MenuItem from '@material-ui/core/MenuItem'
|
||||||
|
import MoreVertIcon from '@material-ui/icons/MoreVert'
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
|
import { playAlbum, shuffleAlbum } from '../audioplayer'
|
||||||
|
import { useGetList } from 'react-admin'
|
||||||
|
|
||||||
|
const GridMenu = (props) => {
|
||||||
|
const [anchorEl, setAnchorEl] = React.useState(null)
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
const { ids, data, loading, error } = useGetList(
|
||||||
|
'albumSong',
|
||||||
|
{},
|
||||||
|
{ field: 'trackNumber', order: 'ASC' },
|
||||||
|
{ album_id: props.id }
|
||||||
|
)
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<IconButton>
|
||||||
|
<MoreVertIcon />
|
||||||
|
</IconButton>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<IconButton>
|
||||||
|
<MoreVertIcon />
|
||||||
|
</IconButton>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
[1, 'Play'],
|
||||||
|
[2, 'Shuffle'],
|
||||||
|
]
|
||||||
|
|
||||||
|
const open = Boolean(anchorEl)
|
||||||
|
|
||||||
|
const handleClick = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
setAnchorEl(e.currentTarget)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClose = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
setAnchorEl(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleItemClick = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
setAnchorEl(null)
|
||||||
|
const value = e.target.getAttribute('value')
|
||||||
|
if (value === '1') {
|
||||||
|
dispatch(playAlbum(ids[0], data))
|
||||||
|
}
|
||||||
|
if (value === '2') {
|
||||||
|
dispatch(shuffleAlbum(data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<IconButton
|
||||||
|
aria-label="more"
|
||||||
|
aria-controls="long-menu"
|
||||||
|
aria-haspopup="true"
|
||||||
|
onClick={handleClick}
|
||||||
|
>
|
||||||
|
<MoreVertIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Menu
|
||||||
|
id="long-menu"
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
keepMounted
|
||||||
|
open={open}
|
||||||
|
onClose={handleClose}
|
||||||
|
>
|
||||||
|
{options.map((option) => (
|
||||||
|
<MenuItem value={option[0]} key={option[0]} onClick={handleItemClick}>
|
||||||
|
{option[1]}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default GridMenu
|
Loading…
x
Reference in New Issue
Block a user