Fixed: Better sorting of releases in manual search

Fixes #1472
This commit is contained in:
Qstick 2023-02-26 22:54:54 -06:00
parent ed8a979fc6
commit 05b477e9d1
13 changed files with 20 additions and 65 deletions

View file

@ -10,7 +10,7 @@ function SearchIndexFilterMenu(props) {
filters, filters,
customFilters, customFilters,
isDisabled, isDisabled,
onFilterSelect onFilterSelect,
} = props; } = props;
return ( return (
@ -27,15 +27,16 @@ function SearchIndexFilterMenu(props) {
} }
SearchIndexFilterMenu.propTypes = { SearchIndexFilterMenu.propTypes = {
selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired,
customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, customFilters: PropTypes.arrayOf(PropTypes.object).isRequired,
isDisabled: PropTypes.bool.isRequired, isDisabled: PropTypes.bool.isRequired,
onFilterSelect: PropTypes.func.isRequired onFilterSelect: PropTypes.func.isRequired,
}; };
SearchIndexFilterMenu.defaultProps = { SearchIndexFilterMenu.defaultProps = {
showCustomFilters: false showCustomFilters: false,
}; };
export default SearchIndexFilterMenu; export default SearchIndexFilterMenu;

View file

@ -7,18 +7,10 @@ import { align, sortDirections } from 'Helpers/Props';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
function SearchIndexSortMenu(props) { function SearchIndexSortMenu(props) {
const { const { sortKey, sortDirection, isDisabled, onSortSelect } = props;
sortKey,
sortDirection,
isDisabled,
onSortSelect
} = props;
return ( return (
<SortMenu <SortMenu isDisabled={isDisabled} alignMenu={align.RIGHT}>
isDisabled={isDisabled}
alignMenu={align.RIGHT}
>
<MenuContent> <MenuContent>
<SortMenuItem <SortMenuItem
name="protocol" name="protocol"
@ -39,7 +31,7 @@ function SearchIndexSortMenu(props) {
</SortMenuItem> </SortMenuItem>
<SortMenuItem <SortMenuItem
name="title" name="sortTitle"
sortKey={sortKey} sortKey={sortKey}
sortDirection={sortDirection} sortDirection={sortDirection}
onPress={onSortSelect} onPress={onSortSelect}
@ -109,7 +101,7 @@ SearchIndexSortMenu.propTypes = {
sortKey: PropTypes.string, sortKey: PropTypes.string,
sortDirection: PropTypes.oneOf(sortDirections.all), sortDirection: PropTypes.oneOf(sortDirections.all),
isDisabled: PropTypes.bool.isRequired, isDisabled: PropTypes.bool.isRequired,
onSortSelect: PropTypes.func.isRequired onSortSelect: PropTypes.func.isRequired,
}; };
export default SearchIndexSortMenu; export default SearchIndexSortMenu;

View file

@ -6,9 +6,9 @@ import IconButton from 'Components/Link/IconButton';
import Link from 'Components/Link/Link'; import Link from 'Components/Link/Link';
import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton';
import { icons, kinds } from 'Helpers/Props'; import { icons, kinds } from 'Helpers/Props';
import ProtocolLabel from 'Indexer/Index/Table/ProtocolLabel';
import CategoryLabel from 'Search/Table/CategoryLabel'; import CategoryLabel from 'Search/Table/CategoryLabel';
import Peers from 'Search/Table/Peers'; import Peers from 'Search/Table/Peers';
import ProtocolLabel from 'Search/Table/ProtocolLabel';
import dimensions from 'Styles/Variables/dimensions'; import dimensions from 'Styles/Variables/dimensions';
import formatAge from 'Utilities/Number/formatAge'; import formatAge from 'Utilities/Number/formatAge';
import formatBytes from 'Utilities/Number/formatBytes'; import formatBytes from 'Utilities/Number/formatBytes';

View file

@ -1,13 +0,0 @@
.torrent {
composes: label from '~Components/Label.css';
border-color: var(--torrentColor);
background-color: var(--torrentColor);
}
.usenet {
composes: label from '~Components/Label.css';
border-color: var(--usenetColor);
background-color: var(--usenetColor);
}

View file

@ -1,8 +0,0 @@
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
'torrent': string;
'usenet': string;
}
export const cssExports: CssExports;
export default cssExports;

View file

@ -1,20 +0,0 @@
import PropTypes from 'prop-types';
import React from 'react';
import Label from 'Components/Label';
import styles from './ProtocolLabel.css';
function ProtocolLabel({ protocol }) {
const protocolName = protocol === 'usenet' ? 'nzb' : protocol;
return (
<Label className={styles[protocol]}>
{protocolName}
</Label>
);
}
ProtocolLabel.propTypes = {
protocol: PropTypes.string.isRequired
};
export default ProtocolLabel;

View file

@ -4,7 +4,7 @@
flex: 0 0 90px; flex: 0 0 90px;
} }
.title { .sortTitle {
composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css';
flex: 4 0 110px; flex: 4 0 110px;

View file

@ -11,7 +11,7 @@ interface CssExports {
'peers': string; 'peers': string;
'protocol': string; 'protocol': string;
'size': string; 'size': string;
'title': string; 'sortTitle': string;
} }
export const cssExports: CssExports; export const cssExports: CssExports;
export default cssExports; export default cssExports;

View file

@ -11,7 +11,7 @@
flex: 0 0 90px; flex: 0 0 90px;
} }
.title { .sortTitle {
composes: cell; composes: cell;
flex: 4 0 110px; flex: 4 0 110px;

View file

@ -15,7 +15,7 @@ interface CssExports {
'peers': string; 'peers': string;
'protocol': string; 'protocol': string;
'size': string; 'size': string;
'title': string; 'sortTitle': string;
} }
export const cssExports: CssExports; export const cssExports: CssExports;
export default cssExports; export default cssExports;

View file

@ -8,6 +8,7 @@ import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell';
import VirtualTableSelectCell from 'Components/Table/Cells/VirtualTableSelectCell'; import VirtualTableSelectCell from 'Components/Table/Cells/VirtualTableSelectCell';
import Popover from 'Components/Tooltip/Popover'; import Popover from 'Components/Tooltip/Popover';
import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import { icons, kinds, tooltipPositions } from 'Helpers/Props';
import ProtocolLabel from 'Indexer/Index/Table/ProtocolLabel';
import formatDateTime from 'Utilities/Date/formatDateTime'; import formatDateTime from 'Utilities/Date/formatDateTime';
import formatAge from 'Utilities/Number/formatAge'; import formatAge from 'Utilities/Number/formatAge';
import formatBytes from 'Utilities/Number/formatBytes'; import formatBytes from 'Utilities/Number/formatBytes';
@ -15,7 +16,6 @@ import titleCase from 'Utilities/String/titleCase';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import CategoryLabel from './CategoryLabel'; import CategoryLabel from './CategoryLabel';
import Peers from './Peers'; import Peers from './Peers';
import ProtocolLabel from './ProtocolLabel';
import styles from './SearchIndexRow.css'; import styles from './SearchIndexRow.css';
function getDownloadIcon(isGrabbing, isGrabbed, grabError) { function getDownloadIcon(isGrabbing, isGrabbed, grabError) {
@ -165,7 +165,7 @@ class SearchIndexRow extends Component {
); );
} }
if (column.name === 'title') { if (column.name === 'sortTitle') {
return ( return (
<VirtualTableRowCell <VirtualTableRowCell
key={column.name} key={column.name}

View file

@ -65,7 +65,7 @@ export const defaultState = {
isVisible: true isVisible: true
}, },
{ {
name: 'title', name: 'sortTitle',
label: translate('Title'), label: translate('Title'),
isSortable: true, isSortable: true,
isVisible: true isVisible: true

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Routing.Constraints; using Microsoft.AspNetCore.Routing.Constraints;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using Prowlarr.Http.REST; using Prowlarr.Http.REST;
@ -22,6 +23,7 @@ namespace Prowlarr.Api.V1.Search
public string SubGroup { get; set; } public string SubGroup { get; set; }
public string ReleaseHash { get; set; } public string ReleaseHash { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string SortTitle { get; set; }
public bool Approved { get; set; } public bool Approved { get; set; }
public int ImdbId { get; set; } public int ImdbId { get; set; }
public DateTime PublishDate { get; set; } public DateTime PublishDate { get; set; }
@ -77,6 +79,7 @@ namespace Prowlarr.Api.V1.Search
IndexerId = releaseInfo.IndexerId, IndexerId = releaseInfo.IndexerId,
Indexer = releaseInfo.Indexer, Indexer = releaseInfo.Indexer,
Title = releaseInfo.Title, Title = releaseInfo.Title,
SortTitle = releaseInfo.Title.NormalizeTitle(),
ImdbId = releaseInfo.ImdbId, ImdbId = releaseInfo.ImdbId,
PublishDate = releaseInfo.PublishDate, PublishDate = releaseInfo.PublishDate,
CommentUrl = releaseInfo.CommentUrl, CommentUrl = releaseInfo.CommentUrl,