Fixed: Show error if adding root folder fails

Closes #4570
pull/4606/head
Mark McDowall 4 years ago
parent dca2cfcecd
commit 6596d0b4da

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

@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { icons, kinds, sizes } from 'Helpers/Props'; import { icons, kinds, sizes } from 'Helpers/Props';
import Button from 'Components/Link/Button'; import Button from 'Components/Link/Button';
import Alert from 'Components/Alert';
import Icon from 'Components/Icon'; import Icon from 'Components/Icon';
import FieldSet from 'Components/FieldSet'; import FieldSet from 'Components/FieldSet';
import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import LoadingIndicator from 'Components/Loading/LoadingIndicator';
@ -47,21 +48,27 @@ class ImportSeriesSelectFolder extends Component {
isWindows, isWindows,
isFetching, isFetching,
isPopulated, isPopulated,
isSaving,
error, error,
saveError,
items items
} = this.props; } = this.props;
const hasRootFolders = items.length > 0;
return ( return (
<PageContent title="Import Series"> <PageContent title="Import Series">
<PageContentBody> <PageContentBody>
{ {
isFetching && !isPopulated && isFetching && !isPopulated ?
<LoadingIndicator /> <LoadingIndicator /> :
null
} }
{ {
!isFetching && !!error && !isFetching && error ?
<div>Unable to load root folders</div> <div>Unable to load root folders</div> :
null
} }
{ {
@ -87,7 +94,7 @@ class ImportSeriesSelectFolder extends Component {
</div> </div>
{ {
items.length > 0 ? hasRootFolders ?
<div className={styles.recentFolders}> <div className={styles.recentFolders}>
<FieldSet legend="Root Folders"> <FieldSet legend="Root Folders">
<RootFolders <RootFolders
@ -97,35 +104,51 @@ class ImportSeriesSelectFolder extends Component {
items={items} items={items}
/> />
</FieldSet> </FieldSet>
<Button
kind={kinds.PRIMARY}
size={sizes.LARGE}
onPress={this.onAddNewRootFolderPress}
>
<Icon
className={styles.importButtonIcon}
name={icons.DRIVE}
/>
Choose another folder
</Button>
</div> : </div> :
null
}
<div className={styles.startImport}> {
<Button !isSaving && saveError ?
kind={kinds.PRIMARY} <Alert
size={sizes.LARGE} className={styles.addErrorAlert}
onPress={this.onAddNewRootFolderPress} kind={kinds.DANGER}
> >
<Icon Unable to add root folder
className={styles.importButtonIcon}
name={icons.DRIVE} <ul>
/> {
Start Import saveError.responseJSON.map((e, index) => {
</Button> return (
</div> <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 ?
'Choose another folder' :
'Start Import'
}
</Button>
</div>
<FileBrowserModal <FileBrowserModal
isOpen={this.state.isAddNewRootFolderModalOpen} isOpen={this.state.isAddNewRootFolderModalOpen}
name="rootFolderPath" name="rootFolderPath"
@ -145,7 +168,9 @@ ImportSeriesSelectFolder.propTypes = {
isWindows: PropTypes.bool.isRequired, isWindows: PropTypes.bool.isRequired,
isFetching: PropTypes.bool.isRequired, isFetching: PropTypes.bool.isRequired,
isPopulated: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired,
isSaving: PropTypes.bool.isRequired,
error: PropTypes.object, error: PropTypes.object,
saveError: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
onNewRootFolderSelect: PropTypes.func.isRequired onNewRootFolderSelect: PropTypes.func.isRequired
}; };

Loading…
Cancel
Save