Fixed: Show error if adding root folder fails

(cherry picked from commit 6596d0b4dad7be4e3d974f723b1a19d9bbfdff1f)

Co-authored-by: Mark McDowall <mark@mcdowall.ca>
This commit is contained in:
Robin Dadswell 2021-08-06 08:36:06 +01:00 committed by GitHub
parent 0daa978fba
commit ebf4425beb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 31 deletions

View File

@ -30,3 +30,9 @@
.importButtonIcon {
margin-right: 8px;
}
.addErrorAlert {
composes: alert from '~Components/Alert.css';
margin: 20px 0;
}

View File

@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Alert from 'Components/Alert';
import FieldSet from 'Components/FieldSet';
import FileBrowserModal from 'Components/FileBrowser/FileBrowserModal';
import Icon from 'Components/Icon';
@ -72,23 +73,29 @@ class ImportMovieSelectFolder extends Component {
isWindows,
isFetching,
isPopulated,
isSaving,
error,
saveError,
items
} = this.props;
const hasRootFolders = items.length > 0;
return (
<PageContent title={translate('ImportMovies')}>
<PageContentBody>
{
isFetching && !isPopulated &&
<LoadingIndicator />
isFetching && !isPopulated ?
<LoadingIndicator /> :
null
}
{
!isFetching && !!error &&
!isFetching && error ?
<div>
{translate('UnableToLoadRootFolders')}
</div>
</div> :
null
}
{
@ -108,7 +115,7 @@ class ImportMovieSelectFolder extends Component {
</div>
{
items.length > 0 ?
hasRootFolders ?
<div className={styles.recentFolders}>
<FieldSet legend={translate('RecentFolders')}>
<Table
@ -131,35 +138,51 @@ class ImportMovieSelectFolder extends Component {
</TableBody>
</Table>
</FieldSet>
<Button
kind={kinds.PRIMARY}
size={sizes.LARGE}
onPress={this.onAddNewRootFolderPress}
>
<Icon
className={styles.importButtonIcon}
name={icons.DRIVE}
/>
{translate('ChooseAnotherFolder')}
</Button>
</div> :
<div className={styles.startImport}>
<Button
kind={kinds.PRIMARY}
size={sizes.LARGE}
onPress={this.onAddNewRootFolderPress}
>
<Icon
className={styles.importButtonIcon}
name={icons.DRIVE}
/>
{translate('StartImport')}
</Button>
</div>
null
}
{
!isSaving && saveError ?
<Alert
className={styles.addErrorAlert}
kind={kinds.DANGER}
>
{translate('UnableToAddRootFolder')}
<ul>
{
saveError.responseJSON.map((e, index) => {
return (
<li key={index}>
{e.errorMessage}
</li>
);
})
}
</ul>
</Alert> :
null
}
<div className={hasRootFolders ? undefined : styles.startImport}>
<Button
kind={kinds.PRIMARY}
size={sizes.LARGE}
onPress={this.onAddNewRootFolderPress}
>
<Icon
className={styles.importButtonIcon}
name={icons.DRIVE}
/>
{
hasRootFolders ?
translate('ChooseAnotherFolder') :
translate('StartImport')
}
</Button>
</div>
<FileBrowserModal
isOpen={this.state.isAddNewRootFolderModalOpen}
name="rootFolderPath"
@ -179,7 +202,9 @@ ImportMovieSelectFolder.propTypes = {
isWindows: PropTypes.bool.isRequired,
isFetching: PropTypes.bool.isRequired,
isPopulated: PropTypes.bool.isRequired,
isSaving: PropTypes.bool.isRequired,
error: PropTypes.object,
saveError: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired,
onNewRootFolderSelect: PropTypes.func.isRequired,
onDeleteRootFolderPress: PropTypes.func.isRequired

View File

@ -1010,6 +1010,7 @@
"UnableToAddANewNotificationPleaseTryAgain": "Unable to add a new notification, please try again.",
"UnableToAddANewQualityProfilePleaseTryAgain": "Unable to add a new quality profile, please try again.",
"UnableToAddANewRemotePathMappingPleaseTryAgain": "Unable to add a new remote path mapping, please try again.",
"UnableToAddRootFolder": "Unable to add root folder",
"UnableToImportCheckLogs": "Downloaded - Unable to Import: check logs for details",
"UnableToLoadAltTitle": "Unable to load alternative titles.",
"UnableToLoadBackups": "Unable to load backups",