Fixed: Import series spinning forever when error is returned

Fixes #3944
pull/3953/head
Mark McDowall 5 years ago
parent b2737a3d35
commit b35fd7e507

@ -31,3 +31,7 @@
margin: 0 10px 0 12px; margin: 0 10px 0 12px;
text-align: left; text-align: left;
} }
.importError {
margin-left: 10px;
}

@ -1,13 +1,15 @@
import _ from 'lodash'; import _ from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { inputTypes, kinds } from 'Helpers/Props'; import { icons, inputTypes, kinds, tooltipPositions } from 'Helpers/Props';
import Icon from 'Components/Icon';
import Button from 'Components/Link/Button'; import Button from 'Components/Link/Button';
import SpinnerButton from 'Components/Link/SpinnerButton'; import SpinnerButton from 'Components/Link/SpinnerButton';
import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import LoadingIndicator from 'Components/Loading/LoadingIndicator';
import CheckInput from 'Components/Form/CheckInput'; import CheckInput from 'Components/Form/CheckInput';
import FormInputGroup from 'Components/Form/FormInputGroup'; import FormInputGroup from 'Components/Form/FormInputGroup';
import PageContentFooter from 'Components/Page/PageContentFooter'; import PageContentFooter from 'Components/Page/PageContentFooter';
import Popover from 'Components/Tooltip/Popover';
import styles from './ImportSeriesFooter.css'; import styles from './ImportSeriesFooter.css';
const MIXED = 'mixed'; const MIXED = 'mixed';
@ -118,6 +120,7 @@ class ImportSeriesFooter extends Component {
isSeriesTypeMixed, isSeriesTypeMixed,
hasUnsearchedItems, hasUnsearchedItems,
showLanguageProfile, showLanguageProfile,
importError,
onImportPress, onImportPress,
onLookupPress, onLookupPress,
onCancelLookupPress onCancelLookupPress
@ -226,38 +229,71 @@ class ImportSeriesFooter extends Component {
</SpinnerButton> </SpinnerButton>
{ {
isLookingUpSeries && isLookingUpSeries ?
<Button <Button
className={styles.loadingButton} className={styles.loadingButton}
kind={kinds.WARNING} kind={kinds.WARNING}
onPress={onCancelLookupPress} onPress={onCancelLookupPress}
> >
Cancel Processing Cancel Processing
</Button> </Button> :
null
} }
{ {
hasUnsearchedItems && hasUnsearchedItems ?
<Button <Button
className={styles.loadingButton} className={styles.loadingButton}
kind={kinds.SUCCESS} kind={kinds.SUCCESS}
onPress={onLookupPress} onPress={onLookupPress}
> >
Start Processing Start Processing
</Button> </Button> :
null
} }
{ {
isLookingUpSeries && isLookingUpSeries ?
<LoadingIndicator <LoadingIndicator
className={styles.loading} className={styles.loading}
size={24} size={24}
/> /> :
null
} }
{ {
isLookingUpSeries && isLookingUpSeries ?
'Processing Folders' 'Processing Folders' :
null
}
{
importError ?
<Popover
anchor={
<Icon
className={styles.importError}
name={icons.WARNING}
kind={kinds.WARNING}
/>
}
title="Import Errors"
body={
<ul>
{
importError.responseJSON.map((error, index) => {
return (
<li key={index}>
{error.errorMessage}
</li>
);
})
}
</ul>
}
position={tooltipPositions.RIGHT}
/> :
null
} }
</div> </div>
</div> </div>
@ -282,6 +318,7 @@ ImportSeriesFooter.propTypes = {
isSeasonFolderMixed: PropTypes.bool.isRequired, isSeasonFolderMixed: PropTypes.bool.isRequired,
hasUnsearchedItems: PropTypes.bool.isRequired, hasUnsearchedItems: PropTypes.bool.isRequired,
showLanguageProfile: PropTypes.bool.isRequired, showLanguageProfile: PropTypes.bool.isRequired,
importError: PropTypes.object,
onInputChange: PropTypes.func.isRequired, onInputChange: PropTypes.func.isRequired,
onImportPress: PropTypes.func.isRequired, onImportPress: PropTypes.func.isRequired,
onLookupPress: PropTypes.func.isRequired, onLookupPress: PropTypes.func.isRequired,

@ -27,7 +27,8 @@ function createMapStateToProps() {
const { const {
isLookingUpSeries, isLookingUpSeries,
isImporting, isImporting,
items items,
importError
} = importSeries; } = importSeries;
const isMonitorMixed = isMixed(items, selectedIds, defaultMonitor, 'monitor'); const isMonitorMixed = isMixed(items, selectedIds, defaultMonitor, 'monitor');
@ -51,6 +52,7 @@ function createMapStateToProps() {
isLanguageProfileIdMixed, isLanguageProfileIdMixed,
isSeriesTypeMixed, isSeriesTypeMixed,
isSeasonFolderMixed, isSeasonFolderMixed,
importError,
hasUnsearchedItems hasUnsearchedItems
}; };
} }

@ -249,7 +249,8 @@ export const actionHandlers = handleThunks({
set({ set({
section, section,
isImporting: false, isImporting: false,
isImported: true isImported: true,
importError: null
}), }),
...data.map((series) => updateItem({ section: 'series', ...series })), ...data.map((series) => updateItem({ section: 'series', ...series })),
@ -261,19 +262,19 @@ export const actionHandlers = handleThunks({
}); });
promise.fail((xhr) => { promise.fail((xhr) => {
dispatch(batchActions( dispatch(batchActions([
set({ set({
section, section,
isImporting: false, isImporting: false,
isImported: true isImported: true,
importError: xhr
}), }),
addedIds.map((id) => updateItem({ ...addedIds.map((id) => updateItem({
section, section,
id, id
importError: xhr
})) }))
)); ]));
}); });
} }
}); });

Loading…
Cancel
Save