quintodrome/ui/src/common/ArtistLinkField.jsx

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

43 lines
861 B
React
Raw Normal View History

2020-05-14 16:42:21 -08:00
import React from 'react'
import PropTypes from 'prop-types'
import { Link } from 'react-admin'
import { withWidth } from '@material-ui/core'
import { useGetHandleArtistClick } from './useGetHandleArtistClick'
2020-05-14 16:42:21 -08:00
export const ArtistLinkField = withWidth()(({
record,
className,
width,
source,
}) => {
const artistLink = useGetHandleArtistClick(width)
const id = record[source + 'Id']
return (
<>
{id ? (
<Link
to={artistLink(id)}
onClick={(e) => e.stopPropagation()}
className={className}
>
{record[source]}
</Link>
) : (
record[source]
)}
</>
)
})
2020-05-14 16:42:21 -08:00
ArtistLinkField.propTypes = {
record: PropTypes.object,
2020-05-14 16:42:21 -08:00
className: PropTypes.string,
2021-11-05 16:25:12 -08:00
source: PropTypes.string,
2020-05-14 16:42:21 -08:00
}
ArtistLinkField.defaultProps = {
addLabel: true,
2021-11-05 16:25:12 -08:00
source: 'albumArtist',
2020-05-14 16:42:21 -08:00
}