Link to artist from album list
This commit is contained in:
@@ -3,7 +3,7 @@ import { Card, CardContent, CardMedia, Typography } from '@material-ui/core'
|
||||
import { useTranslate } from 'react-admin'
|
||||
import subsonic from '../subsonic'
|
||||
import { DurationField, formatRange } from '../common'
|
||||
import { ArtistLinkField } from './ArtistLinkField'
|
||||
import { ArtistLinkField } from '../common'
|
||||
|
||||
const AlbumDetails = ({ classes, record }) => {
|
||||
const translate = useTranslate()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
|
||||
import { linkToRecord, Loading } from 'react-admin'
|
||||
import { withContentRect } from 'react-measure'
|
||||
import subsonic from '../subsonic'
|
||||
import { ArtistLinkField } from './ArtistLinkField'
|
||||
import { ArtistLinkField } from '../common'
|
||||
import AlbumContextMenu from './AlbumContextMenu.js'
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
|
||||
@@ -3,13 +3,17 @@ import {
|
||||
BooleanField,
|
||||
Datagrid,
|
||||
DateField,
|
||||
FunctionField,
|
||||
NumberField,
|
||||
Show,
|
||||
SimpleShowLayout,
|
||||
TextField,
|
||||
} from 'react-admin'
|
||||
import { DurationField, RangeField, SimpleList } from '../common'
|
||||
import {
|
||||
ArtistLinkField,
|
||||
DurationField,
|
||||
RangeField,
|
||||
SimpleList,
|
||||
} from '../common'
|
||||
import { useMediaQuery } from '@material-ui/core'
|
||||
import AlbumContextMenu from './AlbumContextMenu'
|
||||
|
||||
@@ -46,7 +50,7 @@ const AlbumListView = ({ hasShow, hasEdit, hasList, ...rest }) => {
|
||||
) : (
|
||||
<Datagrid expand={<AlbumDetails />} rowClick={'show'} {...rest}>
|
||||
<TextField source="name" />
|
||||
<FunctionField source="artist" render={(r) => r.albumArtist} />
|
||||
<ArtistLinkField />
|
||||
{isDesktop && <NumberField source="songCount" />}
|
||||
{isDesktop && <NumberField source="playCount" />}
|
||||
<RangeField source={'year'} sortBy={'maxYear'} />
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Link } from 'react-admin'
|
||||
|
||||
export const ArtistLinkField = ({ record, className }) => {
|
||||
const filter = { artist_id: record.albumArtistId }
|
||||
const url = `/album?filter=${JSON.stringify(
|
||||
filter
|
||||
)}&order=ASC&sort=maxYear&displayedFilters={"compilation":true}`
|
||||
return (
|
||||
<Link to={url} onClick={(e) => e.stopPropagation()} className={className}>
|
||||
{record.albumArtist}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
ArtistLinkField.propTypes = {
|
||||
className: PropTypes.string,
|
||||
source: PropTypes.string,
|
||||
}
|
||||
|
||||
ArtistLinkField.defaultProps = {
|
||||
source: 'artistId',
|
||||
addLabel: true,
|
||||
}
|
||||
Reference in New Issue
Block a user