Skip to content

Commit

Permalink
New: Show Proper or Repack tag in interactive search
Browse files Browse the repository at this point in the history
(cherry picked from commit efb000529b5dff42829df3ef151e4750a7b15cf6)

Closes #4386
  • Loading branch information
stevietv authored and mynameisbogdan committed Dec 31, 2023
1 parent 7a71c33 commit 9880e2e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
56 changes: 46 additions & 10 deletions frontend/src/Album/TrackQuality.js
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import Label from 'Components/Label';
import { kinds } from 'Helpers/Props';
import formatBytes from 'Utilities/Number/formatBytes';
import translate from 'Utilities/String/translate';

function getTooltip(title, quality, size) {
if (!title) {
Expand All @@ -26,27 +27,60 @@ function getTooltip(title, quality, size) {
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 TrackQuality(props) {
const {
className,
title,
quality,
size,
isCutoffNotMet
isCutoffNotMet,
showRevision
} = props;

if (!quality) {
return null;
}

return (
<Label
className={className}
kind={isCutoffNotMet ? kinds.INVERSE : kinds.DEFAULT}
title={getTooltip(title, quality, size)}
>
{quality.quality.name}
</Label>
<span>
<Label
className={className}
kind={isCutoffNotMet ? kinds.INVERSE : kinds.DEFAULT}
title={getTooltip(title, quality, size)}
>
{quality.quality.name}
</Label>{revisionLabel(className, quality, showRevision)}
</span>
);
}

Expand All @@ -55,11 +89,13 @@ TrackQuality.propTypes = {
title: PropTypes.string,
quality: PropTypes.object.isRequired,
size: PropTypes.number,
isCutoffNotMet: PropTypes.bool
isCutoffNotMet: PropTypes.bool,
showRevision: PropTypes.bool
};

TrackQuality.defaultProps = {
title: ''
title: '',
showRevision: false
};

export default TrackQuality;
4 changes: 4 additions & 0 deletions frontend/src/InteractiveSearch/InteractiveSearchRow.css
Expand Up @@ -22,6 +22,10 @@
text-align: center;
}

.quality {
white-space: nowrap;
}

.customFormatScore {
composes: cell from '~Components/Table/Cells/TableRowCell.css';

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/InteractiveSearch/InteractiveSearchRow.js
Expand Up @@ -178,7 +178,7 @@ class InteractiveSearchRow extends Component {
</TableRowCell>

<TableRowCell className={styles.quality}>
<TrackQuality quality={quality} />
<TrackQuality quality={quality} showRevision={true} />
</TableRowCell>

<TableRowCell className={styles.customFormatScore}>
Expand Down

0 comments on commit 9880e2e

Please sign in to comment.