1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-21 22:05:38 -04:00

Added Enabled & IndexerId to Edit Release Profile UI

This commit is contained in:
Taloth Saldono
2019-06-16 18:28:09 +02:00
parent 5ac7672756
commit c1f3da00a4
7 changed files with 110 additions and 71 deletions
@@ -34,9 +34,9 @@ function EditReleaseProfileModalContent(props) {
required,
ignored,
preferred,
indexerId,
includePreferredWhenRenaming,
tags
tags,
indexerId
} = item;
return (
@@ -127,6 +127,7 @@ function EditReleaseProfileModalContent(props) {
name="indexerId"
helpText="Specify what indexer the profile applies to"
{...indexerId}
includeAny={true}
onChange={onInputChange}
/>
</FormGroup>
@@ -8,13 +8,13 @@ import { setReleaseProfileValue, saveReleaseProfile } from 'Store/Actions/settin
import EditReleaseProfileModalContent from './EditReleaseProfileModalContent';
const newReleaseProfile = {
enabled: false,
enabled: true,
required: '',
ignored: '',
preferred: [],
includePreferredWhenRenaming: false,
indexer: 0,
tags: []
tags: [],
indexerId: 0
};
function createMapStateToProps() {
@@ -1,3 +1,4 @@
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import split from 'Utilities/String/split';
@@ -68,10 +69,13 @@ class ReleaseProfile extends Component {
render() {
const {
id,
enabled,
required,
ignored,
tags,
tagList
indexerId,
tagList,
indexerList
} = this.props;
const {
@@ -80,6 +84,8 @@ class ReleaseProfile extends Component {
isDeleteReleaseProfileModalOpen
} = this.state;
const indexer = indexerId !== 0 && _.find(indexerList, { id: indexerId });
return (
<Card
className={styles.releaseProfile}
@@ -105,6 +111,23 @@ class ReleaseProfile extends Component {
}
</div>
<div>
{
sortedPreferred.map((item) => {
const isPreferred = item.value >= 0;
return (
<Label
key={item.key}
kind={isPreferred ? kinds.DEFAULT : kinds.WARNING}
>
{item.key} {isPreferred && '+'}{item.value}
</Label>
);
})
}
</div>
<div>
{
split(ignored).map((item) => {
@@ -124,28 +147,33 @@ class ReleaseProfile extends Component {
}
</div>
<div>
{
sortedPreferred.map((item) => {
const isPreferred = item.value >= 0;
return (
<Label
key={item.key}
kind={isPreferred ? kinds.DEFAULT : kinds.WARNING}
>
{item.key} {isPreferred && '+'}{item.value}
</Label>
);
})
}
</div>
<TagList
tags={tags}
tagList={tagList}
/>
<div>
{
!enabled &&
<Label
kind={kinds.DISABLED}
outline={true}
>
Disabled
</Label>
}
{
indexer &&
<Label
kind={kinds.INFO}
outline={true}
>
{indexer.name}
</Label>
}
</div>
<EditReleaseProfileModalConnector
id={id}
isOpen={isEditReleaseProfileModalOpen}
@@ -169,18 +197,23 @@ class ReleaseProfile extends Component {
ReleaseProfile.propTypes = {
id: PropTypes.number.isRequired,
enabled: PropTypes.bool.isRequired,
required: PropTypes.string.isRequired,
ignored: PropTypes.string.isRequired,
preferred: PropTypes.arrayOf(PropTypes.object).isRequired,
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
indexerId: PropTypes.number.isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
indexerList: PropTypes.arrayOf(PropTypes.object).isRequired,
onConfirmDeleteReleaseProfile: PropTypes.func.isRequired
};
ReleaseProfile.defaultProps = {
enabled: true,
required: '',
ignored: '',
preferred: []
preferred: [],
indexerId: 0
};
export default ReleaseProfile;
@@ -40,6 +40,7 @@ class ReleaseProfiles extends Component {
const {
items,
tagList,
indexerList,
onConfirmDeleteReleaseProfile,
...otherProps
} = this.props;
@@ -69,6 +70,7 @@ class ReleaseProfiles extends Component {
<ReleaseProfile
key={item.id}
tagList={tagList}
indexerList={indexerList}
{...item}
onConfirmDeleteReleaseProfile={onConfirmDeleteReleaseProfile}
/>
@@ -92,6 +94,7 @@ ReleaseProfiles.propTypes = {
error: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
indexerList: PropTypes.arrayOf(PropTypes.object).isRequired,
onConfirmDeleteReleaseProfile: PropTypes.func.isRequired
};
@@ -2,24 +2,28 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { fetchReleaseProfiles, deleteReleaseProfile } from 'Store/Actions/settingsActions';
import { fetchReleaseProfiles, deleteReleaseProfile, fetchIndexers } from 'Store/Actions/settingsActions';
import createTagsSelector from 'Store/Selectors/createTagsSelector';
import ReleaseProfiles from './ReleaseProfiles';
function createMapStateToProps() {
return createSelector(
(state) => state.settings.releaseProfiles,
(state) => state.settings.indexers,
createTagsSelector(),
(releaseProfiles, tagList) => {
(releaseProfiles, indexers, tagList) => {
return {
...releaseProfiles,
tagList
tagList,
isIndexersPopulated: indexers.isPopulated,
indexerList: indexers.items
};
}
);
}
const mapDispatchToProps = {
fetchIndexers,
fetchReleaseProfiles,
deleteReleaseProfile
};
@@ -31,6 +35,9 @@ class ReleaseProfilesConnector extends Component {
componentDidMount() {
this.props.fetchReleaseProfiles();
if (!this.props.isIndexersPopulated) {
this.props.fetchIndexers();
}
}
//
@@ -54,8 +61,10 @@ class ReleaseProfilesConnector extends Component {
}
ReleaseProfilesConnector.propTypes = {
isIndexersPopulated: PropTypes.bool.isRequired,
fetchReleaseProfiles: PropTypes.func.isRequired,
deleteReleaseProfile: PropTypes.func.isRequired
deleteReleaseProfile: PropTypes.func.isRequired,
fetchIndexers: PropTypes.func.isRequired
};
export default connect(createMapStateToProps, mapDispatchToProps)(ReleaseProfilesConnector);