import React from 'react'; import {ArrowDown, ArrowUp} from 'lucide-react'; import ChangeRow from './ChangeRow'; import ConflictRow from './ConflictRow'; const ChangeTable = ({ changes, isIncoming, isMergeConflict, selectedChanges, willBeSelected, onSelectChange, onMouseEnter, onMouseLeave, sortConfig, onRequestSort, fetchGitStatus }) => { const sortedChanges = changesArray => { // Process changes to extract type from path for unknown types const processedChanges = changesArray.map(change => { if (!change) return change; // Only process items with unknown type if (change.type?.toLowerCase() === 'unknown' && change.file_path) { // Extract type from file path (assuming format: "type/name") const pathParts = change.file_path.split('/'); if (pathParts.length > 1) { return { ...change, type: pathParts[0] }; } } return change; }); if (isMergeConflict || !sortConfig?.key) return processedChanges; return [...processedChanges].sort((a, b) => { if (a[sortConfig.key] < b[sortConfig.key]) { return sortConfig.direction === 'ascending' ? -1 : 1; } if (a[sortConfig.key] > b[sortConfig.key]) { return sortConfig.direction === 'ascending' ? 1 : -1; } return 0; }); }; const SortableHeader = ({children, sortKey, className}) => { const isSorted = sortConfig.key === sortKey; return ( onRequestSort(sortKey)}>
{children} {isSorted && (sortConfig.direction === 'ascending' ? ( ) : ( ))}
); }; const handleRowMouseDown = (e, change, index) => { // Prevent text selection when shift-clicking if (e.shiftKey) { e.preventDefault(); } }; return (
Status Type Name {sortedChanges(changes).map((change, index) => isMergeConflict ? ( ) : ( onSelectChange( path, index, window.event?.shiftKey ) } onMouseEnter={path => onMouseEnter( path, index, window.event?.shiftKey ) } onMouseLeave={onMouseLeave} onMouseDown={e => handleRowMouseDown(e, change, index) } isIncoming={isIncoming} /> ) )}
Actions
); }; export default ChangeTable;