From b35fd7e5073cb9e23b99586756cf59bc6e41c598 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 8 Sep 2020 14:17:25 -0700 Subject: [PATCH] Fixed: Import series spinning forever when error is returned Fixes #3944 --- .../Import/ImportSeriesFooter.css | 4 ++ .../ImportSeries/Import/ImportSeriesFooter.js | 55 ++++++++++++++++--- .../Import/ImportSeriesFooterConnector.js | 4 +- .../src/Store/Actions/importSeriesActions.js | 15 ++--- 4 files changed, 61 insertions(+), 17 deletions(-) diff --git a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.css b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.css index 616aeaf3c..9bfb5a493 100644 --- a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.css +++ b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.css @@ -31,3 +31,7 @@ margin: 0 10px 0 12px; text-align: left; } + +.importError { + margin-left: 10px; +} diff --git a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.js b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.js index 9d28dd299..14adccb00 100644 --- a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.js +++ b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooter.js @@ -1,13 +1,15 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; 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 SpinnerButton from 'Components/Link/SpinnerButton'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import CheckInput from 'Components/Form/CheckInput'; import FormInputGroup from 'Components/Form/FormInputGroup'; import PageContentFooter from 'Components/Page/PageContentFooter'; +import Popover from 'Components/Tooltip/Popover'; import styles from './ImportSeriesFooter.css'; const MIXED = 'mixed'; @@ -118,6 +120,7 @@ class ImportSeriesFooter extends Component { isSeriesTypeMixed, hasUnsearchedItems, showLanguageProfile, + importError, onImportPress, onLookupPress, onCancelLookupPress @@ -226,38 +229,71 @@ class ImportSeriesFooter extends Component { { - isLookingUpSeries && + isLookingUpSeries ? + : + null } { - hasUnsearchedItems && + hasUnsearchedItems ? + : + null } { - isLookingUpSeries && + isLookingUpSeries ? + /> : + null } { - isLookingUpSeries && - 'Processing Folders' + isLookingUpSeries ? + 'Processing Folders' : + null + } + + { + importError ? + + } + title="Import Errors" + body={ +
    + { + importError.responseJSON.map((error, index) => { + return ( +
  • + {error.errorMessage} +
  • + ); + }) + } +
+ } + position={tooltipPositions.RIGHT} + /> : + null } @@ -282,6 +318,7 @@ ImportSeriesFooter.propTypes = { isSeasonFolderMixed: PropTypes.bool.isRequired, hasUnsearchedItems: PropTypes.bool.isRequired, showLanguageProfile: PropTypes.bool.isRequired, + importError: PropTypes.object, onInputChange: PropTypes.func.isRequired, onImportPress: PropTypes.func.isRequired, onLookupPress: PropTypes.func.isRequired, diff --git a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooterConnector.js b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooterConnector.js index 4983f5663..d8f4739fa 100644 --- a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooterConnector.js +++ b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesFooterConnector.js @@ -27,7 +27,8 @@ function createMapStateToProps() { const { isLookingUpSeries, isImporting, - items + items, + importError } = importSeries; const isMonitorMixed = isMixed(items, selectedIds, defaultMonitor, 'monitor'); @@ -51,6 +52,7 @@ function createMapStateToProps() { isLanguageProfileIdMixed, isSeriesTypeMixed, isSeasonFolderMixed, + importError, hasUnsearchedItems }; } diff --git a/frontend/src/Store/Actions/importSeriesActions.js b/frontend/src/Store/Actions/importSeriesActions.js index 347d7b572..b63105486 100644 --- a/frontend/src/Store/Actions/importSeriesActions.js +++ b/frontend/src/Store/Actions/importSeriesActions.js @@ -249,7 +249,8 @@ export const actionHandlers = handleThunks({ set({ section, isImporting: false, - isImported: true + isImported: true, + importError: null }), ...data.map((series) => updateItem({ section: 'series', ...series })), @@ -261,19 +262,19 @@ export const actionHandlers = handleThunks({ }); promise.fail((xhr) => { - dispatch(batchActions( + dispatch(batchActions([ set({ section, isImporting: false, - isImported: true + isImported: true, + importError: xhr }), - addedIds.map((id) => updateItem({ + ...addedIds.map((id) => updateItem({ section, - id, - importError: xhr + id })) - )); + ])); }); } });