mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
New: Server Side UI Filtering, Error Boundaries (#501)
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
a95191dc3b
commit
64a8d02f77
110 changed files with 1564 additions and 431 deletions
57
frontend/src/InteractiveSearch/Peers.js
Normal file
57
frontend/src/InteractiveSearch/Peers.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { kinds } from 'Helpers/Props';
|
||||
import Label from 'Components/Label';
|
||||
|
||||
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`;
|
||||
}
|
||||
|
||||
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;
|
Loading…
Add table
Add a link
Reference in a new issue