mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 04:51:45 +02:00
Trigger manual search from any History Item
This commit is contained in:
@@ -63,6 +63,32 @@ function HistoryDetails(props) {
|
||||
);
|
||||
}
|
||||
|
||||
if (eventType === 'releaseGrabbed') {
|
||||
const {
|
||||
source
|
||||
} = data;
|
||||
|
||||
return (
|
||||
<DescriptionList>
|
||||
{
|
||||
!!indexer &&
|
||||
<DescriptionListItem
|
||||
title={translate('Indexer')}
|
||||
data={indexer.name}
|
||||
/>
|
||||
}
|
||||
|
||||
{
|
||||
!!data &&
|
||||
<DescriptionListItem
|
||||
title={'Source'}
|
||||
data={source}
|
||||
/>
|
||||
}
|
||||
</DescriptionList>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<DescriptionList>
|
||||
<DescriptionListItem
|
||||
|
@@ -9,14 +9,16 @@ function getIconName(eventType) {
|
||||
switch (eventType) {
|
||||
case 'indexerQuery':
|
||||
return icons.SEARCH;
|
||||
case 'releaseGrabbed':
|
||||
return icons.DOWNLOAD;
|
||||
default:
|
||||
return icons.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
function getIconKind(eventType) {
|
||||
switch (eventType) {
|
||||
case 'downloadFailed':
|
||||
function getIconKind(data) {
|
||||
switch (data.successful) {
|
||||
case 'False':
|
||||
return kinds.DANGER;
|
||||
default:
|
||||
return kinds.DEFAULT;
|
||||
@@ -27,6 +29,8 @@ function getTooltip(eventType, data, indexer) {
|
||||
switch (eventType) {
|
||||
case 'indexerQuery':
|
||||
return `Query "${data.query}" sent to ${indexer.name}`;
|
||||
case 'releaseGrabbed':
|
||||
return `Release grabbed from ${indexer.name}`;
|
||||
default:
|
||||
return 'Unknown event';
|
||||
}
|
||||
@@ -34,7 +38,7 @@ function getTooltip(eventType, data, indexer) {
|
||||
|
||||
function HistoryEventTypeCell({ eventType, data, indexer }) {
|
||||
const iconName = getIconName(eventType);
|
||||
const iconKind = getIconKind(eventType);
|
||||
const iconKind = getIconKind(data);
|
||||
const tooltip = getTooltip(eventType, data, indexer);
|
||||
|
||||
return (
|
||||
|
@@ -35,6 +35,25 @@ class HistoryRow extends Component {
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onSearchPress = () => {
|
||||
const {
|
||||
indexer,
|
||||
data
|
||||
} = this.props;
|
||||
|
||||
let categories = [];
|
||||
|
||||
if (data.categories) {
|
||||
categories = data.categories.split(',').map((item) => {
|
||||
return parseInt(item);
|
||||
});
|
||||
}
|
||||
|
||||
console.log(categories);
|
||||
|
||||
this.props.onSearchPress(data.query, indexer.id, categories);
|
||||
}
|
||||
|
||||
onDetailsPress = () => {
|
||||
this.setState({ isDetailsModalOpen: true });
|
||||
}
|
||||
@@ -115,7 +134,11 @@ class HistoryRow extends Component {
|
||||
key={name}
|
||||
className={styles.indexer}
|
||||
>
|
||||
{`${data.elapsedTime}ms`}
|
||||
{
|
||||
data.elapsedTime ?
|
||||
`${data.elapsedTime}ms` :
|
||||
null
|
||||
}
|
||||
</TableRowCell>
|
||||
);
|
||||
}
|
||||
@@ -146,9 +169,19 @@ class HistoryRow extends Component {
|
||||
key={name}
|
||||
className={styles.details}
|
||||
>
|
||||
{
|
||||
eventType === 'indexerQuery' ?
|
||||
<IconButton
|
||||
name={icons.SEARCH}
|
||||
onPress={this.onSearchPress}
|
||||
title='Repeat Search'
|
||||
/> :
|
||||
null
|
||||
}
|
||||
<IconButton
|
||||
name={icons.INFO}
|
||||
onPress={this.onDetailsPress}
|
||||
title='History Details'
|
||||
/>
|
||||
</TableRowCell>
|
||||
);
|
||||
@@ -186,7 +219,8 @@ HistoryRow.propTypes = {
|
||||
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
shortDateFormat: PropTypes.string.isRequired,
|
||||
timeFormat: PropTypes.string.isRequired,
|
||||
onMarkAsFailedPress: PropTypes.func.isRequired
|
||||
onMarkAsFailedPress: PropTypes.func.isRequired,
|
||||
onSearchPress: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default HistoryRow;
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import { push } from 'connected-react-router';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { fetchHistory, markAsFailed } from 'Store/Actions/historyActions';
|
||||
import { setSearchDefault } from 'Store/Actions/releaseActions';
|
||||
import createIndexerSelector from 'Store/Selectors/createIndexerSelector';
|
||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||
import HistoryRow from './HistoryRow';
|
||||
@@ -23,7 +25,9 @@ function createMapStateToProps() {
|
||||
|
||||
const mapDispatchToProps = {
|
||||
fetchHistory,
|
||||
markAsFailed
|
||||
markAsFailed,
|
||||
setSearchDefault,
|
||||
push
|
||||
};
|
||||
|
||||
class HistoryRowConnector extends Component {
|
||||
@@ -44,6 +48,11 @@ class HistoryRowConnector extends Component {
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onSearchPress = (term, indexerId, categories) => {
|
||||
this.props.setSearchDefault({ searchQuery: term, searchIndexerIds: [indexerId], searchCategories: categories });
|
||||
this.props.push(`${window.Prowlarr.urlBase}search`);
|
||||
}
|
||||
|
||||
onMarkAsFailedPress = () => {
|
||||
this.props.markAsFailed({ id: this.props.id });
|
||||
}
|
||||
@@ -56,6 +65,7 @@ class HistoryRowConnector extends Component {
|
||||
<HistoryRow
|
||||
{...this.props}
|
||||
onMarkAsFailedPress={this.onMarkAsFailedPress}
|
||||
onSearchPress={this.onSearchPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -67,7 +77,9 @@ HistoryRowConnector.propTypes = {
|
||||
isMarkingAsFailed: PropTypes.bool,
|
||||
markAsFailedError: PropTypes.object,
|
||||
fetchHistory: PropTypes.func.isRequired,
|
||||
markAsFailed: PropTypes.func.isRequired
|
||||
markAsFailed: PropTypes.func.isRequired,
|
||||
setSearchDefault: PropTypes.func.isRequired,
|
||||
push: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(HistoryRowConnector);
|
||||
|
Reference in New Issue
Block a user