New: Show Proper or Repack tag in interactive search

This commit is contained in:
Stevie Robinson 2023-11-28 20:09:31 +01:00 committed by Mark McDowall
parent 4b22200708
commit efb000529b
3 changed files with 51 additions and 11 deletions

View File

@ -3,6 +3,7 @@ import React from 'react';
import Label from 'Components/Label'; import Label from 'Components/Label';
import { kinds } from 'Helpers/Props'; import { kinds } from 'Helpers/Props';
import formatBytes from 'Utilities/Number/formatBytes'; import formatBytes from 'Utilities/Number/formatBytes';
import translate from 'Utilities/String/translate';
function getTooltip(title, quality, size) { function getTooltip(title, quality, size) {
if (!title) { if (!title) {
@ -26,13 +27,44 @@ function getTooltip(title, quality, size) {
return title; return title;
} }
function revisionLabel(className, quality, showRevision) {
if (!showRevision) {
return;
}
if (quality.revision.isRepack) {
return (
<Label
className={className}
kind={kinds.PRIMARY}
title={translate('Repack')}
>
R
</Label>
);
}
if (quality.revision.version && quality.revision.version > 1) {
return (
<Label
className={className}
kind={kinds.PRIMARY}
title={translate('Proper')}
>
P
</Label>
);
}
}
function EpisodeQuality(props) { function EpisodeQuality(props) {
const { const {
className, className,
title, title,
quality, quality,
size, size,
isCutoffNotMet isCutoffNotMet,
showRevision
} = props; } = props;
if (!quality) { if (!quality) {
@ -40,13 +72,15 @@ function EpisodeQuality(props) {
} }
return ( return (
<Label <span>
className={className} <Label
kind={isCutoffNotMet ? kinds.INVERSE : kinds.DEFAULT} className={className}
title={getTooltip(title, quality, size)} kind={isCutoffNotMet ? kinds.INVERSE : kinds.DEFAULT}
> title={getTooltip(title, quality, size)}
{quality.quality.name} >
</Label> {quality.quality.name}
</Label>{revisionLabel(className, quality, showRevision)}
</span>
); );
} }
@ -55,11 +89,13 @@ EpisodeQuality.propTypes = {
title: PropTypes.string, title: PropTypes.string,
quality: PropTypes.object.isRequired, quality: PropTypes.object.isRequired,
size: PropTypes.number, size: PropTypes.number,
isCutoffNotMet: PropTypes.bool isCutoffNotMet: PropTypes.bool,
showRevision: PropTypes.bool
}; };
EpisodeQuality.defaultProps = { EpisodeQuality.defaultProps = {
title: '' title: '',
showRevision: false
}; };
export default EpisodeQuality; export default EpisodeQuality;

View File

@ -28,6 +28,10 @@
text-align: center; text-align: center;
} }
.quality {
white-space: nowrap;
}
.languages { .languages {
width: 100px; width: 100px;
} }

View File

@ -244,7 +244,7 @@ function InteractiveSearchRow(props: InteractiveSearchRowProps) {
</TableRowCell> </TableRowCell>
<TableRowCell className={styles.quality}> <TableRowCell className={styles.quality}>
<EpisodeQuality quality={quality} /> <EpisodeQuality quality={quality} showRevision={true} />
</TableRowCell> </TableRowCell>
<TableRowCell className={styles.customFormatScore}> <TableRowCell className={styles.customFormatScore}>