2018-11-23 08:04:42 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import Label from 'Components/Label';
|
2020-07-28 20:47:25 +02:00
|
|
|
import { kinds } from 'Helpers/Props';
|
|
|
|
import formatBytes from 'Utilities/Number/formatBytes';
|
2018-11-23 08:04:42 +01:00
|
|
|
|
2019-12-22 20:15:32 +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)}`;
|
|
|
|
}
|
|
|
|
|
2019-12-22 20:15:32 +01:00
|
|
|
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,
|
2019-12-22 20:15:32 +01:00
|
|
|
isMonitored,
|
2018-11-23 08:04:42 +01:00
|
|
|
isCutoffNotMet
|
|
|
|
} = props;
|
|
|
|
|
2019-12-22 20:15:32 +01:00
|
|
|
let kind = kinds.DEFAULT;
|
|
|
|
if (!isMonitored) {
|
|
|
|
kind = kinds.DISABLED;
|
|
|
|
} else if (isCutoffNotMet) {
|
|
|
|
kind = kinds.INVERSE;
|
|
|
|
}
|
|
|
|
|
2020-04-09 03:31:47 +02:00
|
|
|
if (!quality) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-11-23 08:04:42 +01:00
|
|
|
return (
|
|
|
|
<Label
|
|
|
|
className={className}
|
2019-12-22 20:15:32 +01:00
|
|
|
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,
|
2019-12-22 20:15:32 +01:00
|
|
|
isMonitored: PropTypes.bool,
|
2018-11-23 08:04:42 +01:00
|
|
|
isCutoffNotMet: PropTypes.bool
|
|
|
|
};
|
|
|
|
|
|
|
|
MovieQuality.defaultProps = {
|
2019-12-22 20:15:32 +01:00
|
|
|
title: '',
|
|
|
|
isMonitored: true
|
2018-11-23 08:04:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default MovieQuality;
|