You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.5 KiB
78 lines
1.5 KiB
6 years ago
|
import PropTypes from 'prop-types';
|
||
|
import React from 'react';
|
||
|
import Label from 'Components/Label';
|
||
4 years ago
|
import { kinds } from 'Helpers/Props';
|
||
|
import formatBytes from 'Utilities/Number/formatBytes';
|
||
6 years ago
|
|
||
4 years ago
|
function getTooltip(title, quality, size, isMonitored, isCutoffNotMet) {
|
||
6 years ago
|
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)}`;
|
||
|
}
|
||
|
|
||
4 years ago
|
if (!isMonitored) {
|
||
|
title += ' [Not Monitored]';
|
||
|
} else if (isCutoffNotMet) {
|
||
|
title += ' [Cutoff Not Met]';
|
||
|
}
|
||
|
|
||
6 years ago
|
return title;
|
||
|
}
|
||
|
|
||
|
function MovieQuality(props) {
|
||
|
const {
|
||
|
className,
|
||
|
title,
|
||
|
quality,
|
||
|
size,
|
||
4 years ago
|
isMonitored,
|
||
6 years ago
|
isCutoffNotMet
|
||
|
} = props;
|
||
|
|
||
4 years ago
|
let kind = kinds.DEFAULT;
|
||
|
if (!isMonitored) {
|
||
|
kind = kinds.DISABLED;
|
||
|
} else if (isCutoffNotMet) {
|
||
|
kind = kinds.INVERSE;
|
||
|
}
|
||
|
|
||
4 years ago
|
if (!quality) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
6 years ago
|
return (
|
||
|
<Label
|
||
|
className={className}
|
||
4 years ago
|
kind={kind}
|
||
|
title={getTooltip(title, quality, size, isMonitored, isCutoffNotMet)}
|
||
6 years ago
|
>
|
||
|
{quality.quality.name}
|
||
|
</Label>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
MovieQuality.propTypes = {
|
||
|
className: PropTypes.string,
|
||
|
title: PropTypes.string,
|
||
|
quality: PropTypes.object.isRequired,
|
||
|
size: PropTypes.number,
|
||
4 years ago
|
isMonitored: PropTypes.bool,
|
||
6 years ago
|
isCutoffNotMet: PropTypes.bool
|
||
|
};
|
||
|
|
||
|
MovieQuality.defaultProps = {
|
||
4 years ago
|
title: '',
|
||
|
isMonitored: true
|
||
6 years ago
|
};
|
||
|
|
||
|
export default MovieQuality;
|