mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-17 21:25:39 -04:00
New: Download Client Tags
(cherry picked from commit f6ae9fd6c5173cbf1540341fa99d2f120be1d28e)
This commit is contained in:
@@ -3,6 +3,7 @@ import React, { Component } from 'react';
|
||||
import Card from 'Components/Card';
|
||||
import Label from 'Components/Label';
|
||||
import ConfirmModal from 'Components/Modal/ConfirmModal';
|
||||
import TagList from 'Components/TagList';
|
||||
import { kinds } from 'Helpers/Props';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import EditDownloadClientModalConnector from './EditDownloadClientModalConnector';
|
||||
@@ -56,7 +57,9 @@ class DownloadClient extends Component {
|
||||
id,
|
||||
name,
|
||||
enable,
|
||||
priority
|
||||
priority,
|
||||
tags,
|
||||
tagList
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@@ -94,6 +97,11 @@ class DownloadClient extends Component {
|
||||
}
|
||||
</div>
|
||||
|
||||
<TagList
|
||||
tags={tags}
|
||||
tagList={tagList}
|
||||
/>
|
||||
|
||||
<EditDownloadClientModalConnector
|
||||
id={id}
|
||||
isOpen={this.state.isEditDownloadClientModalOpen}
|
||||
@@ -120,6 +128,8 @@ DownloadClient.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
enable: PropTypes.bool.isRequired,
|
||||
priority: PropTypes.number.isRequired,
|
||||
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onConfirmDeleteDownloadClient: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class DownloadClients extends Component {
|
||||
const {
|
||||
items,
|
||||
onConfirmDeleteDownloadClient,
|
||||
tagList,
|
||||
...otherProps
|
||||
} = this.props;
|
||||
|
||||
@@ -71,6 +72,7 @@ class DownloadClients extends Component {
|
||||
<DownloadClient
|
||||
key={item.id}
|
||||
{...item}
|
||||
tagList={tagList}
|
||||
onConfirmDeleteDownloadClient={onConfirmDeleteDownloadClient}
|
||||
/>
|
||||
);
|
||||
@@ -109,6 +111,7 @@ DownloadClients.propTypes = {
|
||||
isFetching: PropTypes.bool.isRequired,
|
||||
error: PropTypes.object,
|
||||
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onConfirmDeleteDownloadClient: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
|
||||
@@ -4,13 +4,20 @@ import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { deleteDownloadClient, fetchDownloadClients } from 'Store/Actions/settingsActions';
|
||||
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
|
||||
import createTagsSelector from 'Store/Selectors/createTagsSelector';
|
||||
import sortByName from 'Utilities/Array/sortByName';
|
||||
import DownloadClients from './DownloadClients';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
createSortedSectionSelector('settings.downloadClients', sortByName),
|
||||
(downloadClients) => downloadClients
|
||||
createTagsSelector(),
|
||||
(downloadClients, tagList) => {
|
||||
return {
|
||||
...downloadClients,
|
||||
tagList
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ class EditDownloadClientModalContent extends Component {
|
||||
removeCompletedDownloads,
|
||||
removeFailedDownloads,
|
||||
fields,
|
||||
tags,
|
||||
message
|
||||
} = item;
|
||||
|
||||
@@ -146,6 +147,18 @@ class EditDownloadClientModalContent extends Component {
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('Tags')}</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.TAG}
|
||||
name="tags"
|
||||
helpText={translate('DownloadClientTagHelpText')}
|
||||
{...tags}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FieldSet
|
||||
size={sizes.SMALL}
|
||||
legend={translate('CompletedDownloadHandling')}
|
||||
|
||||
@@ -22,6 +22,7 @@ function TagDetailsModalContent(props) {
|
||||
notifications,
|
||||
releaseProfiles,
|
||||
indexers,
|
||||
downloadClients,
|
||||
onModalClose,
|
||||
onDeleteTagPress
|
||||
} = props;
|
||||
@@ -180,6 +181,22 @@ function TagDetailsModalContent(props) {
|
||||
</FieldSet> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
downloadClients.length ?
|
||||
<FieldSet legend={translate('DownloadClients')}>
|
||||
{
|
||||
downloadClients.map((item) => {
|
||||
return (
|
||||
<div key={item.id}>
|
||||
{item.name}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
}
|
||||
</FieldSet> :
|
||||
null
|
||||
}
|
||||
</ModalBody>
|
||||
|
||||
<ModalFooter>
|
||||
@@ -214,6 +231,7 @@ TagDetailsModalContent.propTypes = {
|
||||
notifications: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
releaseProfiles: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
indexers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
downloadClients: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onModalClose: PropTypes.func.isRequired,
|
||||
onDeleteTagPress: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
@@ -77,6 +77,14 @@ function createMatchingIndexersSelector() {
|
||||
);
|
||||
}
|
||||
|
||||
function createMatchingDownloadClientsSelector() {
|
||||
return createSelector(
|
||||
(state, { downloadClientIds }) => downloadClientIds,
|
||||
(state) => state.settings.downloadClients.items,
|
||||
findMatchingItems
|
||||
);
|
||||
}
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
createMatchingAuthorSelector(),
|
||||
@@ -85,14 +93,16 @@ function createMapStateToProps() {
|
||||
createMatchingNotificationsSelector(),
|
||||
createMatchingReleaseProfilesSelector(),
|
||||
createMatchingIndexersSelector(),
|
||||
(author, delayProfiles, importLists, notifications, releaseProfiles, indexers) => {
|
||||
createMatchingDownloadClientsSelector(),
|
||||
(author, delayProfiles, importLists, notifications, releaseProfiles, indexers, downloadClients) => {
|
||||
return {
|
||||
author,
|
||||
delayProfiles,
|
||||
importLists,
|
||||
notifications,
|
||||
releaseProfiles,
|
||||
indexers
|
||||
indexers,
|
||||
downloadClients
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
@@ -58,6 +58,7 @@ class Tag extends Component {
|
||||
notificationIds,
|
||||
restrictionIds,
|
||||
indexerIds,
|
||||
downloadClientIds,
|
||||
authorIds
|
||||
} = this.props;
|
||||
|
||||
@@ -72,6 +73,7 @@ class Tag extends Component {
|
||||
notificationIds.length ||
|
||||
restrictionIds.length ||
|
||||
indexerIds.length ||
|
||||
downloadClientIds.length ||
|
||||
authorIds.length
|
||||
);
|
||||
|
||||
@@ -130,6 +132,14 @@ class Tag extends Component {
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
downloadClientIds.length ?
|
||||
<div>
|
||||
{downloadClientIds.length} download client{indexerIds.length > 1 && 's'}
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -149,6 +159,7 @@ class Tag extends Component {
|
||||
notificationIds={notificationIds}
|
||||
restrictionIds={restrictionIds}
|
||||
indexerIds={indexerIds}
|
||||
downloadClientIds={downloadClientIds}
|
||||
isOpen={isDetailsModalOpen}
|
||||
onModalClose={this.onDetailsModalClose}
|
||||
onDeleteTagPress={this.onDeleteTagPress}
|
||||
@@ -176,6 +187,7 @@ Tag.propTypes = {
|
||||
notificationIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
restrictionIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
indexerIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
downloadClientIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
authorIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
onConfirmDeleteTag: PropTypes.func.isRequired
|
||||
};
|
||||
@@ -186,6 +198,7 @@ Tag.defaultProps = {
|
||||
notificationIds: [],
|
||||
restrictionIds: [],
|
||||
indexerIds: [],
|
||||
downloadClientIds: [],
|
||||
authorIds: []
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { fetchDelayProfiles, fetchImportLists, fetchIndexers, fetchNotifications, fetchReleaseProfiles } from 'Store/Actions/settingsActions';
|
||||
import { fetchDelayProfiles, fetchDownloadClients, fetchImportLists, fetchIndexers, fetchNotifications, fetchReleaseProfiles } from 'Store/Actions/settingsActions';
|
||||
import { fetchTagDetails } from 'Store/Actions/tagActions';
|
||||
import Tags from './Tags';
|
||||
|
||||
@@ -30,7 +30,8 @@ const mapDispatchToProps = {
|
||||
dispatchFetchImportLists: fetchImportLists,
|
||||
dispatchFetchNotifications: fetchNotifications,
|
||||
dispatchFetchReleaseProfiles: fetchReleaseProfiles,
|
||||
dispatchFetchIndexers: fetchIndexers
|
||||
dispatchFetchIndexers: fetchIndexers,
|
||||
dispatchFetchDownloadClients: fetchDownloadClients
|
||||
};
|
||||
|
||||
class MetadatasConnector extends Component {
|
||||
@@ -45,7 +46,8 @@ class MetadatasConnector extends Component {
|
||||
dispatchFetchImportLists,
|
||||
dispatchFetchNotifications,
|
||||
dispatchFetchReleaseProfiles,
|
||||
dispatchFetchIndexers
|
||||
dispatchFetchIndexers,
|
||||
dispatchFetchDownloadClients
|
||||
} = this.props;
|
||||
|
||||
dispatchFetchTagDetails();
|
||||
@@ -54,6 +56,7 @@ class MetadatasConnector extends Component {
|
||||
dispatchFetchNotifications();
|
||||
dispatchFetchReleaseProfiles();
|
||||
dispatchFetchIndexers();
|
||||
dispatchFetchDownloadClients();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -74,7 +77,8 @@ MetadatasConnector.propTypes = {
|
||||
dispatchFetchImportLists: PropTypes.func.isRequired,
|
||||
dispatchFetchNotifications: PropTypes.func.isRequired,
|
||||
dispatchFetchReleaseProfiles: PropTypes.func.isRequired,
|
||||
dispatchFetchIndexers: PropTypes.func.isRequired
|
||||
dispatchFetchIndexers: PropTypes.func.isRequired,
|
||||
dispatchFetchDownloadClients: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(MetadatasConnector);
|
||||
|
||||
Reference in New Issue
Block a user