Fixed: Show errors when adding Root Folder

This commit is contained in:
Bogdan 2023-12-31 02:07:06 +02:00 committed by GitHub
parent 0a5200766e
commit 16d60a6586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 22 deletions

View File

@ -118,7 +118,7 @@ class ImportSeriesSelectFolder extends Component {
className={styles.addErrorAlert}
kind={kinds.DANGER}
>
{translate('RootFolderLoadError')}
{translate('AddRootFolderError')}
<ul>
{

View File

@ -49,7 +49,7 @@ function RootFolders() {
if (!isFetching && !!error) {
return (
<Alert kind={kinds.DANGER}>{translate('UnableToLoadRootFolders')}</Alert>
<Alert kind={kinds.DANGER}>{translate('RootFoldersLoadError')}</Alert>
);
}

View File

@ -1,14 +1,18 @@
import React, { useCallback, useState } from 'react';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import Alert from 'Components/Alert';
import FileBrowserModal from 'Components/FileBrowser/FileBrowserModal';
import Icon from 'Components/Icon';
import Button from 'Components/Link/Button';
import { icons, kinds, sizes } from 'Helpers/Props';
import { addRootFolder } from 'Store/Actions/rootFolderActions';
import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector';
import translate from 'Utilities/String/translate';
import styles from './AddRootFolder.css';
function AddRootFolder() {
const { isSaving, saveError } = useSelector(createRootFoldersSelector());
const dispatch = useDispatch();
const [isAddNewRootFolderModalOpen, setIsAddNewRootFolderModalOpen] =
@ -30,24 +34,42 @@ function AddRootFolder() {
}, [setIsAddNewRootFolderModalOpen]);
return (
<div className={styles.addRootFolderButtonContainer}>
<Button
kind={kinds.PRIMARY}
size={sizes.LARGE}
onPress={onAddNewRootFolderPress}
>
<Icon className={styles.importButtonIcon} name={icons.DRIVE} />
{translate('AddRootFolder')}
</Button>
<>
{!isSaving && saveError ? (
<Alert kind={kinds.DANGER}>
{translate('AddRootFolderError')}
<FileBrowserModal
isOpen={isAddNewRootFolderModalOpen}
name="rootFolderPath"
value=""
onChange={onNewRootFolderSelect}
onModalClose={onAddRootFolderModalClose}
/>
</div>
<ul>
{Array.isArray(saveError.responseJSON) ? (
saveError.responseJSON.map((e, index) => {
return <li key={index}>{e.errorMessage}</li>;
})
) : (
<li>{JSON.stringify(saveError.responseJSON)}</li>
)}
</ul>
</Alert>
) : null}
<div className={styles.addRootFolderButtonContainer}>
<Button
kind={kinds.PRIMARY}
size={sizes.LARGE}
onPress={onAddNewRootFolderPress}
>
<Icon className={styles.importButtonIcon} name={icons.DRIVE} />
{translate('AddRootFolder')}
</Button>
<FileBrowserModal
isOpen={isAddNewRootFolderModalOpen}
name="rootFolderPath"
value=""
onChange={onNewRootFolderSelect}
onModalClose={onAddRootFolderModalClose}
/>
</div>
</>
);
}

View File

@ -49,6 +49,7 @@
"AddRemotePathMapping": "Add Remote Path Mapping",
"AddRemotePathMappingError": "Unable to add a new remote path mapping, please try again.",
"AddRootFolder": "Add Root Folder",
"AddRootFolderError": "Unable to add root folder",
"AddSeriesWithTitle": "Add {title}",
"AddToDownloadQueue": "Add to download queue",
"Added": "Added",
@ -1348,7 +1349,6 @@
"RetentionHelpText": "Usenet only: Set to zero to set for unlimited retention",
"RetryingDownloadOn": "Retrying download on {date} at {time}",
"RootFolder": "Root Folder",
"RootFolderLoadError": "Unable to add root folder",
"RootFolderMissingHealthCheckMessage": "Missing root folder: {rootFolderPath}",
"RootFolderMultipleMissingHealthCheckMessage": "Multiple root folders are missing: {rootFolderPaths}",
"RootFolderPath": "Root Folder Path",
@ -1620,7 +1620,6 @@
"Umask777Description": "{octal} - Everyone write",
"UnableToLoadAutoTagging": "Unable to load auto tagging",
"UnableToLoadBackups": "Unable to load backups",
"UnableToLoadRootFolders": "Unable to load root folders",
"UnableToUpdateSonarrDirectly": "Unable to update {appName} directly,",
"Unavailable": "Unavailable",
"Underscore": "Underscore",