# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: EthanHealy01 <ethan.healy.21@gmail.com> Co-authored-by: EthanHealy01 <80844253+EthanHealy01@users.noreply.github.com>
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
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;
|
|
onHistoryFileRemove: (file: StirlingFileStub) => void;
|
|
isFileSupported: (fileName: string) => boolean;
|
|
}
|
|
|
|
const FileHistoryGroup: React.FC<FileHistoryGroupProps> = ({
|
|
leafFile,
|
|
historyFiles,
|
|
isExpanded,
|
|
onDownloadSingle,
|
|
onFileDoubleClick,
|
|
onHistoryFileRemove,
|
|
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) => (b.versionNumber || 1) - (a.versionNumber || 1));
|
|
|
|
if (!isExpanded || sortedHistory.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Collapse in={isExpanded}>
|
|
<Box ml="md" mt="xs" mb="sm">
|
|
<Group align="center" mb="sm">
|
|
<Text size="xs" fw={600} c="dimmed">
|
|
{t('fileManager.fileHistory', 'File History')} ({sortedHistory.length})
|
|
</Text>
|
|
</Group>
|
|
|
|
<Box ml="md">
|
|
{sortedHistory.map((historyFile) => (
|
|
<FileListItem
|
|
key={`history-${historyFile.id}-${historyFile.versionNumber || 1}`}
|
|
file={historyFile}
|
|
isSelected={false} // History files are not selectable
|
|
isSupported={isFileSupported(historyFile.name)}
|
|
onSelect={() => {}} // No selection for history files
|
|
onRemove={() => onHistoryFileRemove(historyFile)} // Remove specific history file
|
|
onDownload={() => onDownloadSingle(historyFile)}
|
|
onDoubleClick={() => onFileDoubleClick(historyFile)}
|
|
isHistoryFile={true} // This enables "Add to Recents" in menu
|
|
isLatestVersion={false} // History files are never latest
|
|
/>
|
|
))}
|
|
</Box>
|
|
</Box>
|
|
</Collapse>
|
|
);
|
|
};
|
|
|
|
export default FileHistoryGroup;
|