* feat: create vite project * feat: it's alive! * feat: `make dev` working! * feat: replace custom serviceWorker with vite plugin * test: replace Jest with Vitest * fix: run prettier * fix: skip eslint for now. * chore: remove ui.old folder * refactor: replace lodash.pick with simple destructuring * fix: eslint errors (wip) * fix: eslint errors (wip) * fix: display-name eslint errors (wip) * fix: no-console eslint errors (wip) * fix: react-refresh/only-export-components eslint errors (wip) * fix: react-refresh/only-export-components eslint errors (wip) * fix: react-refresh/only-export-components eslint errors (wip) * fix: react-refresh/only-export-components eslint errors (wip) * fix: build * fix: pwa manifest * refactor: pwa manifest * refactor: simplify PORT configuration * refactor: rename simple JS files * test: cover playlistUtils * fix: react-image-lightbox * feat(ui): add sourcemaps to help debug issues
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
import React from 'react'
|
|
import { useRecordContext, useTranslate } from 'react-admin'
|
|
import { IconButton, Tooltip, Link } from '@material-ui/core'
|
|
import { ImLastfm2 } from 'react-icons/im'
|
|
import MusicBrainz from '../icons/MusicBrainz'
|
|
import { intersperse } from '../utils'
|
|
import config from '../config'
|
|
|
|
const AlbumExternalLinks = (props) => {
|
|
const { className } = props
|
|
const translate = useTranslate()
|
|
const record = useRecordContext(props)
|
|
let links = []
|
|
|
|
const addLink = (url, title, icon) => {
|
|
const translatedTitle = translate(title)
|
|
const link = (
|
|
<Link href={url} target="_blank" rel="noopener noreferrer">
|
|
<Tooltip title={translatedTitle}>
|
|
<IconButton size={'small'} aria-label={translatedTitle}>
|
|
{icon}
|
|
</IconButton>
|
|
</Tooltip>
|
|
</Link>
|
|
)
|
|
const id = links.length
|
|
links.push(<span key={`link-${record.id}-${id}`}>{link}</span>)
|
|
}
|
|
|
|
if (config.lastFMEnabled) {
|
|
addLink(
|
|
`https://last.fm/music/${
|
|
encodeURIComponent(record.albumArtist) +
|
|
'/' +
|
|
encodeURIComponent(record.name)
|
|
}`,
|
|
'message.openIn.lastfm',
|
|
<ImLastfm2 className="lastfm-icon" />,
|
|
)
|
|
}
|
|
|
|
record.mbzAlbumId &&
|
|
addLink(
|
|
`https://musicbrainz.org/release/${record.mbzAlbumId}`,
|
|
'message.openIn.musicbrainz',
|
|
<MusicBrainz className="musicbrainz-icon" />,
|
|
)
|
|
|
|
return <div className={className}>{intersperse(links, ' ')}</div>
|
|
}
|
|
|
|
export default AlbumExternalLinks
|