From c08ae534c591962143d6490089e21a432b88d232 Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 1 Nov 2019 21:31:47 -0400 Subject: [PATCH] Fixed: List Tags and Prevent Delete of Tag if on List --- .../NetImport/EditNetImportModalContent.js | 13 +++++++++++++ .../Tags/Details/TagDetailsModalContent.js | 17 +++++++++++++++++ .../Details/TagDetailsModalContentConnector.js | 14 ++++++++++++-- frontend/src/Settings/Tags/Tag.js | 12 ++++++++++++ frontend/src/Settings/Tags/TagsConnector.js | 12 ++++++++---- src/NzbDrone.Core/Datastore/TableMapping.cs | 1 - src/NzbDrone.Core/Tags/TagDetails.cs | 1 + src/NzbDrone.Core/Tags/TagService.cs | 8 ++++++++ src/Radarr.Api.V2/Tags/TagDetailsResource.cs | 2 ++ 9 files changed, 73 insertions(+), 7 deletions(-) diff --git a/frontend/src/Settings/NetImport/NetImport/EditNetImportModalContent.js b/frontend/src/Settings/NetImport/NetImport/EditNetImportModalContent.js index 39d0233c2..85fefbf25 100644 --- a/frontend/src/Settings/NetImport/NetImport/EditNetImportModalContent.js +++ b/frontend/src/Settings/NetImport/NetImport/EditNetImportModalContent.js @@ -42,6 +42,7 @@ function EditNetImportModalContent(props) { shouldMonitor, qualityProfileId, rootFolderPath, + tags, fields } = item; @@ -136,6 +137,18 @@ function EditNetImportModalContent(props) { /> + + Radarr Tags + + + + { fields.map((field) => { return ( diff --git a/frontend/src/Settings/Tags/Details/TagDetailsModalContent.js b/frontend/src/Settings/Tags/Details/TagDetailsModalContent.js index 9a0e1c76b..53d89b643 100644 --- a/frontend/src/Settings/Tags/Details/TagDetailsModalContent.js +++ b/frontend/src/Settings/Tags/Details/TagDetailsModalContent.js @@ -20,6 +20,7 @@ function TagDetailsModalContent(props) { delayProfiles, notifications, restrictions, + netImports, onModalClose, onDeleteTagPress } = props; @@ -140,6 +141,21 @@ function TagDetailsModalContent(props) { } } + + { + !!netImports.length && +
+ { + netImports.map((item) => { + return ( +
+ {item.name} +
+ ); + }) + } +
+ } @@ -172,6 +188,7 @@ TagDetailsModalContent.propTypes = { delayProfiles: PropTypes.arrayOf(PropTypes.object).isRequired, notifications: PropTypes.arrayOf(PropTypes.object).isRequired, restrictions: PropTypes.arrayOf(PropTypes.object).isRequired, + netImports: PropTypes.arrayOf(PropTypes.object).isRequired, onModalClose: PropTypes.func.isRequired, onDeleteTagPress: PropTypes.func.isRequired }; diff --git a/frontend/src/Settings/Tags/Details/TagDetailsModalContentConnector.js b/frontend/src/Settings/Tags/Details/TagDetailsModalContentConnector.js index 414fa0ff4..c0f500d2a 100644 --- a/frontend/src/Settings/Tags/Details/TagDetailsModalContentConnector.js +++ b/frontend/src/Settings/Tags/Details/TagDetailsModalContentConnector.js @@ -41,18 +41,28 @@ function createMatchingRestrictionsSelector() { ); } +function createMatchingNetImportsSelector() { + return createSelector( + (state, { netImportIds }) => netImportIds, + (state) => state.settings.netImports.items, + findMatchingItems + ); +} + function createMapStateToProps() { return createSelector( createMatchingMovieSelector(), createMatchingDelayProfilesSelector(), createMatchingNotificationsSelector(), createMatchingRestrictionsSelector(), - (movies, delayProfiles, notifications, restrictions) => { + createMatchingNetImportsSelector(), + (movies, delayProfiles, notifications, restrictions, netImports) => { return { movies, delayProfiles, notifications, - restrictions + restrictions, + netImports }; } ); diff --git a/frontend/src/Settings/Tags/Tag.js b/frontend/src/Settings/Tags/Tag.js index 0d02ef62f..b4f7b3bf2 100644 --- a/frontend/src/Settings/Tags/Tag.js +++ b/frontend/src/Settings/Tags/Tag.js @@ -55,6 +55,7 @@ class Tag extends Component { delayProfileIds, notificationIds, restrictionIds, + netImportIds, movieIds } = this.props; @@ -67,6 +68,7 @@ class Tag extends Component { delayProfileIds.length || notificationIds.length || restrictionIds.length || + netImportIds.length || movieIds.length ); @@ -110,6 +112,13 @@ class Tag extends Component { {restrictionIds.length} restriction{restrictionIds.length > 1 && 's'} } + + { + !!netImportIds.length && +
+ {netImportIds.length} list{netImportIds.length > 1 && 's'} +
+ } } @@ -127,6 +136,7 @@ class Tag extends Component { delayProfileIds={delayProfileIds} notificationIds={notificationIds} restrictionIds={restrictionIds} + netImportIds={netImportIds} isOpen={isDetailsModalOpen} onModalClose={this.onDetailsModalClose} onDeleteTagPress={this.onDeleteTagPress} @@ -152,6 +162,7 @@ Tag.propTypes = { delayProfileIds: PropTypes.arrayOf(PropTypes.number).isRequired, notificationIds: PropTypes.arrayOf(PropTypes.number).isRequired, restrictionIds: PropTypes.arrayOf(PropTypes.number).isRequired, + netImportIds: PropTypes.arrayOf(PropTypes.number).isRequired, movieIds: PropTypes.arrayOf(PropTypes.number).isRequired, onConfirmDeleteTag: PropTypes.func.isRequired }; @@ -160,6 +171,7 @@ Tag.defaultProps = { delayProfileIds: [], notificationIds: [], restrictionIds: [], + netImportIds: [], movieIds: [] }; diff --git a/frontend/src/Settings/Tags/TagsConnector.js b/frontend/src/Settings/Tags/TagsConnector.js index dccf9b43d..5784df4ec 100644 --- a/frontend/src/Settings/Tags/TagsConnector.js +++ b/frontend/src/Settings/Tags/TagsConnector.js @@ -3,7 +3,7 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { fetchTagDetails } from 'Store/Actions/tagActions'; -import { fetchDelayProfiles, fetchNotifications, fetchRestrictions } from 'Store/Actions/settingsActions'; +import { fetchDelayProfiles, fetchNotifications, fetchRestrictions, fetchNetImports } from 'Store/Actions/settingsActions'; import Tags from './Tags'; function createMapStateToProps() { @@ -28,7 +28,8 @@ const mapDispatchToProps = { dispatchFetchTagDetails: fetchTagDetails, dispatchFetchDelayProfiles: fetchDelayProfiles, dispatchFetchNotifications: fetchNotifications, - dispatchFetchRestrictions: fetchRestrictions + dispatchFetchRestrictions: fetchRestrictions, + dispatchFetchNetImports: fetchNetImports }; class MetadatasConnector extends Component { @@ -41,13 +42,15 @@ class MetadatasConnector extends Component { dispatchFetchTagDetails, dispatchFetchDelayProfiles, dispatchFetchNotifications, - dispatchFetchRestrictions + dispatchFetchRestrictions, + dispatchFetchNetImports } = this.props; dispatchFetchTagDetails(); dispatchFetchDelayProfiles(); dispatchFetchNotifications(); dispatchFetchRestrictions(); + dispatchFetchNetImports(); } // @@ -66,7 +69,8 @@ MetadatasConnector.propTypes = { dispatchFetchTagDetails: PropTypes.func.isRequired, dispatchFetchDelayProfiles: PropTypes.func.isRequired, dispatchFetchNotifications: PropTypes.func.isRequired, - dispatchFetchRestrictions: PropTypes.func.isRequired + dispatchFetchRestrictions: PropTypes.func.isRequired, + dispatchFetchNetImports: PropTypes.func.isRequired }; export default connect(createMapStateToProps, mapDispatchToProps)(MetadatasConnector); diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 7652e53bc..6314fe835 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -67,7 +67,6 @@ namespace NzbDrone.Core.Datastore Mapper.Entity().RegisterDefinition("NetImport") .Ignore(i => i.Enable) - .Ignore(d => d.Tags) .Relationship() .HasOne(n => n.Profile, n => n.ProfileId); diff --git a/src/NzbDrone.Core/Tags/TagDetails.cs b/src/NzbDrone.Core/Tags/TagDetails.cs index 3eae3a35f..af60d6fb6 100644 --- a/src/NzbDrone.Core/Tags/TagDetails.cs +++ b/src/NzbDrone.Core/Tags/TagDetails.cs @@ -10,6 +10,7 @@ namespace NzbDrone.Core.Tags public List MovieIds { get; set; } public List NotificationIds { get; set; } public List RestrictionIds { get; set; } + public List NetImportIds { get; set; } public List DelayProfileIds { get; set; } public bool InUse diff --git a/src/NzbDrone.Core/Tags/TagService.cs b/src/NzbDrone.Core/Tags/TagService.cs index 6a83ae181..1b9ba6d0a 100644 --- a/src/NzbDrone.Core/Tags/TagService.cs +++ b/src/NzbDrone.Core/Tags/TagService.cs @@ -7,6 +7,7 @@ using NzbDrone.Core.Notifications; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Restrictions; using NzbDrone.Core.Movies; +using NzbDrone.Core.NetImport; namespace NzbDrone.Core.Tags { @@ -28,6 +29,7 @@ namespace NzbDrone.Core.Tags private readonly ITagRepository _repo; private readonly IEventAggregator _eventAggregator; private readonly IDelayProfileService _delayProfileService; + private readonly INetImportFactory _netImportFactory; private readonly INotificationFactory _notificationFactory; private readonly IRestrictionService _restrictionService; private readonly IMovieService _movieService; @@ -35,6 +37,7 @@ namespace NzbDrone.Core.Tags public TagService(ITagRepository repo, IEventAggregator eventAggregator, IDelayProfileService delayProfileService, + INetImportFactory netImportFactory, INotificationFactory notificationFactory, IRestrictionService restrictionService, IMovieService movieService) @@ -42,6 +45,7 @@ namespace NzbDrone.Core.Tags _repo = repo; _eventAggregator = eventAggregator; _delayProfileService = delayProfileService; + _netImportFactory = netImportFactory; _notificationFactory = notificationFactory; _restrictionService = restrictionService; _movieService = movieService; @@ -73,6 +77,7 @@ namespace NzbDrone.Core.Tags { var tag = GetTag(tagId); var delayProfiles = _delayProfileService.AllForTag(tagId); + var netImports = _netImportFactory.AllForTag(tagId); var notifications = _notificationFactory.AllForTag(tagId); var restrictions = _restrictionService.AllForTag(tagId); var movies = _movieService.AllForTag(tagId); @@ -82,6 +87,7 @@ namespace NzbDrone.Core.Tags Id = tagId, Label = tag.Label, DelayProfileIds = delayProfiles.Select(c => c.Id).ToList(), + NetImportIds = netImports.Select(c => c.Id).ToList(), NotificationIds = notifications.Select(c => c.Id).ToList(), RestrictionIds = restrictions.Select(c => c.Id).ToList(), MovieIds = movies.Select(c => c.Id).ToList() @@ -92,6 +98,7 @@ namespace NzbDrone.Core.Tags { var tags = All(); var delayProfiles = _delayProfileService.All(); + var netImports = _netImportFactory.All(); var notifications = _notificationFactory.All(); var restrictions = _restrictionService.All(); var movies = _movieService.GetAllMovies(); @@ -105,6 +112,7 @@ namespace NzbDrone.Core.Tags Id = tag.Id, Label = tag.Label, DelayProfileIds = delayProfiles.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), + NetImportIds = netImports.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), NotificationIds = notifications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), RestrictionIds = restrictions.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), MovieIds = movies.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList() diff --git a/src/Radarr.Api.V2/Tags/TagDetailsResource.cs b/src/Radarr.Api.V2/Tags/TagDetailsResource.cs index 384d2ee0b..74f27c212 100644 --- a/src/Radarr.Api.V2/Tags/TagDetailsResource.cs +++ b/src/Radarr.Api.V2/Tags/TagDetailsResource.cs @@ -11,6 +11,7 @@ namespace Radarr.Api.V2.Tags public List DelayProfileIds { get; set; } public List NotificationIds { get; set; } public List RestrictionIds { get; set; } + public List NetImportIds { get; set; } public List MovieIds { get; set; } } @@ -27,6 +28,7 @@ namespace Radarr.Api.V2.Tags DelayProfileIds = model.DelayProfileIds, NotificationIds = model.NotificationIds, RestrictionIds = model.RestrictionIds, + NetImportIds = model.NetImportIds, MovieIds = model.MovieIds }; }