New: Add root folder select to EditSeriesModal
This commit is contained in:
parent
9218962e3c
commit
7123d914b1
|
@ -2,14 +2,22 @@ import PropTypes from 'prop-types';
|
|||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { clearPendingChanges } from 'Store/Actions/baseActions';
|
||||
import { fetchRootFolders } from 'Store/Actions/rootFolderActions';
|
||||
import EditSeriesModal from './EditSeriesModal';
|
||||
|
||||
const mapDispatchToProps = {
|
||||
clearPendingChanges
|
||||
clearPendingChanges,
|
||||
fetchRootFolders
|
||||
};
|
||||
|
||||
class EditSeriesModalConnector extends Component {
|
||||
|
||||
//
|
||||
// Lifecycle
|
||||
componentDidMount() {
|
||||
this.props.fetchRootFolders();
|
||||
}
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
|
@ -34,7 +42,8 @@ class EditSeriesModalConnector extends Component {
|
|||
EditSeriesModalConnector.propTypes = {
|
||||
...EditSeriesModal.propTypes,
|
||||
onModalClose: PropTypes.func.isRequired,
|
||||
clearPendingChanges: PropTypes.func.isRequired
|
||||
clearPendingChanges: PropTypes.func.isRequired,
|
||||
fetchRootFolders: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(undefined, mapDispatchToProps)(EditSeriesModalConnector);
|
||||
|
|
|
@ -77,6 +77,7 @@ class EditSeriesModalContent extends Component {
|
|||
qualityProfileId,
|
||||
seriesType,
|
||||
path,
|
||||
rootFolderPath,
|
||||
tags
|
||||
} = item;
|
||||
|
||||
|
@ -148,6 +149,23 @@ class EditSeriesModalContent extends Component {
|
|||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('Root Folder')}</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.ROOT_FOLDER_SELECT}
|
||||
name="rootFolderPath"
|
||||
{...rootFolderPath}
|
||||
includeNoChange={true}
|
||||
includeNoChangeDisabled={false}
|
||||
selectedValueOptions={{ includeFreeSpace: false }}
|
||||
helpText={translate(
|
||||
'Moving series to the same root folder can be used to rename series folders to match updated title or naming format'
|
||||
)}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<FormLabel>Tags</FormLabel>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { createSelector } from 'reselect';
|
|||
import { saveSeries, setSeriesValue } from 'Store/Actions/seriesActions';
|
||||
import createSeriesSelector from 'Store/Selectors/createSeriesSelector';
|
||||
import selectSettings from 'Store/Selectors/selectSettings';
|
||||
import combinePath from 'Utilities/String/combinePath';
|
||||
import EditSeriesModalContent from './EditSeriesModalContent';
|
||||
|
||||
function createIsPathChangingSelector() {
|
||||
|
@ -27,9 +28,10 @@ function createIsPathChangingSelector() {
|
|||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.series,
|
||||
(state) => state.system.status.item.isWindows,
|
||||
createSeriesSelector(),
|
||||
createIsPathChangingSelector(),
|
||||
(seriesState, series, isPathChanging) => {
|
||||
(seriesState, isWindows, series, isPathChanging) => {
|
||||
const {
|
||||
isSaving,
|
||||
saveError,
|
||||
|
@ -42,6 +44,7 @@ function createMapStateToProps() {
|
|||
'qualityProfileId',
|
||||
'seriesType',
|
||||
'path',
|
||||
'rootFolderPath',
|
||||
'tags'
|
||||
]);
|
||||
|
||||
|
@ -49,6 +52,7 @@ function createMapStateToProps() {
|
|||
|
||||
return {
|
||||
title: series.title,
|
||||
isWindows,
|
||||
isSaving,
|
||||
saveError,
|
||||
isPathChanging,
|
||||
|
@ -80,7 +84,20 @@ class EditSeriesModalContentConnector extends Component {
|
|||
// Listeners
|
||||
|
||||
onInputChange = ({ name, value }) => {
|
||||
this.props.dispatchSetSeriesValue({ name, value });
|
||||
const {
|
||||
dispatchSetSeriesValue,
|
||||
isWindows,
|
||||
title,
|
||||
item: { path }
|
||||
} = this.props;
|
||||
|
||||
dispatchSetSeriesValue({ name, value });
|
||||
|
||||
// Also update the path if the root folder path changes
|
||||
if (name === 'rootFolderPath' && value !== 'noChange' && path.value.indexOf(value) === -1) {
|
||||
const newPath = combinePath(isWindows, value, [title]);
|
||||
dispatchSetSeriesValue({ name: 'path', value: newPath });
|
||||
}
|
||||
};
|
||||
|
||||
onSavePress = (moveFiles) => {
|
||||
|
@ -106,7 +123,10 @@ class EditSeriesModalContentConnector extends Component {
|
|||
}
|
||||
|
||||
EditSeriesModalContentConnector.propTypes = {
|
||||
title: PropTypes.string.isRequired,
|
||||
item: PropTypes.object.isRequired,
|
||||
seriesId: PropTypes.number,
|
||||
isWindows: PropTypes.bool.isRequired,
|
||||
isSaving: PropTypes.bool.isRequired,
|
||||
saveError: PropTypes.object,
|
||||
dispatchSetSeriesValue: PropTypes.func.isRequired,
|
||||
|
|
Loading…
Reference in New Issue