quintodrome/ui/src/album/AlbumShow.js

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

63 lines
1.4 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 { makeStyles } from '@material-ui/core/styles'
2020-11-19 14:44:28 -09:00
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'
const useStyles = makeStyles(
(theme) => ({
albumActions: {},
}),
{
name: 'NDAlbumShow',
}
)
2020-11-19 14:44:28 -09:00
const AlbumShowLayout = (props) => {
const { loading, ...context } = useShowContext(props)
const { record } = context
const classes = useStyles()
return (
<>
2020-11-19 14:44:28 -09:00
{record && <AlbumDetails {...context} />}
{record && (
<ReferenceManyField
{...context}
addLabel={false}
reference="albumSong"
target="album_id"
sort={{ field: 'album', order: 'ASC' }}
2020-11-19 14:44:28 -09:00
perPage={0}
pagination={null}
>
<AlbumSongs
resource={'albumSong'}
exporter={false}
actions={
<AlbumActions className={classes.albumActions} record={record} />
}
2020-11-19 14:44:28 -09:00
/>
</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