mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-06 18:33:10 +03:00
Link to artist from album list
This commit is contained in:
parent
0d1af8c635
commit
a340b62fdf
@ -3,7 +3,7 @@ import { Card, CardContent, CardMedia, Typography } from '@material-ui/core'
|
|||||||
import { useTranslate } from 'react-admin'
|
import { useTranslate } from 'react-admin'
|
||||||
import subsonic from '../subsonic'
|
import subsonic from '../subsonic'
|
||||||
import { DurationField, formatRange } from '../common'
|
import { DurationField, formatRange } from '../common'
|
||||||
import { ArtistLinkField } from './ArtistLinkField'
|
import { ArtistLinkField } from '../common'
|
||||||
|
|
||||||
const AlbumDetails = ({ classes, record }) => {
|
const AlbumDetails = ({ classes, record }) => {
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
|
@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
|
|||||||
import { linkToRecord, Loading } from 'react-admin'
|
import { linkToRecord, Loading } from 'react-admin'
|
||||||
import { withContentRect } from 'react-measure'
|
import { withContentRect } from 'react-measure'
|
||||||
import subsonic from '../subsonic'
|
import subsonic from '../subsonic'
|
||||||
import { ArtistLinkField } from './ArtistLinkField'
|
import { ArtistLinkField } from '../common'
|
||||||
import AlbumContextMenu from './AlbumContextMenu.js'
|
import AlbumContextMenu from './AlbumContextMenu.js'
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
@ -3,13 +3,17 @@ import {
|
|||||||
BooleanField,
|
BooleanField,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
DateField,
|
DateField,
|
||||||
FunctionField,
|
|
||||||
NumberField,
|
NumberField,
|
||||||
Show,
|
Show,
|
||||||
SimpleShowLayout,
|
SimpleShowLayout,
|
||||||
TextField,
|
TextField,
|
||||||
} from 'react-admin'
|
} from 'react-admin'
|
||||||
import { DurationField, RangeField, SimpleList } from '../common'
|
import {
|
||||||
|
ArtistLinkField,
|
||||||
|
DurationField,
|
||||||
|
RangeField,
|
||||||
|
SimpleList,
|
||||||
|
} from '../common'
|
||||||
import { useMediaQuery } from '@material-ui/core'
|
import { useMediaQuery } from '@material-ui/core'
|
||||||
import AlbumContextMenu from './AlbumContextMenu'
|
import AlbumContextMenu from './AlbumContextMenu'
|
||||||
|
|
||||||
@ -46,7 +50,7 @@ const AlbumListView = ({ hasShow, hasEdit, hasList, ...rest }) => {
|
|||||||
) : (
|
) : (
|
||||||
<Datagrid expand={<AlbumDetails />} rowClick={'show'} {...rest}>
|
<Datagrid expand={<AlbumDetails />} rowClick={'show'} {...rest}>
|
||||||
<TextField source="name" />
|
<TextField source="name" />
|
||||||
<FunctionField source="artist" render={(r) => r.albumArtist} />
|
<ArtistLinkField />
|
||||||
{isDesktop && <NumberField source="songCount" />}
|
{isDesktop && <NumberField source="songCount" />}
|
||||||
{isDesktop && <NumberField source="playCount" />}
|
{isDesktop && <NumberField source="playCount" />}
|
||||||
<RangeField source={'year'} sortBy={'maxYear'} />
|
<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,
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ import {
|
|||||||
SearchInput,
|
SearchInput,
|
||||||
TextField,
|
TextField,
|
||||||
} from 'react-admin'
|
} from 'react-admin'
|
||||||
import { Pagination, Title } from '../common'
|
import { artistLink, Pagination, Title } from '../common'
|
||||||
|
|
||||||
const ArtistFilter = (props) => (
|
const ArtistFilter = (props) => (
|
||||||
<Filter {...props}>
|
<Filter {...props}>
|
||||||
@ -15,13 +15,6 @@ const ArtistFilter = (props) => (
|
|||||||
</Filter>
|
</Filter>
|
||||||
)
|
)
|
||||||
|
|
||||||
const artistRowClick = (id) => {
|
|
||||||
const filter = { artist_id: id }
|
|
||||||
return `/album?filter=${JSON.stringify(
|
|
||||||
filter
|
|
||||||
)}&order=ASC&sort=maxYear&displayedFilters={"compilation":true}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const ArtistList = (props) => (
|
const ArtistList = (props) => (
|
||||||
<List
|
<List
|
||||||
{...props}
|
{...props}
|
||||||
@ -35,7 +28,7 @@ const ArtistList = (props) => (
|
|||||||
perPage={15}
|
perPage={15}
|
||||||
pagination={<Pagination />}
|
pagination={<Pagination />}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick={artistRowClick}>
|
<Datagrid rowClick={artistLink}>
|
||||||
<TextField source="name" />
|
<TextField source="name" />
|
||||||
<NumberField source="albumCount" />
|
<NumberField source="albumCount" />
|
||||||
<NumberField source="songCount" />
|
<NumberField source="songCount" />
|
||||||
|
33
ui/src/common/ArtistLinkField.js
Normal file
33
ui/src/common/ArtistLinkField.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { Link } from 'react-admin'
|
||||||
|
|
||||||
|
const artistLink = (id) => {
|
||||||
|
return `/album?filter={"artist_id":"${id}"}&order=ASC&sort=maxYear&displayedFilters={"compilation":true}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const ArtistLinkField = ({ record, className }) => {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
to={artistLink(record.albumArtistId)}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
className={className}
|
||||||
|
>
|
||||||
|
{record.albumArtist}
|
||||||
|
</Link>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ArtistLinkField.propTypes = {
|
||||||
|
className: PropTypes.string,
|
||||||
|
source: PropTypes.string,
|
||||||
|
}
|
||||||
|
|
||||||
|
ArtistLinkField.defaultProps = {
|
||||||
|
source: 'artistId',
|
||||||
|
addLabel: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
export { artistLink }
|
||||||
|
|
||||||
|
export default ArtistLinkField
|
@ -5,6 +5,7 @@ import Pagination from './Pagination'
|
|||||||
import PlayButton from './PlayButton'
|
import PlayButton from './PlayButton'
|
||||||
import SimpleList from './SimpleList'
|
import SimpleList from './SimpleList'
|
||||||
import RangeField, { formatRange } from './RangeField'
|
import RangeField, { formatRange } from './RangeField'
|
||||||
|
import ArtistLinkField, { artistLink } from './ArtistLinkField'
|
||||||
import SongDetails from './SongDetails'
|
import SongDetails from './SongDetails'
|
||||||
import SizeField from './SizeField'
|
import SizeField from './SizeField'
|
||||||
import DocLink from './DocLink'
|
import DocLink from './DocLink'
|
||||||
@ -21,4 +22,6 @@ export {
|
|||||||
SongDetails,
|
SongDetails,
|
||||||
DocLink,
|
DocLink,
|
||||||
formatRange,
|
formatRange,
|
||||||
|
ArtistLinkField,
|
||||||
|
artistLink,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user