navidrome/ui/src/common/SongDetails.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-04-14 20:59:16 +02:00
import React from 'react'
2020-04-14 22:19:18 +02:00
import Paper from '@material-ui/core/Paper'
import Table from '@material-ui/core/Table'
import TableBody from '@material-ui/core/TableBody'
import TableCell from '@material-ui/core/TableCell'
import TableContainer from '@material-ui/core/TableContainer'
import TableRow from '@material-ui/core/TableRow'
import { BooleanField, DateField, TextField, useTranslate } from 'react-admin'
import inflection from 'inflection'
import { BitrateField, SizeField } from './index'
2020-04-14 20:59:16 +02:00
const SongDetails = (props) => {
2020-04-14 22:19:18 +02:00
const translate = useTranslate()
const { record } = props
2020-04-14 22:19:18 +02:00
const data = {
path: <TextField record={record} source="path" />,
2020-05-18 19:32:12 +02:00
album: <TextField record={record} source="album" />,
2020-05-12 17:17:22 +02:00
discSubtitle: <TextField record={record} source="discSubtitle" />,
2020-04-14 22:19:18 +02:00
albumArtist: <TextField record={record} source="albumArtist" />,
genre: <TextField record={record} source="genre" />,
compilation: <BooleanField record={record} source="compilation" />,
bitRate: <BitrateField record={record} source="bitRate" />,
size: <SizeField record={record} source="size" />,
updatedAt: <DateField record={record} source="updatedAt" showTime />,
playCount: <TextField record={record} source="playCount" />,
}
2020-05-12 17:17:22 +02:00
if (!record.discSubtitle) {
delete data.discSubtitle
}
2020-04-14 22:19:18 +02:00
if (record.playCount > 0) {
data.playDate = <DateField record={record} source="playDate" showTime />
}
2020-04-14 20:59:16 +02:00
return (
2020-04-14 22:19:18 +02:00
<TableContainer component={Paper}>
2020-04-14 23:09:47 +02:00
<Table aria-label="song details" size="small">
2020-04-14 22:19:18 +02:00
<TableBody>
{Object.keys(data).map((key) => {
return (
2020-05-23 02:48:49 +02:00
<TableRow key={`${record.id}-${key}`}>
2020-04-14 22:19:18 +02:00
<TableCell component="th" scope="row">
{translate(`resources.song.fields.${key}`, {
_: inflection.humanize(inflection.underscore(key)),
})}
:
</TableCell>
<TableCell align="left">{data[key]}</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
</TableContainer>
2020-04-14 20:59:16 +02:00
)
}
export default SongDetails