1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-19 21:46:43 -04:00

New: Include External IDs for series with links

Closes #7927
This commit is contained in:
Yashizzle
2026-03-02 04:48:15 +11:00
committed by GitHub
parent db9ef92a80
commit 7f971d47ac
6 changed files with 97 additions and 80 deletions
@@ -4,6 +4,10 @@
position: relative; position: relative;
} }
.buttonText {
margin: 0 5px;
}
.stateIconContainer { .stateIconContainer {
position: absolute; position: absolute;
top: 50%; top: 50%;
+1
View File
@@ -2,6 +2,7 @@
// Please do not change this file! // Please do not change this file!
interface CssExports { interface CssExports {
'button': string; 'button': string;
'buttonText': string;
'clipboardIconContainer': string; 'clipboardIconContainer': string;
'showStateIcon': string; 'showStateIcon': string;
'stateIconContainer': string; 'stateIconContainer': string;
@@ -8,6 +8,7 @@ import styles from './ClipboardButton.css';
export interface ClipboardButtonProps extends Omit<ButtonProps, 'children'> { export interface ClipboardButtonProps extends Omit<ButtonProps, 'children'> {
value: string; value: string;
label?: string | number;
} }
export type ClipboardState = 'success' | 'error' | null; export type ClipboardState = 'success' | 'error' | null;
@@ -15,6 +16,7 @@ export type ClipboardState = 'success' | 'error' | null;
export default function ClipboardButton({ export default function ClipboardButton({
id, id,
value, value,
label,
className = styles.button, className = styles.button,
...otherProps ...otherProps
}: ClipboardButtonProps) { }: ClipboardButtonProps) {
@@ -68,6 +70,7 @@ export default function ClipboardButton({
) : null} ) : null}
<span className={styles.clipboardIconContainer}> <span className={styles.clipboardIconContainer}>
{label ? <span className={styles.buttonText}>{label}</span> : null}
<Icon name={icons.CLIPBOARD} /> <Icon name={icons.CLIPBOARD} />
</span> </span>
</span> </span>
@@ -1,4 +1,6 @@
.links { .links {
display: flex;
flex-wrap: wrap;
margin: 0; margin: 0;
} }
@@ -9,12 +11,22 @@
.linkLabel { .linkLabel {
composes: label from '~Components/Label.css'; composes: label from '~Components/Label.css';
cursor: pointer; margin: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
&:hover {
cursor: pointer;
}
}
.linkBlock {
display: flex;
margin: 3px;
} }
@media only screen and (max-width: $breakpointExtraSmall) { @media only screen and (max-width: $breakpointExtraSmall) {
.links { .links {
display: flex;
flex-flow: column wrap; flex-flow: column wrap;
} }
} }
@@ -2,6 +2,7 @@
// Please do not change this file! // Please do not change this file!
interface CssExports { interface CssExports {
'link': string; 'link': string;
'linkBlock': string;
'linkLabel': string; 'linkLabel': string;
'links': string; 'links': string;
} }
@@ -1,8 +1,10 @@
import React from 'react'; import React, { useMemo } from 'react';
import Label from 'Components/Label'; import Label from 'Components/Label';
import ClipboardButton from 'Components/Link/ClipboardButton';
import Link from 'Components/Link/Link'; import Link from 'Components/Link/Link';
import { kinds, sizes } from 'Helpers/Props'; import { kinds, sizes } from 'Helpers/Props';
import Series from 'Series/Series'; import Series from 'Series/Series';
import translate from 'Utilities/String/translate';
import styles from './SeriesDetailsLinks.css'; import styles from './SeriesDetailsLinks.css';
type SeriesDetailsLinksProps = Pick< type SeriesDetailsLinksProps = Pick<
@@ -10,96 +12,90 @@ type SeriesDetailsLinksProps = Pick<
'tvdbId' | 'tvMazeId' | 'imdbId' | 'tmdbId' 'tvdbId' | 'tvMazeId' | 'imdbId' | 'tmdbId'
>; >;
interface SeriesDetailsLink {
externalId: string | number;
name: string;
url: string;
}
function SeriesDetailsLinks(props: SeriesDetailsLinksProps) { function SeriesDetailsLinks(props: SeriesDetailsLinksProps) {
const { tvdbId, tvMazeId, imdbId, tmdbId } = props; const { tvdbId, tvMazeId, imdbId, tmdbId } = props;
const links = useMemo(() => {
const validLinks: SeriesDetailsLink[] = [];
if (tvdbId) {
validLinks.push(
{
externalId: tvdbId,
name: 'The TVDB',
url: `https://www.thetvdb.com/?tab=series&id=${tvdbId}`,
},
{
externalId: tvdbId,
name: 'Trakt',
url: `https://trakt.tv/search/tvdb/${tvdbId}?id_type=show`,
}
);
}
if (tvMazeId) {
validLinks.push({
externalId: tvMazeId,
name: 'TV Maze',
url: `https://www.tvmaze.com/shows/${tvMazeId}/_`,
});
}
if (imdbId) {
validLinks.push(
{
externalId: imdbId,
name: 'IMDB',
url: `https://imdb.com/title/${imdbId}/`,
},
{
externalId: imdbId,
name: 'MDBList',
url: `https://mdblist.com/show/${imdbId}`,
}
);
}
if (tmdbId) {
validLinks.push({
externalId: tmdbId,
name: 'TMDB',
url: `https://www.themoviedb.org/tv/${tmdbId}`,
});
}
return validLinks;
}, [tvdbId, tvMazeId, imdbId, tmdbId]);
return ( return (
<div className={styles.links}> <div className={styles.links}>
<Link {links.map((link) => (
className={styles.link} <div key={link.name} className={styles.linkBlock}>
to={`https://www.thetvdb.com/?tab=series&id=${tvdbId}`} <Link className={styles.link} to={link.url}>
>
<Label
className={styles.linkLabel}
kind={kinds.INFO}
size={sizes.LARGE}
>
The TVDB
</Label>
</Link>
<Link
className={styles.link}
to={`https://trakt.tv/search/tvdb/${tvdbId}?id_type=show`}
>
<Label
className={styles.linkLabel}
kind={kinds.INFO}
size={sizes.LARGE}
>
Trakt
</Label>
</Link>
{tvMazeId ? (
<Link
className={styles.link}
to={`https://www.tvmaze.com/shows/${tvMazeId}/_`}
>
<Label
className={styles.linkLabel}
kind={kinds.INFO}
size={sizes.LARGE}
>
TV Maze
</Label>
</Link>
) : null}
{imdbId ? (
<>
<Link
className={styles.link}
to={`https://imdb.com/title/${imdbId}/`}
>
<Label <Label
className={styles.linkLabel} className={styles.linkLabel}
kind={kinds.INFO} kind={kinds.INFO}
size={sizes.LARGE} size={sizes.LARGE}
> >
IMDB {link.name}
</Label> </Label>
</Link> </Link>
<Link <ClipboardButton
className={styles.link} value={`${link.externalId}`}
to={`http://mdblist.com/show/${imdbId}`} title={translate('CopyToClipboard')}
> kind={kinds.DEFAULT}
<Label size={sizes.SMALL}
className={styles.linkLabel} label={link.externalId}
kind={kinds.INFO} />
size={sizes.LARGE} </div>
> ))}
MDBList
</Label>
</Link>
</>
) : null}
{tmdbId ? (
<Link
className={styles.link}
to={`https://www.themoviedb.org/tv/${tmdbId}`}
>
<Label
className={styles.linkLabel}
kind={kinds.INFO}
size={sizes.LARGE}
>
TMDB
</Label>
</Link>
) : null}
</div> </div>
); );
} }