From 0b7b12d1d9c6885552418055cb411c9acbd6a6a6 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 22 Jul 2023 03:05:32 +0300 Subject: [PATCH] Fixed: (UI) Allow `No Change` in mass editor --- .../src/Artist/Editor/ArtistEditorFooter.js | 11 ++++++++--- .../MetadataProfileSelectInputConnector.js | 18 ++++++++++-------- .../Form/MonitorNewItemsSelectInput.js | 4 ++-- .../Form/QualityProfileSelectInputConnector.js | 13 +++++++------ 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/frontend/src/Artist/Editor/ArtistEditorFooter.js b/frontend/src/Artist/Editor/ArtistEditorFooter.js index 7675df44c..4555c1826 100644 --- a/frontend/src/Artist/Editor/ArtistEditorFooter.js +++ b/frontend/src/Artist/Editor/ArtistEditorFooter.js @@ -1,14 +1,14 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; +import FormInputGroup from 'Components/Form/FormInputGroup'; import MetadataProfileSelectInputConnector from 'Components/Form/MetadataProfileSelectInputConnector'; import MonitorNewItemsSelectInput from 'Components/Form/MonitorNewItemsSelectInput'; import QualityProfileSelectInputConnector from 'Components/Form/QualityProfileSelectInputConnector'; import RootFolderSelectInputConnector from 'Components/Form/RootFolderSelectInputConnector'; -import SelectInput from 'Components/Form/SelectInput'; import SpinnerButton from 'Components/Link/SpinnerButton'; import PageContentFooter from 'Components/Page/PageContentFooter'; -import { kinds } from 'Helpers/Props'; +import { inputTypes, kinds } from 'Helpers/Props'; import translate from 'Utilities/String/translate'; import ArtistEditorFooterLabel from './ArtistEditorFooterLabel'; import DeleteArtistModal from './Delete/DeleteArtistModal'; @@ -174,10 +174,12 @@ class ArtistEditorFooter extends Component { isSaving={isSaving && monitored !== NO_CHANGE} /> - @@ -193,6 +195,7 @@ class ArtistEditorFooter extends Component { name="monitorNewItems" value={monitorNewItems} includeNoChange={true} + includeNoChangeDisabled={false} isDisabled={!selectedCount} onChange={this.onInputChange} /> @@ -224,6 +227,7 @@ class ArtistEditorFooter extends Component { name="qualityProfileId" value={qualityProfileId} includeNoChange={true} + includeNoChangeDisabled={false} isDisabled={!selectedCount} onChange={this.onInputChange} /> @@ -246,6 +250,7 @@ class ArtistEditorFooter extends Component { name="metadataProfileId" value={metadataProfileId} includeNoChange={true} + includeNoChangeDisabled={false} includeNone={true} isDisabled={!selectedCount} onChange={this.onInputChange} diff --git a/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js b/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js index ed8a138ba..e7c1535c1 100644 --- a/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js +++ b/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js @@ -7,15 +7,16 @@ import { metadataProfileNames } from 'Helpers/Props'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; import sortByName from 'Utilities/Array/sortByName'; import translate from 'Utilities/String/translate'; -import SelectInput from './SelectInput'; +import EnhancedSelectInput from './EnhancedSelectInput'; function createMapStateToProps() { return createSelector( createSortedSectionSelector('settings.metadataProfiles', sortByName), (state, { includeNoChange }) => includeNoChange, + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, (state, { includeNone }) => includeNone, - (metadataProfiles, includeNoChange, includeMixed, includeNone) => { + (metadataProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed, includeNone) => { const profiles = metadataProfiles.items.filter((item) => item.name !== metadataProfileNames.NONE); const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE); @@ -38,7 +39,7 @@ function createMapStateToProps() { values.unshift({ key: 'noChange', value: translate('NoChange'), - disabled: true + disabled: includeNoChangeDisabled }); } @@ -69,8 +70,8 @@ class MetadataProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { - const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); + if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { + const firstValue = values.find((option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -82,7 +83,7 @@ class MetadataProfileSelectInputConnector extends Component { // Listeners onChange = ({ name, value }) => { - this.props.onChange({ name, value: parseInt(value) }); + this.props.onChange({ name, value: value === 'noChange' ? value : parseInt(value) }); }; // @@ -90,7 +91,7 @@ class MetadataProfileSelectInputConnector extends Component { render() { return ( - @@ -108,7 +109,8 @@ MetadataProfileSelectInputConnector.propTypes = { }; MetadataProfileSelectInputConnector.defaultProps = { - includeNoChange: false + includeNoChange: false, + includeNone: true }; export default connect(createMapStateToProps)(MetadataProfileSelectInputConnector); diff --git a/frontend/src/Components/Form/MonitorNewItemsSelectInput.js b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js index 65d8f1b52..f9cc07d7d 100644 --- a/frontend/src/Components/Form/MonitorNewItemsSelectInput.js +++ b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import monitorNewItemsOptions from 'Utilities/Artist/monitorNewItemsOptions'; import translate from 'Utilities/String/translate'; -import SelectInput from './SelectInput'; +import EnhancedSelectInput from './EnhancedSelectInput'; function MonitorNewItemsSelectInput(props) { const { @@ -31,7 +31,7 @@ function MonitorNewItemsSelectInput(props) { } return ( - diff --git a/frontend/src/Components/Form/QualityProfileSelectInputConnector.js b/frontend/src/Components/Form/QualityProfileSelectInputConnector.js index 282037722..a898de4a2 100644 --- a/frontend/src/Components/Form/QualityProfileSelectInputConnector.js +++ b/frontend/src/Components/Form/QualityProfileSelectInputConnector.js @@ -6,14 +6,15 @@ import { createSelector } from 'reselect'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; import sortByName from 'Utilities/Array/sortByName'; import translate from 'Utilities/String/translate'; -import SelectInput from './SelectInput'; +import EnhancedSelectInput from './EnhancedSelectInput'; function createMapStateToProps() { return createSelector( createSortedSectionSelector('settings.qualityProfiles', sortByName), (state, { includeNoChange }) => includeNoChange, + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, - (qualityProfiles, includeNoChange, includeMixed) => { + (qualityProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed) => { const values = _.map(qualityProfiles.items, (qualityProfile) => { return { key: qualityProfile.id, @@ -25,7 +26,7 @@ function createMapStateToProps() { values.unshift({ key: 'noChange', value: translate('NoChange'), - disabled: true + disabled: includeNoChangeDisabled }); } @@ -56,8 +57,8 @@ class QualityProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { - const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); + if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { + const firstValue = values.find((option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -77,7 +78,7 @@ class QualityProfileSelectInputConnector extends Component { render() { return ( -