quintodrome/ui/src/album/AlbumListView.js

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

64 lines
1.7 KiB
JavaScript
Raw Normal View History

import React from 'react'
import {
BooleanField,
Datagrid,
DateField,
2020-05-01 07:50:07 -08:00
NumberField,
Show,
SimpleShowLayout,
TextField,
} from 'react-admin'
2020-05-14 16:42:21 -08:00
import {
ArtistLinkField,
DurationField,
RangeField,
SimpleList,
} from '../common'
import { useMediaQuery } from '@material-ui/core'
2020-05-01 07:27:09 -08:00
import AlbumContextMenu from './AlbumContextMenu'
const AlbumDetails = (props) => {
return (
<Show {...props} title=" ">
<SimpleShowLayout>
<TextField source="albumArtist" />
<TextField source="genre" />
<BooleanField source="compilation" />
<DateField source="updatedAt" showTime />
</SimpleShowLayout>
</Show>
)
}
const AlbumListView = ({ hasShow, hasEdit, hasList, ...rest }) => {
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
2020-05-01 07:50:07 -08:00
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
return isXsmall ? (
<SimpleList
primaryText={(r) => r.name}
secondaryText={(r) => r.albumArtist}
tertiaryText={(r) => (
<>
<RangeField record={r} source={'year'} sortBy={'maxYear'} />
&nbsp;&nbsp;&nbsp;
</>
)}
linkType={'show'}
rightIcon={(r) => <AlbumContextMenu record={r} />}
{...rest}
/>
) : (
<Datagrid expand={<AlbumDetails />} rowClick={'show'} {...rest}>
2020-04-24 13:37:28 -08:00
<TextField source="name" />
2020-05-14 16:42:21 -08:00
<ArtistLinkField />
{isDesktop && <NumberField source="songCount" />}
{isDesktop && <NumberField source="playCount" />}
2020-05-01 07:50:07 -08:00
<RangeField source={'year'} sortBy={'maxYear'} />
{isDesktop && <DurationField source="duration" />}
2020-05-01 07:27:09 -08:00
<AlbumContextMenu />
</Datagrid>
)
}
2020-05-01 07:50:07 -08:00
export default AlbumListView