1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00
Radarr/frontend/src/InteractiveSearch/Peers.js

58 lines
1016 B
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';
2018-11-23 08:04:42 +01:00
function getKind(seeders) {
if (seeders > 50) {
return kinds.PRIMARY;
}
if (seeders > 10) {
return kinds.INFO;
}
if (seeders > 0) {
return kinds.WARNING;
}
return kinds.DANGER;
}
function getPeersTooltipPart(peers, peersUnit) {
if (peers == null) {
return `Unknown ${peersUnit}s`;
2018-11-23 08:04:42 +01:00
}
if (peers === 1) {
return `1 ${peersUnit}`;
}
return `${peers} ${peersUnit}s`;
}
function Peers(props) {
const {
seeders,
leechers
} = props;
const kind = getKind(seeders);
return (
<Label
kind={kind}
title={`${getPeersTooltipPart(seeders, 'seeder')}, ${getPeersTooltipPart(leechers, 'leecher')}`}
>
{seeders == null ? '-' : seeders} / {leechers == null ? '-' : leechers}
</Label>
);
}
Peers.propTypes = {
seeders: PropTypes.number,
leechers: PropTypes.number
};
export default Peers;