mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-19 08:14:15 +03:00
Add SongContextMenu
This commit is contained in:
parent
dbde5330bd
commit
10a7dfeb15
@ -15,6 +15,10 @@ export default deepmerge(englishMessages, {
|
|||||||
bulk: {
|
bulk: {
|
||||||
addToQueue: 'Play Later',
|
addToQueue: 'Play Later',
|
||||||
},
|
},
|
||||||
|
actions: {
|
||||||
|
playNow: 'Play Now',
|
||||||
|
addToQueue: 'Play Later',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
album: {
|
album: {
|
||||||
name: 'Album |||| Albums',
|
name: 'Album |||| Albums',
|
||||||
@ -26,7 +30,7 @@ export default deepmerge(englishMessages, {
|
|||||||
playCount: 'Plays',
|
playCount: 'Plays',
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
playAll: 'Play',
|
playAll: 'Play Now',
|
||||||
playNext: 'Play Next',
|
playNext: 'Play Next',
|
||||||
addToQueue: 'Play Later',
|
addToQueue: 'Play Later',
|
||||||
shuffle: 'Shuffle',
|
shuffle: 'Shuffle',
|
||||||
|
@ -21,7 +21,11 @@ export default deepmerge(portugueseMessages, {
|
|||||||
updatedAt: 'Últ. Atualização',
|
updatedAt: 'Últ. Atualização',
|
||||||
},
|
},
|
||||||
bulk: {
|
bulk: {
|
||||||
addToQueue: 'Play Later',
|
addToQueue: 'Tocar no fim',
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
playNow: 'Tocar agora',
|
||||||
|
addToQueue: 'Tocar no fim',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
album: {
|
album: {
|
||||||
@ -37,10 +41,10 @@ export default deepmerge(portugueseMessages, {
|
|||||||
year: 'Ano',
|
year: 'Ano',
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
playAll: 'Play',
|
playAll: 'Tocar',
|
||||||
playNext: 'Play Next',
|
playNext: 'Tocar em seguida',
|
||||||
addToQueue: 'Play Later',
|
addToQueue: 'Tocar no fim',
|
||||||
shuffle: 'Shuffle',
|
shuffle: 'Aleatório',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
artist: {
|
artist: {
|
||||||
|
60
ui/src/song/SongContextMenu.js
Normal file
60
ui/src/song/SongContextMenu.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import React, { useState } from 'react'
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
|
import { useTranslate } from 'react-admin'
|
||||||
|
import { IconButton, Menu, MenuItem } from '@material-ui/core'
|
||||||
|
import MoreVertIcon from '@material-ui/icons/MoreVert'
|
||||||
|
import { addTrack, setTrack } from '../audioplayer'
|
||||||
|
|
||||||
|
export const SongContextMenu = ({ record }) => {
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
const translate = useTranslate()
|
||||||
|
const [anchorEl, setAnchorEl] = useState(null)
|
||||||
|
const options = {
|
||||||
|
playNow: {
|
||||||
|
label: translate('resources.song.actions.playNow'),
|
||||||
|
action: (record) => setTrack(record),
|
||||||
|
},
|
||||||
|
addToQueue: {
|
||||||
|
label: translate('resources.song.actions.addToQueue'),
|
||||||
|
action: (record) => addTrack(record),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClick = (e) => {
|
||||||
|
setAnchorEl(e.currentTarget)
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClose = (e) => {
|
||||||
|
setAnchorEl(null)
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleItemClick = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
setAnchorEl(null)
|
||||||
|
const key = e.target.getAttribute('value')
|
||||||
|
dispatch(options[key].action(record))
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<IconButton onClick={handleClick}>
|
||||||
|
<MoreVertIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Menu
|
||||||
|
id={'menu' + record.id}
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={Boolean(anchorEl)}
|
||||||
|
onClose={handleClose}
|
||||||
|
>
|
||||||
|
{Object.keys(options).map((key) => (
|
||||||
|
<MenuItem value={key} key={key} onClick={handleItemClick}>
|
||||||
|
{options[key].label}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Menu>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
@ -9,19 +9,13 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
} from 'react-admin'
|
} from 'react-admin'
|
||||||
import { useMediaQuery } from '@material-ui/core'
|
import { useMediaQuery } from '@material-ui/core'
|
||||||
import {
|
import { DurationField, Pagination, SimpleList, Title } from '../common'
|
||||||
DurationField,
|
|
||||||
Pagination,
|
|
||||||
PlayButton,
|
|
||||||
SimpleList,
|
|
||||||
Title,
|
|
||||||
} from '../common'
|
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import { addTrack, setTrack } from '../audioplayer'
|
import { setTrack } from '../audioplayer'
|
||||||
import AddIcon from '@material-ui/icons/Add'
|
|
||||||
import { SongBulkActions } from './SongBulkActions'
|
import { SongBulkActions } from './SongBulkActions'
|
||||||
import { AlbumLinkField } from './AlbumLinkField'
|
import { AlbumLinkField } from './AlbumLinkField'
|
||||||
import { SongDetails } from '../common'
|
import { SongDetails } from '../common'
|
||||||
|
import { SongContextMenu } from './SongContextMenu'
|
||||||
|
|
||||||
const SongFilter = (props) => (
|
const SongFilter = (props) => (
|
||||||
<Filter {...props}>
|
<Filter {...props}>
|
||||||
@ -48,16 +42,16 @@ const SongList = (props) => {
|
|||||||
>
|
>
|
||||||
{isXsmall ? (
|
{isXsmall ? (
|
||||||
<SimpleList
|
<SimpleList
|
||||||
primaryText={(r) => (
|
primaryText={(r) => r.title}
|
||||||
|
secondaryText={(r) => r.artist}
|
||||||
|
tertiaryText={(r) => (
|
||||||
<>
|
<>
|
||||||
<PlayButton action={setTrack(r)} />
|
<DurationField record={r} source={'duration'} />
|
||||||
<PlayButton action={addTrack(r)} icon={<AddIcon />} />
|
|
||||||
{r.title}
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
secondaryText={(r) => r.artist}
|
|
||||||
tertiaryText={(r) => <DurationField record={r} source={'duration'} />}
|
|
||||||
linkType={(id, basePath, record) => dispatch(setTrack(record))}
|
linkType={(id, basePath, record) => dispatch(setTrack(record))}
|
||||||
|
rightIcon={(r) => <SongContextMenu record={r} />}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Datagrid
|
<Datagrid
|
||||||
@ -73,6 +67,7 @@ const SongList = (props) => {
|
|||||||
<FunctionField source="year" render={(r) => r.year || ''} />
|
<FunctionField source="year" render={(r) => r.year || ''} />
|
||||||
)}
|
)}
|
||||||
<DurationField source="duration" />
|
<DurationField source="duration" />
|
||||||
|
<SongContextMenu />
|
||||||
</Datagrid>
|
</Datagrid>
|
||||||
)}
|
)}
|
||||||
</List>
|
</List>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user