Fixed: List Tags and Prevent Delete of Tag if on List

pull/2/head
Qstick 5 years ago
parent 816905a506
commit c08ae534c5

@ -42,6 +42,7 @@ function EditNetImportModalContent(props) {
shouldMonitor, shouldMonitor,
qualityProfileId, qualityProfileId,
rootFolderPath, rootFolderPath,
tags,
fields fields
} = item; } = item;
@ -136,6 +137,18 @@ function EditNetImportModalContent(props) {
/> />
</FormGroup> </FormGroup>
<FormGroup>
<FormLabel>Radarr Tags</FormLabel>
<FormInputGroup
type={inputTypes.TAG}
name="tags"
helpText="Add movie from this list with these tags"
{...tags}
onChange={onInputChange}
/>
</FormGroup>
{ {
fields.map((field) => { fields.map((field) => {
return ( return (

@ -20,6 +20,7 @@ function TagDetailsModalContent(props) {
delayProfiles, delayProfiles,
notifications, notifications,
restrictions, restrictions,
netImports,
onModalClose, onModalClose,
onDeleteTagPress onDeleteTagPress
} = props; } = props;
@ -140,6 +141,21 @@ function TagDetailsModalContent(props) {
} }
</FieldSet> </FieldSet>
} }
{
!!netImports.length &&
<FieldSet legend="Lists">
{
netImports.map((item) => {
return (
<div key={item.id}>
{item.name}
</div>
);
})
}
</FieldSet>
}
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
@ -172,6 +188,7 @@ TagDetailsModalContent.propTypes = {
delayProfiles: PropTypes.arrayOf(PropTypes.object).isRequired, delayProfiles: PropTypes.arrayOf(PropTypes.object).isRequired,
notifications: PropTypes.arrayOf(PropTypes.object).isRequired, notifications: PropTypes.arrayOf(PropTypes.object).isRequired,
restrictions: PropTypes.arrayOf(PropTypes.object).isRequired, restrictions: PropTypes.arrayOf(PropTypes.object).isRequired,
netImports: PropTypes.arrayOf(PropTypes.object).isRequired,
onModalClose: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired,
onDeleteTagPress: PropTypes.func.isRequired onDeleteTagPress: PropTypes.func.isRequired
}; };

@ -41,18 +41,28 @@ function createMatchingRestrictionsSelector() {
); );
} }
function createMatchingNetImportsSelector() {
return createSelector(
(state, { netImportIds }) => netImportIds,
(state) => state.settings.netImports.items,
findMatchingItems
);
}
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createMatchingMovieSelector(), createMatchingMovieSelector(),
createMatchingDelayProfilesSelector(), createMatchingDelayProfilesSelector(),
createMatchingNotificationsSelector(), createMatchingNotificationsSelector(),
createMatchingRestrictionsSelector(), createMatchingRestrictionsSelector(),
(movies, delayProfiles, notifications, restrictions) => { createMatchingNetImportsSelector(),
(movies, delayProfiles, notifications, restrictions, netImports) => {
return { return {
movies, movies,
delayProfiles, delayProfiles,
notifications, notifications,
restrictions restrictions,
netImports
}; };
} }
); );

@ -55,6 +55,7 @@ class Tag extends Component {
delayProfileIds, delayProfileIds,
notificationIds, notificationIds,
restrictionIds, restrictionIds,
netImportIds,
movieIds movieIds
} = this.props; } = this.props;
@ -67,6 +68,7 @@ class Tag extends Component {
delayProfileIds.length || delayProfileIds.length ||
notificationIds.length || notificationIds.length ||
restrictionIds.length || restrictionIds.length ||
netImportIds.length ||
movieIds.length movieIds.length
); );
@ -110,6 +112,13 @@ class Tag extends Component {
{restrictionIds.length} restriction{restrictionIds.length > 1 && 's'} {restrictionIds.length} restriction{restrictionIds.length > 1 && 's'}
</div> </div>
} }
{
!!netImportIds.length &&
<div>
{netImportIds.length} list{netImportIds.length > 1 && 's'}
</div>
}
</div> </div>
} }
@ -127,6 +136,7 @@ class Tag extends Component {
delayProfileIds={delayProfileIds} delayProfileIds={delayProfileIds}
notificationIds={notificationIds} notificationIds={notificationIds}
restrictionIds={restrictionIds} restrictionIds={restrictionIds}
netImportIds={netImportIds}
isOpen={isDetailsModalOpen} isOpen={isDetailsModalOpen}
onModalClose={this.onDetailsModalClose} onModalClose={this.onDetailsModalClose}
onDeleteTagPress={this.onDeleteTagPress} onDeleteTagPress={this.onDeleteTagPress}
@ -152,6 +162,7 @@ Tag.propTypes = {
delayProfileIds: PropTypes.arrayOf(PropTypes.number).isRequired, delayProfileIds: PropTypes.arrayOf(PropTypes.number).isRequired,
notificationIds: PropTypes.arrayOf(PropTypes.number).isRequired, notificationIds: PropTypes.arrayOf(PropTypes.number).isRequired,
restrictionIds: PropTypes.arrayOf(PropTypes.number).isRequired, restrictionIds: PropTypes.arrayOf(PropTypes.number).isRequired,
netImportIds: PropTypes.arrayOf(PropTypes.number).isRequired,
movieIds: PropTypes.arrayOf(PropTypes.number).isRequired, movieIds: PropTypes.arrayOf(PropTypes.number).isRequired,
onConfirmDeleteTag: PropTypes.func.isRequired onConfirmDeleteTag: PropTypes.func.isRequired
}; };
@ -160,6 +171,7 @@ Tag.defaultProps = {
delayProfileIds: [], delayProfileIds: [],
notificationIds: [], notificationIds: [],
restrictionIds: [], restrictionIds: [],
netImportIds: [],
movieIds: [] movieIds: []
}; };

@ -3,7 +3,7 @@ import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { fetchTagDetails } from 'Store/Actions/tagActions'; 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'; import Tags from './Tags';
function createMapStateToProps() { function createMapStateToProps() {
@ -28,7 +28,8 @@ const mapDispatchToProps = {
dispatchFetchTagDetails: fetchTagDetails, dispatchFetchTagDetails: fetchTagDetails,
dispatchFetchDelayProfiles: fetchDelayProfiles, dispatchFetchDelayProfiles: fetchDelayProfiles,
dispatchFetchNotifications: fetchNotifications, dispatchFetchNotifications: fetchNotifications,
dispatchFetchRestrictions: fetchRestrictions dispatchFetchRestrictions: fetchRestrictions,
dispatchFetchNetImports: fetchNetImports
}; };
class MetadatasConnector extends Component { class MetadatasConnector extends Component {
@ -41,13 +42,15 @@ class MetadatasConnector extends Component {
dispatchFetchTagDetails, dispatchFetchTagDetails,
dispatchFetchDelayProfiles, dispatchFetchDelayProfiles,
dispatchFetchNotifications, dispatchFetchNotifications,
dispatchFetchRestrictions dispatchFetchRestrictions,
dispatchFetchNetImports
} = this.props; } = this.props;
dispatchFetchTagDetails(); dispatchFetchTagDetails();
dispatchFetchDelayProfiles(); dispatchFetchDelayProfiles();
dispatchFetchNotifications(); dispatchFetchNotifications();
dispatchFetchRestrictions(); dispatchFetchRestrictions();
dispatchFetchNetImports();
} }
// //
@ -66,7 +69,8 @@ MetadatasConnector.propTypes = {
dispatchFetchTagDetails: PropTypes.func.isRequired, dispatchFetchTagDetails: PropTypes.func.isRequired,
dispatchFetchDelayProfiles: PropTypes.func.isRequired, dispatchFetchDelayProfiles: PropTypes.func.isRequired,
dispatchFetchNotifications: 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); export default connect(createMapStateToProps, mapDispatchToProps)(MetadatasConnector);

@ -67,7 +67,6 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity<NetImportDefinition>().RegisterDefinition("NetImport") Mapper.Entity<NetImportDefinition>().RegisterDefinition("NetImport")
.Ignore(i => i.Enable) .Ignore(i => i.Enable)
.Ignore(d => d.Tags)
.Relationship() .Relationship()
.HasOne(n => n.Profile, n => n.ProfileId); .HasOne(n => n.Profile, n => n.ProfileId);

@ -10,6 +10,7 @@ namespace NzbDrone.Core.Tags
public List<int> MovieIds { get; set; } public List<int> MovieIds { get; set; }
public List<int> NotificationIds { get; set; } public List<int> NotificationIds { get; set; }
public List<int> RestrictionIds { get; set; } public List<int> RestrictionIds { get; set; }
public List<int> NetImportIds { get; set; }
public List<int> DelayProfileIds { get; set; } public List<int> DelayProfileIds { get; set; }
public bool InUse public bool InUse

@ -7,6 +7,7 @@ using NzbDrone.Core.Notifications;
using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Restrictions; using NzbDrone.Core.Restrictions;
using NzbDrone.Core.Movies; using NzbDrone.Core.Movies;
using NzbDrone.Core.NetImport;
namespace NzbDrone.Core.Tags namespace NzbDrone.Core.Tags
{ {
@ -28,6 +29,7 @@ namespace NzbDrone.Core.Tags
private readonly ITagRepository _repo; private readonly ITagRepository _repo;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IDelayProfileService _delayProfileService; private readonly IDelayProfileService _delayProfileService;
private readonly INetImportFactory _netImportFactory;
private readonly INotificationFactory _notificationFactory; private readonly INotificationFactory _notificationFactory;
private readonly IRestrictionService _restrictionService; private readonly IRestrictionService _restrictionService;
private readonly IMovieService _movieService; private readonly IMovieService _movieService;
@ -35,6 +37,7 @@ namespace NzbDrone.Core.Tags
public TagService(ITagRepository repo, public TagService(ITagRepository repo,
IEventAggregator eventAggregator, IEventAggregator eventAggregator,
IDelayProfileService delayProfileService, IDelayProfileService delayProfileService,
INetImportFactory netImportFactory,
INotificationFactory notificationFactory, INotificationFactory notificationFactory,
IRestrictionService restrictionService, IRestrictionService restrictionService,
IMovieService movieService) IMovieService movieService)
@ -42,6 +45,7 @@ namespace NzbDrone.Core.Tags
_repo = repo; _repo = repo;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_delayProfileService = delayProfileService; _delayProfileService = delayProfileService;
_netImportFactory = netImportFactory;
_notificationFactory = notificationFactory; _notificationFactory = notificationFactory;
_restrictionService = restrictionService; _restrictionService = restrictionService;
_movieService = movieService; _movieService = movieService;
@ -73,6 +77,7 @@ namespace NzbDrone.Core.Tags
{ {
var tag = GetTag(tagId); var tag = GetTag(tagId);
var delayProfiles = _delayProfileService.AllForTag(tagId); var delayProfiles = _delayProfileService.AllForTag(tagId);
var netImports = _netImportFactory.AllForTag(tagId);
var notifications = _notificationFactory.AllForTag(tagId); var notifications = _notificationFactory.AllForTag(tagId);
var restrictions = _restrictionService.AllForTag(tagId); var restrictions = _restrictionService.AllForTag(tagId);
var movies = _movieService.AllForTag(tagId); var movies = _movieService.AllForTag(tagId);
@ -82,6 +87,7 @@ namespace NzbDrone.Core.Tags
Id = tagId, Id = tagId,
Label = tag.Label, Label = tag.Label,
DelayProfileIds = delayProfiles.Select(c => c.Id).ToList(), DelayProfileIds = delayProfiles.Select(c => c.Id).ToList(),
NetImportIds = netImports.Select(c => c.Id).ToList(),
NotificationIds = notifications.Select(c => c.Id).ToList(), NotificationIds = notifications.Select(c => c.Id).ToList(),
RestrictionIds = restrictions.Select(c => c.Id).ToList(), RestrictionIds = restrictions.Select(c => c.Id).ToList(),
MovieIds = movies.Select(c => c.Id).ToList() MovieIds = movies.Select(c => c.Id).ToList()
@ -92,6 +98,7 @@ namespace NzbDrone.Core.Tags
{ {
var tags = All(); var tags = All();
var delayProfiles = _delayProfileService.All(); var delayProfiles = _delayProfileService.All();
var netImports = _netImportFactory.All();
var notifications = _notificationFactory.All(); var notifications = _notificationFactory.All();
var restrictions = _restrictionService.All(); var restrictions = _restrictionService.All();
var movies = _movieService.GetAllMovies(); var movies = _movieService.GetAllMovies();
@ -105,6 +112,7 @@ namespace NzbDrone.Core.Tags
Id = tag.Id, Id = tag.Id,
Label = tag.Label, Label = tag.Label,
DelayProfileIds = delayProfiles.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), 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(), 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(), 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() MovieIds = movies.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList()

@ -11,6 +11,7 @@ namespace Radarr.Api.V2.Tags
public List<int> DelayProfileIds { get; set; } public List<int> DelayProfileIds { get; set; }
public List<int> NotificationIds { get; set; } public List<int> NotificationIds { get; set; }
public List<int> RestrictionIds { get; set; } public List<int> RestrictionIds { get; set; }
public List<int> NetImportIds { get; set; }
public List<int> MovieIds { get; set; } public List<int> MovieIds { get; set; }
} }
@ -27,6 +28,7 @@ namespace Radarr.Api.V2.Tags
DelayProfileIds = model.DelayProfileIds, DelayProfileIds = model.DelayProfileIds,
NotificationIds = model.NotificationIds, NotificationIds = model.NotificationIds,
RestrictionIds = model.RestrictionIds, RestrictionIds = model.RestrictionIds,
NetImportIds = model.NetImportIds,
MovieIds = model.MovieIds MovieIds = model.MovieIds
}; };
} }

Loading…
Cancel
Save