navidrome/ui/src/share/ShareList.js

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

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-01-20 04:52:55 +01:00
import {
Datagrid,
FunctionField,
List,
NumberField,
TextField,
} from 'react-admin'
import React from 'react'
import { DateField, QualityInfo } from '../common'
import { shareUrl } from '../utils'
import { Link } from '@material-ui/core'
import config from '../config'
2023-01-20 04:52:55 +01:00
export const FormatInfo = ({ record, size }) => {
const r = { suffix: record.format, bitRate: record.maxBitRate }
r.suffix =
r.suffix || (r.bitRate ? config.defaultDownsamplingFormat : 'Original')
2023-01-20 04:52:55 +01:00
return <QualityInfo record={r} size={size} />
}
const ShareList = (props) => {
return (
<List
{...props}
sort={{ field: 'createdAt', order: 'DESC' }}
exporter={false}
>
<Datagrid rowClick="edit">
<FunctionField
source={'id'}
render={(r) => (
<Link
href={shareUrl(r.id)}
label="URL"
target="_blank"
rel="noopener noreferrer"
2023-01-21 01:53:53 +01:00
onClick={(e) => {
e.stopPropagation()
}}
2023-01-20 04:52:55 +01:00
>
{r.id}
</Link>
)}
/>
<TextField source="username" />
<TextField source="description" />
<TextField source="contents" />
2023-01-20 04:52:55 +01:00
<FormatInfo source="format" />
<NumberField source="visitCount" />
<DateField source="expiresAt" showTime />
<DateField source="lastVisitedAt" showTime sortByOrder={'DESC'} />
</Datagrid>
</List>
)
}
export default ShareList