Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-06-23 22:35:51 -04:00
commit daa3648b06
5 changed files with 18 additions and 13 deletions

View file

@ -51,4 +51,4 @@ const DeleteLibraryButton = ({ record, resource, basePath, ...props }) => {
)
}
export default DeleteLibraryButton
export default DeleteLibraryButton

View file

@ -41,11 +41,11 @@ const LibraryCreate = (props) => {
if (error.body && error.body.errors) {
return error.body.errors
}
// Handle other structured errors from the server
if (error.body && error.body.error) {
const errorMsg = error.body.error
// Handle database constraint violations
if (errorMsg.includes('UNIQUE constraint failed: library.name')) {
return { name: 'ra.validation.unique' }
@ -53,14 +53,15 @@ const LibraryCreate = (props) => {
if (errorMsg.includes('UNIQUE constraint failed: library.path')) {
return { path: 'ra.validation.unique' }
}
// Show a general notification for other server errors
notify(errorMsg, 'error')
return
}
// Fallback for unexpected error formats
const fallbackMessage = error.message ||
const fallbackMessage =
error.message ||
(typeof error === 'string' ? error : 'An unexpected error occurred')
notify(fallbackMessage, 'error')
}
@ -78,4 +79,4 @@ const LibraryCreate = (props) => {
)
}
export default LibraryCreate
export default LibraryCreate

View file

@ -119,12 +119,11 @@ const LibraryEdit = (props) => {
fullWidth
disabled={isFirstLibrary}
/>
<Divider className={classes.divider} fullWidth />
<Typography variant="h6" gutterBottom>
Statistics
</Typography>
{/*eslint-disable-next-line react/no-unknown-property*/}
<div className={classes.stats} fullWidth>
<div>
<Typography variant="caption" display="block" color="textSecondary">
@ -178,6 +177,7 @@ const LibraryEdit = (props) => {
</div>
</div>
<Divider className={classes.divider} fullWidth />
{/*eslint-disable-next-line react/no-unknown-property*/}
<div className={classes.stats} fullWidth>
<div>
<Typography variant="caption" display="block" color="textSecondary">

View file

@ -40,11 +40,15 @@ const LibraryList = (props) => {
<NumberField source="totalSongs" label="Songs" />
<NumberField source="totalAlbums" label="Albums" />
<NumberField source="totalMissingFiles" label="Missing Files" />
<DateField source="lastScanAt" label="Last Scan" sortByOrder={'DESC'} />
<DateField
source="lastScanAt"
label="Last Scan"
sortByOrder={'DESC'}
/>
</Datagrid>
)}
</List>
)
}
export default LibraryList
export default LibraryList

View file

@ -1,9 +1,9 @@
import LibraryList from './LibraryList'
import LibraryEdit from './LibraryEdit'
import LibraryCreate from './LibraryCreate'
export default {
list: LibraryList,
edit: LibraryEdit,
create: LibraryCreate,
}
}