mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-22 21:11:26 +03:00
36 lines
903 B
JavaScript
36 lines
903 B
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { Link } from 'react-admin'
|
|
import { useAlbumsPerPage } from './index'
|
|
import { withWidth } from '@material-ui/core'
|
|
|
|
export const useGetHandleArtistClick = (width) => {
|
|
const [perPage] = useAlbumsPerPage(width)
|
|
|
|
return (id) => {
|
|
return `/album?filter={"artist_id":"${id}"}&order=ASC&sort=maxYear&displayedFilters={"compilation":true}&perPage=${perPage}`
|
|
}
|
|
}
|
|
|
|
export const ArtistLinkField = withWidth()(({ record, className, width }) => {
|
|
const artistLink = useGetHandleArtistClick(width)
|
|
return (
|
|
<Link
|
|
to={artistLink(record.albumArtistId)}
|
|
onClick={(e) => e.stopPropagation()}
|
|
className={className}
|
|
>
|
|
{record.albumArtist}
|
|
</Link>
|
|
)
|
|
})
|
|
|
|
ArtistLinkField.propTypes = {
|
|
record: PropTypes.object,
|
|
className: PropTypes.string,
|
|
}
|
|
|
|
ArtistLinkField.defaultProps = {
|
|
addLabel: true,
|
|
}
|