quintodrome/ui/src/album/AlbumShow.js

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

50 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react'
2020-11-19 14:44:28 -09:00
import {
ReferenceManyField,
ShowContextProvider,
useShowContext,
useShowController,
} from 'react-admin'
import AlbumSongs from './AlbumSongs'
2020-02-07 11:04:45 -09:00
import AlbumDetails from './AlbumDetails'
2020-05-15 09:48:33 -08:00
import AlbumActions from './AlbumActions'
2020-11-19 14:44:28 -09:00
const AlbumShowLayout = (props) => {
const { loading, ...context } = useShowContext(props)
const { record } = context
return (
<>
2020-11-19 14:44:28 -09:00
{record && <AlbumDetails {...context} />}
{record && (
<ReferenceManyField
{...context}
addLabel={false}
reference="albumSong"
target="album_id"
sort={{ field: 'discNumber asc, trackNumber asc', order: 'ASC' }}
perPage={0}
pagination={null}
>
<AlbumSongs
resource={'albumSong'}
exporter={false}
actions={<AlbumActions record={record} />}
/>
</ReferenceManyField>
)}
</>
)
}
2020-11-19 14:44:28 -09:00
const AlbumShow = (props) => {
const controllerProps = useShowController(props)
return (
<ShowContextProvider value={controllerProps}>
<AlbumShowLayout {...props} {...controllerProps} />
</ShowContextProvider>
)
}
export default AlbumShow