Fixed: Don't allow profile delete if in use by import list

Fixes #280
This commit is contained in:
Qstick 2018-04-07 22:28:16 -04:00
commit fde276f000
10 changed files with 50 additions and 18 deletions

View file

@ -8,7 +8,7 @@ import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
import { saveDimensions, setIsSidebarVisible } from 'Store/Actions/appActions';
import { fetchArtist } from 'Store/Actions/artistActions';
import { fetchTags } from 'Store/Actions/tagActions';
import { fetchQualityProfiles, fetchLanguageProfiles, fetchMetadataProfiles, fetchUISettings } from 'Store/Actions/settingsActions';
import { fetchQualityProfiles, fetchLanguageProfiles, fetchMetadataProfiles, fetchUISettings, fetchImportLists } from 'Store/Actions/settingsActions';
import { fetchStatus } from 'Store/Actions/systemActions';
import ErrorPage from './ErrorPage';
import LoadingPage from './LoadingPage';
@ -38,11 +38,17 @@ function createMapStateToProps() {
const isPopulated = artist.isPopulated &&
tags.isPopulated &&
settings.qualityProfiles.isPopulated &&
settings.languageProfiles.isPopulated &&
settings.metadataProfiles.isPopulated &&
settings.importLists.isPopulated &&
settings.ui.isPopulated;
const hasError = !!artist.error ||
!!tags.error ||
!!settings.qualityProfiles.error ||
!!settings.languageProfiles.error ||
!!settings.metadataProfiles.error ||
!!settings.importLists.error ||
!!settings.ui.error;
return {
@ -51,6 +57,9 @@ function createMapStateToProps() {
artistError: artist.error,
tagsError: tags.error,
qualityProfilesError: settings.qualityProfiles.error,
languageProfilesError: settings.languageProfiles.error,
metadataProfilesError: settings.metadataProfiles.error,
importListsError: settings.importLists.error,
uiSettingsError: settings.ui.error,
isSmallScreen: dimensions.isSmallScreen,
isSidebarVisible: app.isSidebarVisible,
@ -79,6 +88,9 @@ function createMapDispatchToProps(dispatch, props) {
dispatchFetchMetadataProfiles() {
dispatch(fetchMetadataProfiles());
},
dispatchFetchImportLists() {
dispatch(fetchImportLists());
},
dispatchFetchUISettings() {
dispatch(fetchUISettings());
},
@ -114,6 +126,7 @@ class PageConnector extends Component {
this.props.dispatchFetchQualityProfiles();
this.props.dispatchFetchLanguageProfiles();
this.props.dispatchFetchMetadataProfiles();
this.props.dispatchFetchImportLists();
this.props.dispatchFetchUISettings();
this.props.dispatchFetchStatus();
}
@ -138,6 +151,7 @@ class PageConnector extends Component {
dispatchFetchQualityProfiles,
dispatchFetchLanguageProfiles,
dispatchFetchMetadataProfiles,
dispatchFetchImportLists,
dispatchFetchUISettings,
dispatchFetchStatus,
...otherProps
@ -176,6 +190,7 @@ PageConnector.propTypes = {
dispatchFetchQualityProfiles: PropTypes.func.isRequired,
dispatchFetchLanguageProfiles: PropTypes.func.isRequired,
dispatchFetchMetadataProfiles: PropTypes.func.isRequired,
dispatchFetchImportLists: PropTypes.func.isRequired,
dispatchFetchUISettings: PropTypes.func.isRequired,
dispatchFetchStatus: PropTypes.func.isRequired,
onSidebarVisibleChange: PropTypes.func.isRequired

View file

@ -41,7 +41,7 @@ function EditImportListModalContent(props) {
enableAutomaticAdd,
shouldMonitor,
rootFolderPath,
profileId,
qualityProfileId,
languageProfileId,
metadataProfileId,
fields
@ -121,9 +121,9 @@ function EditImportListModalContent(props) {
<FormInputGroup
type={inputTypes.QUALITY_PROFILE_SELECT}
name="profileId"
name="qualityProfileId"
helpText={'Quality Profile list items should be added with'}
{...profileId}
{...qualityProfileId}
onChange={onInputChange}
/>
</FormGroup>

View file

@ -101,7 +101,7 @@ function EditLanguageProfileModalContent(props) {
id &&
<div
className={styles.deleteButtonContainer}
title={isInUse ? 'Can\'t delete a language profile that is attached to a artist' : undefined}
title={isInUse ? 'Can\'t delete a language profile that is attached to an artist or import list' : undefined}
>
<Button
kind={kinds.DANGER}

View file

@ -107,7 +107,7 @@ function EditMetadataProfileModalContent(props) {
id &&
<div
className={styles.deleteButtonContainer}
title={isInUse ? 'Can\'t delete a metadata profile that is attached to a artist' : undefined}
title={isInUse ? 'Can\'t delete a metadata profile that is attached to an artist or import list' : undefined}
>
<Button
kind={kinds.DANGER}

View file

@ -200,7 +200,7 @@ class EditQualityProfileModalContent extends Component {
id &&
<div
className={styles.deleteButtonContainer}
title={isInUse ? 'Can\'t delete a quality profile that is attached to a artist' : undefined}
title={isInUse ? 'Can\'t delete a quality profile that is attached to an artist or import list' : undefined}
>
<Button
kind={kinds.DANGER}

View file

@ -6,12 +6,17 @@ function createProfileInUseSelector(profileProp) {
return createSelector(
(state, { id }) => id,
createAllArtistSelector(),
(id, artist) => {
(state) => state.settings.importLists.items,
(id, artist, lists) => {
if (!id) {
return false;
}
return _.some(artist, { [profileProp]: id });
if (_.some(artist, { [profileProp]: id }) || _.some(lists, { [profileProp]: id })) {
return true;
}
return false;
}
);
}