import React, { useRef } from 'react'; import { FaTimes, FaCheck, FaSpinner } from 'react-icons/fa'; import { BsChevronLeft } from 'react-icons/bs'; import CircularProgress from '@mui/material/CircularProgress'; import Sources from './Sources'; import Evaluate from './Evaluate' import './RightSidebar.css'; function RightSidebar({ isOpen, rightSidebarWidth, setRightSidebarWidth, toggleRightSidebar, sidebarContent, tasks = [], tasksLoading, sources = [], sourcesLoading, onTaskClick, onSourceClick, evaluation }) { const minWidth = 200; const maxWidth = 450; const sidebarRef = useRef(null); // Called when the user starts resizing the sidebar. const startResize = (e) => { e.preventDefault(); sidebarRef.current.classList.add("resizing"); // Add the "resizing" class to the sidebar when resizing document.addEventListener("mousemove", resizeSidebar); document.addEventListener("mouseup", stopResize); }; const resizeSidebar = (e) => { let newWidth = window.innerWidth - e.clientX; if (newWidth < minWidth) newWidth = minWidth; if (newWidth > maxWidth) newWidth = maxWidth; setRightSidebarWidth(newWidth); }; const stopResize = () => { sidebarRef.current.classList.remove("resizing"); // Remove the "resizing" class from the sidebar when resizing stops document.removeEventListener("mousemove", resizeSidebar); document.removeEventListener("mouseup", stopResize); }; // Default handler for source clicks: open the link in a new tab. const handleSourceClick = (source) => { if (source && source.link) { window.open(source.link, '_blank'); } }; // Helper function to return the proper icon based on task status. const getTaskIcon = (task) => { // If the task is a simple string, default to the completed icon. if (typeof task === 'string') { return ; } // Use the status field to determine which icon to render. switch (task.status) { case 'RUNNING': // FaSpinner is used for running tasks. The CSS class "spin" can be defined to add animation. return ; case 'DONE': return ; case 'FAILED': return ; default: return ; } }; return ( <> {!isOpen && ( )} ); } export default RightSidebar;