mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Fixed: (Tags) Show applications in tag details
This commit is contained in:
@@ -17,6 +17,7 @@ function TagDetailsModalContent(props) {
|
||||
indexers,
|
||||
notifications,
|
||||
indexerProxies,
|
||||
applications,
|
||||
onModalClose,
|
||||
onDeleteTagPress
|
||||
} = props;
|
||||
@@ -79,6 +80,21 @@ function TagDetailsModalContent(props) {
|
||||
}
|
||||
</FieldSet>
|
||||
}
|
||||
|
||||
{
|
||||
!!applications.length &&
|
||||
<FieldSet legend={translate('Applications')}>
|
||||
{
|
||||
applications.map((item) => {
|
||||
return (
|
||||
<div key={item.id}>
|
||||
{item.name}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
}
|
||||
</FieldSet>
|
||||
}
|
||||
</ModalBody>
|
||||
|
||||
<ModalFooter>
|
||||
@@ -110,6 +126,7 @@ TagDetailsModalContent.propTypes = {
|
||||
indexers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
notifications: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
indexerProxies: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
applications: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onModalClose: PropTypes.func.isRequired,
|
||||
onDeleteTagPress: PropTypes.func.isRequired
|
||||
};
|
||||
|
@@ -18,16 +18,24 @@ function createMatchingIndexersSelector() {
|
||||
|
||||
function createMatchingIndexerProxiesSelector() {
|
||||
return createSelector(
|
||||
(state, { notificationIds }) => notificationIds,
|
||||
(state) => state.settings.notifications.items,
|
||||
(state, { indexerProxyIds }) => indexerProxyIds,
|
||||
(state) => state.settings.indexerProxies.items,
|
||||
findMatchingItems
|
||||
);
|
||||
}
|
||||
|
||||
function createMatchingNotificationsSelector() {
|
||||
return createSelector(
|
||||
(state, { indexerProxyIds }) => indexerProxyIds,
|
||||
(state) => state.settings.indexerProxies.items,
|
||||
(state, { notificationIds }) => notificationIds,
|
||||
(state) => state.settings.notifications.items,
|
||||
findMatchingItems
|
||||
);
|
||||
}
|
||||
|
||||
function createMatchingApplicationsSelector() {
|
||||
return createSelector(
|
||||
(state, { applicationIds }) => applicationIds,
|
||||
(state) => state.settings.applications.items,
|
||||
findMatchingItems
|
||||
);
|
||||
}
|
||||
@@ -37,11 +45,13 @@ function createMapStateToProps() {
|
||||
createMatchingIndexersSelector(),
|
||||
createMatchingIndexerProxiesSelector(),
|
||||
createMatchingNotificationsSelector(),
|
||||
(indexers, indexerProxies, notifications) => {
|
||||
createMatchingApplicationsSelector(),
|
||||
(indexers, indexerProxies, notifications, applications) => {
|
||||
return {
|
||||
indexers,
|
||||
indexerProxies,
|
||||
notifications
|
||||
notifications,
|
||||
applications
|
||||
};
|
||||
}
|
||||
);
|
||||
|
@@ -55,7 +55,8 @@ class Tag extends Component {
|
||||
label,
|
||||
notificationIds,
|
||||
indexerIds,
|
||||
indexerProxyIds
|
||||
indexerProxyIds,
|
||||
applicationIds
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
@@ -66,7 +67,8 @@ class Tag extends Component {
|
||||
const isTagUsed = !!(
|
||||
indexerIds.length ||
|
||||
notificationIds.length ||
|
||||
indexerProxyIds.length
|
||||
indexerProxyIds.length ||
|
||||
applicationIds.length
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -102,6 +104,13 @@ class Tag extends Component {
|
||||
{indexerProxyIds.length} {indexerProxyIds.length > 1 ? translate('IndexerProxies') : translate('IndexerProxy')}
|
||||
</div>
|
||||
}
|
||||
|
||||
{
|
||||
!!applicationIds.length &&
|
||||
<div>
|
||||
{applicationIds.length} {applicationIds.length > 1 ? translate('Applications') : translate('Application')}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -118,6 +127,7 @@ class Tag extends Component {
|
||||
indexerIds={indexerIds}
|
||||
notificationIds={notificationIds}
|
||||
indexerProxyIds={indexerProxyIds}
|
||||
applicationIds={applicationIds}
|
||||
isOpen={isDetailsModalOpen}
|
||||
onModalClose={this.onDetailsModalClose}
|
||||
onDeleteTagPress={this.onDeleteTagPress}
|
||||
@@ -143,13 +153,15 @@ Tag.propTypes = {
|
||||
notificationIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
indexerIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
indexerProxyIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
applicationIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
onConfirmDeleteTag: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
Tag.defaultProps = {
|
||||
indexerIds: [],
|
||||
notificationIds: [],
|
||||
indexerProxyIds: []
|
||||
indexerProxyIds: [],
|
||||
applicationIds: []
|
||||
};
|
||||
|
||||
export default Tag;
|
||||
|
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { fetchIndexerProxies, fetchNotifications } from 'Store/Actions/settingsActions';
|
||||
import { fetchApplications, fetchIndexerProxies, fetchNotifications } from 'Store/Actions/settingsActions';
|
||||
import { fetchTagDetails } from 'Store/Actions/tagActions';
|
||||
import Tags from './Tags';
|
||||
|
||||
@@ -27,7 +27,8 @@ function createMapStateToProps() {
|
||||
const mapDispatchToProps = {
|
||||
dispatchFetchTagDetails: fetchTagDetails,
|
||||
dispatchFetchNotifications: fetchNotifications,
|
||||
dispatchFetchIndexerProxies: fetchIndexerProxies
|
||||
dispatchFetchIndexerProxies: fetchIndexerProxies,
|
||||
dispatchFetchApplications: fetchApplications
|
||||
};
|
||||
|
||||
class MetadatasConnector extends Component {
|
||||
@@ -39,12 +40,14 @@ class MetadatasConnector extends Component {
|
||||
const {
|
||||
dispatchFetchTagDetails,
|
||||
dispatchFetchNotifications,
|
||||
dispatchFetchIndexerProxies
|
||||
dispatchFetchIndexerProxies,
|
||||
dispatchFetchApplications
|
||||
} = this.props;
|
||||
|
||||
dispatchFetchTagDetails();
|
||||
dispatchFetchNotifications();
|
||||
dispatchFetchIndexerProxies();
|
||||
dispatchFetchApplications();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -62,7 +65,8 @@ class MetadatasConnector extends Component {
|
||||
MetadatasConnector.propTypes = {
|
||||
dispatchFetchTagDetails: PropTypes.func.isRequired,
|
||||
dispatchFetchNotifications: PropTypes.func.isRequired,
|
||||
dispatchFetchIndexerProxies: PropTypes.func.isRequired
|
||||
dispatchFetchIndexerProxies: PropTypes.func.isRequired,
|
||||
dispatchFetchApplications: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(MetadatasConnector);
|
||||
|
@@ -10,13 +10,8 @@ namespace NzbDrone.Core.Tags
|
||||
public List<int> NotificationIds { get; set; }
|
||||
public List<int> IndexerIds { get; set; }
|
||||
public List<int> IndexerProxyIds { get; set; }
|
||||
public List<int> ApplicationIds { get; set; }
|
||||
|
||||
public bool InUse
|
||||
{
|
||||
get
|
||||
{
|
||||
return NotificationIds.Any() || IndexerIds.Any() || IndexerProxyIds.Any();
|
||||
}
|
||||
}
|
||||
public bool InUse => NotificationIds.Any() || IndexerIds.Any() || IndexerProxyIds.Any() || ApplicationIds.Any();
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Applications;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.IndexerProxies;
|
||||
using NzbDrone.Core.Indexers;
|
||||
@@ -28,18 +29,21 @@ namespace NzbDrone.Core.Tags
|
||||
private readonly INotificationFactory _notificationFactory;
|
||||
private readonly IIndexerFactory _indexerFactory;
|
||||
private readonly IIndexerProxyFactory _indexerProxyFactory;
|
||||
private readonly IApplicationFactory _applicationFactory;
|
||||
|
||||
public TagService(ITagRepository repo,
|
||||
IEventAggregator eventAggregator,
|
||||
INotificationFactory notificationFactory,
|
||||
IIndexerFactory indexerFactory,
|
||||
IIndexerProxyFactory indexerProxyFactory)
|
||||
IIndexerProxyFactory indexerProxyFactory,
|
||||
IApplicationFactory applicationFactory)
|
||||
{
|
||||
_repo = repo;
|
||||
_eventAggregator = eventAggregator;
|
||||
_notificationFactory = notificationFactory;
|
||||
_indexerFactory = indexerFactory;
|
||||
_indexerProxyFactory = indexerProxyFactory;
|
||||
_applicationFactory = applicationFactory;
|
||||
}
|
||||
|
||||
public Tag GetTag(int tagId)
|
||||
@@ -70,6 +74,7 @@ namespace NzbDrone.Core.Tags
|
||||
var notifications = _notificationFactory.AllForTag(tagId);
|
||||
var indexers = _indexerFactory.AllForTag(tagId);
|
||||
var indexerProxies = _indexerProxyFactory.AllForTag(tagId);
|
||||
var applications = _applicationFactory.AllForTag(tagId);
|
||||
|
||||
return new TagDetails
|
||||
{
|
||||
@@ -77,7 +82,8 @@ namespace NzbDrone.Core.Tags
|
||||
Label = tag.Label,
|
||||
NotificationIds = notifications.Select(c => c.Id).ToList(),
|
||||
IndexerIds = indexers.Select(c => c.Id).ToList(),
|
||||
IndexerProxyIds = indexerProxies.Select(c => c.Id).ToList()
|
||||
IndexerProxyIds = indexerProxies.Select(c => c.Id).ToList(),
|
||||
ApplicationIds = applications.Select(c => c.Id).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -87,6 +93,7 @@ namespace NzbDrone.Core.Tags
|
||||
var notifications = _notificationFactory.All();
|
||||
var indexers = _indexerFactory.All();
|
||||
var indexerProxies = _indexerProxyFactory.All();
|
||||
var applications = _applicationFactory.All();
|
||||
|
||||
var details = new List<TagDetails>();
|
||||
|
||||
@@ -98,7 +105,8 @@ namespace NzbDrone.Core.Tags
|
||||
Label = tag.Label,
|
||||
NotificationIds = notifications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
|
||||
IndexerIds = indexers.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
|
||||
IndexerProxyIds = indexerProxies.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList()
|
||||
IndexerProxyIds = indexerProxies.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
|
||||
ApplicationIds = applications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList()
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,7 @@ namespace Prowlarr.Api.V1.Tags
|
||||
public List<int> NotificationIds { get; set; }
|
||||
public List<int> IndexerIds { get; set; }
|
||||
public List<int> IndexerProxyIds { get; set; }
|
||||
public List<int> ApplicationIds { get; set; }
|
||||
}
|
||||
|
||||
public static class TagDetailsResourceMapper
|
||||
@@ -28,7 +29,8 @@ namespace Prowlarr.Api.V1.Tags
|
||||
Label = model.Label,
|
||||
NotificationIds = model.NotificationIds,
|
||||
IndexerIds = model.IndexerIds,
|
||||
IndexerProxyIds = model.IndexerProxyIds
|
||||
IndexerProxyIds = model.IndexerProxyIds,
|
||||
ApplicationIds = model.ApplicationIds
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user