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} className={styles.addErrorAlert}
kind={kinds.DANGER} kind={kinds.DANGER}
> >
{translate('RootFolderLoadError')} {translate('AddRootFolderError')}
<ul> <ul>
{ {

View File

@ -49,7 +49,7 @@ function RootFolders() {
if (!isFetching && !!error) { if (!isFetching && !!error) {
return ( 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 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 FileBrowserModal from 'Components/FileBrowser/FileBrowserModal';
import Icon from 'Components/Icon'; import Icon from 'Components/Icon';
import Button from 'Components/Link/Button'; import Button from 'Components/Link/Button';
import { icons, kinds, sizes } from 'Helpers/Props'; import { icons, kinds, sizes } from 'Helpers/Props';
import { addRootFolder } from 'Store/Actions/rootFolderActions'; import { addRootFolder } from 'Store/Actions/rootFolderActions';
import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import styles from './AddRootFolder.css'; import styles from './AddRootFolder.css';
function AddRootFolder() { function AddRootFolder() {
const { isSaving, saveError } = useSelector(createRootFoldersSelector());
const dispatch = useDispatch(); const dispatch = useDispatch();
const [isAddNewRootFolderModalOpen, setIsAddNewRootFolderModalOpen] = const [isAddNewRootFolderModalOpen, setIsAddNewRootFolderModalOpen] =
@ -30,6 +34,23 @@ function AddRootFolder() {
}, [setIsAddNewRootFolderModalOpen]); }, [setIsAddNewRootFolderModalOpen]);
return ( return (
<>
{!isSaving && saveError ? (
<Alert kind={kinds.DANGER}>
{translate('AddRootFolderError')}
<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}> <div className={styles.addRootFolderButtonContainer}>
<Button <Button
kind={kinds.PRIMARY} kind={kinds.PRIMARY}
@ -48,6 +69,7 @@ function AddRootFolder() {
onModalClose={onAddRootFolderModalClose} onModalClose={onAddRootFolderModalClose}
/> />
</div> </div>
</>
); );
} }

View File

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