Fixed: (UI) Allow `No Change` in mass editor

This commit is contained in:
Bogdan 2023-07-22 03:05:32 +03:00
parent cc3667ed13
commit 0b7b12d1d9
4 changed files with 27 additions and 19 deletions

View File

@ -1,14 +1,14 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal';
import FormInputGroup from 'Components/Form/FormInputGroup';
import MetadataProfileSelectInputConnector from 'Components/Form/MetadataProfileSelectInputConnector'; import MetadataProfileSelectInputConnector from 'Components/Form/MetadataProfileSelectInputConnector';
import MonitorNewItemsSelectInput from 'Components/Form/MonitorNewItemsSelectInput'; import MonitorNewItemsSelectInput from 'Components/Form/MonitorNewItemsSelectInput';
import QualityProfileSelectInputConnector from 'Components/Form/QualityProfileSelectInputConnector'; import QualityProfileSelectInputConnector from 'Components/Form/QualityProfileSelectInputConnector';
import RootFolderSelectInputConnector from 'Components/Form/RootFolderSelectInputConnector'; import RootFolderSelectInputConnector from 'Components/Form/RootFolderSelectInputConnector';
import SelectInput from 'Components/Form/SelectInput';
import SpinnerButton from 'Components/Link/SpinnerButton'; import SpinnerButton from 'Components/Link/SpinnerButton';
import PageContentFooter from 'Components/Page/PageContentFooter'; import PageContentFooter from 'Components/Page/PageContentFooter';
import { kinds } from 'Helpers/Props'; import { inputTypes, kinds } from 'Helpers/Props';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import ArtistEditorFooterLabel from './ArtistEditorFooterLabel'; import ArtistEditorFooterLabel from './ArtistEditorFooterLabel';
import DeleteArtistModal from './Delete/DeleteArtistModal'; import DeleteArtistModal from './Delete/DeleteArtistModal';
@ -174,10 +174,12 @@ class ArtistEditorFooter extends Component {
isSaving={isSaving && monitored !== NO_CHANGE} isSaving={isSaving && monitored !== NO_CHANGE}
/> />
<SelectInput <FormInputGroup
type={inputTypes.SELECT}
name="monitored" name="monitored"
value={monitored} value={monitored}
values={monitoredOptions} values={monitoredOptions}
includeNoChangeDisabled={false}
isDisabled={!selectedCount} isDisabled={!selectedCount}
onChange={this.onInputChange} onChange={this.onInputChange}
/> />
@ -193,6 +195,7 @@ class ArtistEditorFooter extends Component {
name="monitorNewItems" name="monitorNewItems"
value={monitorNewItems} value={monitorNewItems}
includeNoChange={true} includeNoChange={true}
includeNoChangeDisabled={false}
isDisabled={!selectedCount} isDisabled={!selectedCount}
onChange={this.onInputChange} onChange={this.onInputChange}
/> />
@ -224,6 +227,7 @@ class ArtistEditorFooter extends Component {
name="qualityProfileId" name="qualityProfileId"
value={qualityProfileId} value={qualityProfileId}
includeNoChange={true} includeNoChange={true}
includeNoChangeDisabled={false}
isDisabled={!selectedCount} isDisabled={!selectedCount}
onChange={this.onInputChange} onChange={this.onInputChange}
/> />
@ -246,6 +250,7 @@ class ArtistEditorFooter extends Component {
name="metadataProfileId" name="metadataProfileId"
value={metadataProfileId} value={metadataProfileId}
includeNoChange={true} includeNoChange={true}
includeNoChangeDisabled={false}
includeNone={true} includeNone={true}
isDisabled={!selectedCount} isDisabled={!selectedCount}
onChange={this.onInputChange} onChange={this.onInputChange}

View File

@ -7,15 +7,16 @@ import { metadataProfileNames } from 'Helpers/Props';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import sortByName from 'Utilities/Array/sortByName'; import sortByName from 'Utilities/Array/sortByName';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import SelectInput from './SelectInput'; import EnhancedSelectInput from './EnhancedSelectInput';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createSortedSectionSelector('settings.metadataProfiles', sortByName), createSortedSectionSelector('settings.metadataProfiles', sortByName),
(state, { includeNoChange }) => includeNoChange, (state, { includeNoChange }) => includeNoChange,
(state, { includeNoChangeDisabled }) => includeNoChangeDisabled,
(state, { includeMixed }) => includeMixed, (state, { includeMixed }) => includeMixed,
(state, { includeNone }) => includeNone, (state, { includeNone }) => includeNone,
(metadataProfiles, includeNoChange, includeMixed, includeNone) => { (metadataProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed, includeNone) => {
const profiles = metadataProfiles.items.filter((item) => item.name !== metadataProfileNames.NONE); const profiles = metadataProfiles.items.filter((item) => item.name !== metadataProfileNames.NONE);
const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE); const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE);
@ -38,7 +39,7 @@ function createMapStateToProps() {
values.unshift({ values.unshift({
key: 'noChange', key: 'noChange',
value: translate('NoChange'), value: translate('NoChange'),
disabled: true disabled: includeNoChangeDisabled
}); });
} }
@ -69,8 +70,8 @@ class MetadataProfileSelectInputConnector extends Component {
values values
} = this.props; } = this.props;
if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) {
const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); const firstValue = values.find((option) => !isNaN(parseInt(option.key)));
if (firstValue) { if (firstValue) {
this.onChange({ name, value: firstValue.key }); this.onChange({ name, value: firstValue.key });
@ -82,7 +83,7 @@ class MetadataProfileSelectInputConnector extends Component {
// Listeners // Listeners
onChange = ({ name, value }) => { 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() { render() {
return ( return (
<SelectInput <EnhancedSelectInput
{...this.props} {...this.props}
onChange={this.onChange} onChange={this.onChange}
/> />
@ -108,7 +109,8 @@ MetadataProfileSelectInputConnector.propTypes = {
}; };
MetadataProfileSelectInputConnector.defaultProps = { MetadataProfileSelectInputConnector.defaultProps = {
includeNoChange: false includeNoChange: false,
includeNone: true
}; };
export default connect(createMapStateToProps)(MetadataProfileSelectInputConnector); export default connect(createMapStateToProps)(MetadataProfileSelectInputConnector);

View File

@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import monitorNewItemsOptions from 'Utilities/Artist/monitorNewItemsOptions'; import monitorNewItemsOptions from 'Utilities/Artist/monitorNewItemsOptions';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import SelectInput from './SelectInput'; import EnhancedSelectInput from './EnhancedSelectInput';
function MonitorNewItemsSelectInput(props) { function MonitorNewItemsSelectInput(props) {
const { const {
@ -31,7 +31,7 @@ function MonitorNewItemsSelectInput(props) {
} }
return ( return (
<SelectInput <EnhancedSelectInput
values={values} values={values}
{...otherProps} {...otherProps}
/> />

View File

@ -6,14 +6,15 @@ import { createSelector } from 'reselect';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import sortByName from 'Utilities/Array/sortByName'; import sortByName from 'Utilities/Array/sortByName';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import SelectInput from './SelectInput'; import EnhancedSelectInput from './EnhancedSelectInput';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createSortedSectionSelector('settings.qualityProfiles', sortByName), createSortedSectionSelector('settings.qualityProfiles', sortByName),
(state, { includeNoChange }) => includeNoChange, (state, { includeNoChange }) => includeNoChange,
(state, { includeNoChangeDisabled }) => includeNoChangeDisabled,
(state, { includeMixed }) => includeMixed, (state, { includeMixed }) => includeMixed,
(qualityProfiles, includeNoChange, includeMixed) => { (qualityProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed) => {
const values = _.map(qualityProfiles.items, (qualityProfile) => { const values = _.map(qualityProfiles.items, (qualityProfile) => {
return { return {
key: qualityProfile.id, key: qualityProfile.id,
@ -25,7 +26,7 @@ function createMapStateToProps() {
values.unshift({ values.unshift({
key: 'noChange', key: 'noChange',
value: translate('NoChange'), value: translate('NoChange'),
disabled: true disabled: includeNoChangeDisabled
}); });
} }
@ -56,8 +57,8 @@ class QualityProfileSelectInputConnector extends Component {
values values
} = this.props; } = this.props;
if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) {
const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); const firstValue = values.find((option) => !isNaN(parseInt(option.key)));
if (firstValue) { if (firstValue) {
this.onChange({ name, value: firstValue.key }); this.onChange({ name, value: firstValue.key });
@ -77,7 +78,7 @@ class QualityProfileSelectInputConnector extends Component {
render() { render() {
return ( return (
<SelectInput <EnhancedSelectInput
{...this.props} {...this.props}
onChange={this.onChange} onChange={this.onChange}
/> />