mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 21:12:43 +02:00
Improve sorting indexer by status
This commit is contained in:
@@ -8,6 +8,30 @@ import translate from 'Utilities/String/translate';
|
|||||||
import DisabledIndexerInfo from './DisabledIndexerInfo';
|
import DisabledIndexerInfo from './DisabledIndexerInfo';
|
||||||
import styles from './IndexerStatusCell.css';
|
import styles from './IndexerStatusCell.css';
|
||||||
|
|
||||||
|
function getIconKind(enabled: boolean, redirect: boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
return redirect ? kinds.INFO : kinds.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return kinds.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIconName(enabled: boolean, redirect: boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
return redirect ? icons.REDIRECT : icons.CHECK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return icons.BLOCKLIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIconTooltip(enabled: boolean, redirect: boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
return redirect ? translate('EnabledRedirected') : translate('Enabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
return translate('Disabled');
|
||||||
|
}
|
||||||
|
|
||||||
interface IndexerStatusCellProps {
|
interface IndexerStatusCellProps {
|
||||||
className: string;
|
className: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
@@ -30,19 +54,13 @@ function IndexerStatusCell(props: IndexerStatusCellProps) {
|
|||||||
...otherProps
|
...otherProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const enableKind = redirect ? kinds.INFO : kinds.SUCCESS;
|
|
||||||
const enableIcon = redirect ? icons.REDIRECT : icons.CHECK;
|
|
||||||
const enableTitle = redirect
|
|
||||||
? translate('EnabledRedirected')
|
|
||||||
: translate('Enabled');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Component className={className} {...otherProps}>
|
<Component className={className} {...otherProps}>
|
||||||
<Icon
|
<Icon
|
||||||
className={styles.statusIcon}
|
className={styles.statusIcon}
|
||||||
kind={enabled ? enableKind : kinds.DEFAULT}
|
kind={getIconKind(enabled, redirect)}
|
||||||
name={enabled ? enableIcon : icons.BLOCKLIST}
|
name={getIconName(enabled, redirect)}
|
||||||
title={enabled ? enableTitle : translate('Disabled')}
|
title={getIconTooltip(enabled, redirect)}
|
||||||
/>
|
/>
|
||||||
{status ? (
|
{status ? (
|
||||||
<Popover
|
<Popover
|
||||||
|
@@ -100,8 +100,22 @@ export const filterPredicates = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const sortPredicates = {
|
export const sortPredicates = {
|
||||||
vipExpiration: function(item) {
|
status: function({ enable, redirect }) {
|
||||||
return item.fields.find((field) => field.name === 'vipExpiration')?.value ?? '';
|
let result = 0;
|
||||||
|
|
||||||
|
if (redirect) {
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
result += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
vipExpiration: function({ fields = [] }) {
|
||||||
|
return fields.find((field) => field.name === 'vipExpiration')?.value ?? '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user