import React from 'react'; import { Box, Text, Collapse, Group } from '@mantine/core'; import { useTranslation } from 'react-i18next'; import { StirlingFileStub } from '../../types/fileContext'; import FileListItem from './FileListItem'; interface FileHistoryGroupProps { leafFile: StirlingFileStub; historyFiles: StirlingFileStub[]; isExpanded: boolean; onDownloadSingle: (file: StirlingFileStub) => void; onFileDoubleClick: (file: StirlingFileStub) => void; onFileRemove: (index: number) => void; isFileSupported: (fileName: string) => boolean; } const FileHistoryGroup: React.FC = ({ leafFile, historyFiles, isExpanded, onDownloadSingle, onFileDoubleClick, onFileRemove, isFileSupported, }) => { const { t } = useTranslation(); // Sort history files by version number (oldest first, excluding the current leaf file) const sortedHistory = historyFiles .filter(file => file.id !== leafFile.id) // Exclude the leaf file itself .sort((a, b) => (a.versionNumber || 1) - (b.versionNumber || 1)); if (!isExpanded || sortedHistory.length === 0) { return null; } return ( {t('fileManager.fileHistory', 'File History')} ({sortedHistory.length}) {sortedHistory.map((historyFile, index) => ( {}} // No selection for history files onRemove={() => onFileRemove(index)} // Pass through remove handler onDownload={() => onDownloadSingle(historyFile)} onDoubleClick={() => onFileDoubleClick(historyFile)} isHistoryFile={true} // This enables "Add to Recents" in menu isLatestVersion={false} // History files are never latest // onAddToRecents is accessed from context by FileListItem /> ))} ); }; export default FileHistoryGroup;