yangdx
commited on
Commit
Β·
1933c59
1
Parent(s):
6f72f1d
Improve toast notifications and document clearing flow
Browse files- Enhanced Toaster component with theme, close button and rich colors
- Added immediate feedback for document clearing operation
lightrag_webui/src/AppRouter.tsx
CHANGED
@@ -80,7 +80,12 @@ const AppRouter = () => {
|
|
80 |
<ThemeProvider>
|
81 |
<Router>
|
82 |
<AppContent />
|
83 |
-
<Toaster
|
|
|
|
|
|
|
|
|
|
|
84 |
</Router>
|
85 |
</ThemeProvider>
|
86 |
)
|
|
|
80 |
<ThemeProvider>
|
81 |
<Router>
|
82 |
<AppContent />
|
83 |
+
<Toaster
|
84 |
+
position="bottom-center"
|
85 |
+
theme="system"
|
86 |
+
closeButton
|
87 |
+
richColors
|
88 |
+
/>
|
89 |
</Router>
|
90 |
</ThemeProvider>
|
91 |
)
|
lightrag_webui/src/components/documents/ClearDocumentsDialog.tsx
CHANGED
@@ -61,6 +61,14 @@ export default function ClearDocumentsDialog({ onDocumentsCleared }: ClearDocume
|
|
61 |
try {
|
62 |
const result = await clearDocuments()
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
if (clearCacheOption) {
|
65 |
try {
|
66 |
await clearCache()
|
@@ -70,28 +78,19 @@ export default function ClearDocumentsDialog({ onDocumentsCleared }: ClearDocume
|
|
70 |
}
|
71 |
}
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
toast.error(t('documentPanel.clearDocuments.error', { error: errorMessage(err) }))
|
80 |
-
} finally {
|
81 |
-
// Execute these operations regardless of success or failure
|
82 |
-
try {
|
83 |
-
// Update backend state
|
84 |
-
await check()
|
85 |
-
|
86 |
-
// Refresh document list
|
87 |
-
if (onDocumentsCleared) {
|
88 |
-
await onDocumentsCleared()
|
89 |
-
}
|
90 |
-
} catch (refreshErr) {
|
91 |
-
console.error('Error refreshing state:', refreshErr)
|
92 |
}
|
93 |
|
|
|
94 |
setOpen(false)
|
|
|
|
|
|
|
95 |
}
|
96 |
}, [isConfirmEnabled, clearCacheOption, setOpen, t, check, onDocumentsCleared])
|
97 |
|
|
|
61 |
try {
|
62 |
const result = await clearDocuments()
|
63 |
|
64 |
+
if (result.status !== 'success') {
|
65 |
+
toast.error(t('documentPanel.clearDocuments.failed', { message: result.message }))
|
66 |
+
setConfirmText('')
|
67 |
+
return
|
68 |
+
}
|
69 |
+
|
70 |
+
toast.success(t('documentPanel.clearDocuments.success'))
|
71 |
+
|
72 |
if (clearCacheOption) {
|
73 |
try {
|
74 |
await clearCache()
|
|
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
// Update health check status
|
82 |
+
await check()
|
83 |
+
|
84 |
+
// Refresh document list if provided
|
85 |
+
if (onDocumentsCleared) {
|
86 |
+
await onDocumentsCleared()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
+
// ζζζδ½ζεεε
³ιε―Ήθ―ζ‘
|
90 |
setOpen(false)
|
91 |
+
} catch (err) {
|
92 |
+
toast.error(t('documentPanel.clearDocuments.error', { error: errorMessage(err) }))
|
93 |
+
setConfirmText('')
|
94 |
}
|
95 |
}, [isConfirmEnabled, clearCacheOption, setOpen, t, check, onDocumentsCleared])
|
96 |
|