From 03934b138529298ca34ee081d2c4157594ad9ceb Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 26 Mar 2025 16:24:38 +0800 Subject: [PATCH] fix(ui): improve pipeline status dialog layout and styling - Switch from AlertDialog to Dialog component for better modal behavior - Adjust dialog positioning and alignment controls - Remove custom close button to avoid duplication - Add proper spacing between alignment buttons and close button - Simplify history container height with min/max height - Reduce overlay opacity for better visibility --- .../documents/PipelineStatusDialog.tsx | 148 +++++++----------- lightrag_webui/src/components/ui/Dialog.tsx | 2 +- 2 files changed, 54 insertions(+), 96 deletions(-) diff --git a/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx b/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx index 8b83132b..cdf29ca0 100644 --- a/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx +++ b/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx @@ -1,16 +1,15 @@ -import { useState, useEffect, useRef, useCallback } from 'react' +import { useState, useEffect, useRef } from 'react' import { useTranslation } from 'react-i18next' import { toast } from 'sonner' -import { X, AlignLeft, AlignCenter, AlignRight } from 'lucide-react' +import { AlignLeft, AlignCenter, AlignRight } from 'lucide-react' import { - AlertDialog, - AlertDialogContent, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogDescription, - AlertDialogOverlay, -} from '@/components/ui/AlertDialog' + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogDescription +} from '@/components/ui/Dialog' import Button from '@/components/ui/Button' import { getPipelineStatus, PipelineStatusResponse } from '@/api/lightrag' import { errorMessage } from '@/lib/utils' @@ -31,44 +30,15 @@ export default function PipelineStatusDialog({ const [status, setStatus] = useState(null) const [position, setPosition] = useState('center') const [isUserScrolled, setIsUserScrolled] = useState(false) - const [historyHeight, setHistoryHeight] = useState('20em') const historyRef = useRef(null) - const resizeObserverRef = useRef(null) - - // Calculate history height based on window height - const updateHistoryHeight = useCallback(() => { - const minHeight = 7.5 // 5 lines * 1.5em line height - const windowHeight = window.innerHeight - const pixelsPerEm = parseFloat(getComputedStyle(document.documentElement).fontSize) - const maxHeightInEm = Math.max(Math.floor((windowHeight * 0.4) / pixelsPerEm), minHeight) - setHistoryHeight(`${maxHeightInEm}em`) - }, []) // Reset position when dialog opens useEffect(() => { if (open) { setPosition('center') setIsUserScrolled(false) - updateHistoryHeight() } - }, [open, updateHistoryHeight]) - - // Setup resize observer - useEffect(() => { - if (!open) return - - resizeObserverRef.current = new ResizeObserver((entries) => { - if (entries[0]) { - updateHistoryHeight() - } - }) - - resizeObserverRef.current.observe(document.body) - - return () => { - resizeObserverRef.current?.disconnect() - } - }, [open, updateHistoryHeight]) + }, [open]) // Handle scroll position useEffect(() => { @@ -112,74 +82,63 @@ export default function PipelineStatusDialog({ }, [open, t]) return ( - - - + - + {status?.job_name ? `${t('documentPanel.pipelineStatus.jobName')}: ${status.job_name}, ${t('documentPanel.pipelineStatus.progress')}: ${status.cur_batch}/${status.batchs}` : t('documentPanel.pipelineStatus.noActiveJob') } - - - + + + {t('documentPanel.pipelineStatus.title')} - + - {/* Position control buttons and close button */} -
-
- - - -
+ {/* Position control buttons */} +
+ +
- + {/* Status Content */}
@@ -218,8 +177,7 @@ export default function PipelineStatusDialog({
{status?.history_messages?.map((msg, idx) => (
{msg}
@@ -227,7 +185,7 @@ export default function PipelineStatusDialog({
-
-
+ + ) } diff --git a/lightrag_webui/src/components/ui/Dialog.tsx b/lightrag_webui/src/components/ui/Dialog.tsx index a45f1e32..75d806f5 100644 --- a/lightrag_webui/src/components/ui/Dialog.tsx +++ b/lightrag_webui/src/components/ui/Dialog.tsx @@ -19,7 +19,7 @@ const DialogOverlay = React.forwardRef<