1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-20 09:52:46 +01:00
Radarr/frontend/src/Movie/MovieQuality.js

78 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-11-23 08:04:42 +01:00
import PropTypes from 'prop-types';
import React from 'react';
import Label from 'Components/Label';
import { kinds } from 'Helpers/Props';
import formatBytes from 'Utilities/Number/formatBytes';
2018-11-23 08:04:42 +01:00
function getTooltip(title, quality, size, isMonitored, isCutoffNotMet) {
2018-11-23 08:04:42 +01:00
const revision = quality.revision;
if (revision.real && revision.real > 0) {
title += ' [REAL]';
}
if (revision.version && revision.version > 1) {
title += ' [PROPER]';
}
if (size) {
title += ` - ${formatBytes(size)}`;
}
if (!isMonitored) {
title += ' [Not Monitored]';
} else if (isCutoffNotMet) {
title += ' [Cutoff Not Met]';
}
2018-11-23 08:04:42 +01:00
return title;
}
function MovieQuality(props) {
const {
className,
title,
quality,
size,
isMonitored,
2018-11-23 08:04:42 +01:00
isCutoffNotMet
} = props;
let kind = kinds.DEFAULT;
if (!isMonitored) {
kind = kinds.DISABLED;
} else if (isCutoffNotMet) {
kind = kinds.INVERSE;
}
if (!quality) {
return null;
}
2018-11-23 08:04:42 +01:00
return (
<Label
className={className}
kind={kind}
title={getTooltip(title, quality, size, isMonitored, isCutoffNotMet)}
2018-11-23 08:04:42 +01:00
>
{quality.quality.name}
</Label>
);
}
MovieQuality.propTypes = {
className: PropTypes.string,
title: PropTypes.string,
quality: PropTypes.object.isRequired,
size: PropTypes.number,
isMonitored: PropTypes.bool,
2018-11-23 08:04:42 +01:00
isCutoffNotMet: PropTypes.bool
};
MovieQuality.defaultProps = {
title: '',
isMonitored: true
2018-11-23 08:04:42 +01:00
};
export default MovieQuality;