2025-08-08 15:15:09 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { Stack, Card, Box, Text, Badge, Group, Divider, ScrollArea } from '@mantine/core';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { detectFileExtension, getFileSize } from '../../utils/fileUtils';
|
2025-08-21 17:30:26 +01:00
|
|
|
import { FileMetadata } from '../../types/file';
|
2025-09-03 17:47:58 +01:00
|
|
|
import ToolChain from '../shared/ToolChain';
|
2025-08-08 15:15:09 +01:00
|
|
|
|
|
|
|
interface FileInfoCardProps {
|
2025-08-21 17:30:26 +01:00
|
|
|
currentFile: FileMetadata | null;
|
2025-08-08 15:15:09 +01:00
|
|
|
modalHeight: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FileInfoCard: React.FC<FileInfoCardProps> = ({
|
|
|
|
currentFile,
|
|
|
|
modalHeight
|
|
|
|
}) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
2025-09-02 17:24:26 +01:00
|
|
|
<Card withBorder p={0} h={`calc(${modalHeight} * 0.38 - 1rem)`} style={{ flex: 1, overflow: 'hidden' }}>
|
2025-08-22 17:12:14 +01:00
|
|
|
<Box bg="gray.4" p="sm" style={{ borderTopLeftRadius: 'var(--mantine-radius-md)', borderTopRightRadius: 'var(--mantine-radius-md)' }}>
|
2025-08-08 15:15:09 +01:00
|
|
|
<Text size="sm" fw={500} ta="center" c="white">
|
|
|
|
{t('fileManager.details', 'File Details')}
|
|
|
|
</Text>
|
|
|
|
</Box>
|
|
|
|
<ScrollArea style={{ flex: 1 }} p="md">
|
|
|
|
<Stack gap="sm">
|
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.fileName', 'Name')}</Text>
|
|
|
|
<Text size="sm" fw={500} style={{ maxWidth: '60%', textAlign: 'right' }} truncate>
|
|
|
|
{currentFile ? currentFile.name : ''}
|
|
|
|
</Text>
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
2025-08-22 17:12:14 +01:00
|
|
|
|
2025-08-08 15:15:09 +01:00
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.fileFormat', 'Format')}</Text>
|
|
|
|
{currentFile ? (
|
|
|
|
<Badge size="sm" variant="light">
|
|
|
|
{detectFileExtension(currentFile.name).toUpperCase()}
|
|
|
|
</Badge>
|
|
|
|
) : (
|
|
|
|
<Text size="sm" fw={500}></Text>
|
|
|
|
)}
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
2025-08-22 17:12:14 +01:00
|
|
|
|
2025-08-08 15:15:09 +01:00
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.fileSize', 'Size')}</Text>
|
|
|
|
<Text size="sm" fw={500}>
|
|
|
|
{currentFile ? getFileSize(currentFile) : ''}
|
|
|
|
</Text>
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
2025-08-22 17:12:14 +01:00
|
|
|
|
2025-09-03 14:48:14 +01:00
|
|
|
{/* Standard PDF Metadata */}
|
|
|
|
{currentFile?.pdfMetadata?.title && (
|
|
|
|
<>
|
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.title', 'Title')}</Text>
|
|
|
|
<Text size="sm" fw={500} style={{ maxWidth: '60%', textAlign: 'right' }} truncate>
|
|
|
|
{currentFile.pdfMetadata.title}
|
|
|
|
</Text>
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{currentFile?.pdfMetadata?.author && (
|
|
|
|
<>
|
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.author', 'Author')}</Text>
|
|
|
|
<Text size="sm" fw={500} style={{ maxWidth: '60%', textAlign: 'right' }} truncate>
|
|
|
|
{currentFile.pdfMetadata.author}
|
|
|
|
</Text>
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{currentFile?.pdfMetadata?.subject && (
|
|
|
|
<>
|
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.subject', 'Subject')}</Text>
|
|
|
|
<Text size="sm" fw={500} style={{ maxWidth: '60%', textAlign: 'right' }} truncate>
|
|
|
|
{currentFile.pdfMetadata.subject}
|
|
|
|
</Text>
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{currentFile?.pdfMetadata?.creationDate && (
|
|
|
|
<>
|
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.created', 'Created')}</Text>
|
|
|
|
<Text size="sm" fw={500}>
|
|
|
|
{new Date(currentFile.pdfMetadata.creationDate).toLocaleDateString()}
|
|
|
|
</Text>
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.lastModified', 'Last Modified')}</Text>
|
|
|
|
<Text size="sm" fw={500}>
|
|
|
|
{currentFile ? new Date(currentFile.lastModified).toLocaleDateString() : ''}
|
|
|
|
</Text>
|
|
|
|
</Group>
|
|
|
|
<Divider />
|
|
|
|
|
2025-08-08 15:15:09 +01:00
|
|
|
<Group justify="space-between" py="xs">
|
|
|
|
<Text size="sm" c="dimmed">{t('fileManager.fileVersion', 'Version')}</Text>
|
2025-09-02 17:24:26 +01:00
|
|
|
{currentFile &&
|
|
|
|
<Badge size="sm" variant="light" color={currentFile?.versionNumber ? 'blue' : 'gray'}>
|
|
|
|
v{currentFile ? (currentFile.versionNumber || 0) : ''}
|
|
|
|
</Badge>}
|
|
|
|
|
2025-08-08 15:15:09 +01:00
|
|
|
</Group>
|
2025-09-02 17:24:26 +01:00
|
|
|
|
2025-09-03 17:47:58 +01:00
|
|
|
{/* Tool Chain Display */}
|
2025-09-02 17:24:26 +01:00
|
|
|
{currentFile?.historyInfo?.toolChain && currentFile.historyInfo.toolChain.length > 0 && (
|
|
|
|
<>
|
|
|
|
<Divider />
|
|
|
|
<Box py="xs">
|
2025-09-03 17:47:58 +01:00
|
|
|
<Text size="xs" c="dimmed" mb="xs">{t('fileManager.toolChain', 'Tools Applied')}</Text>
|
2025-09-03 17:57:39 +01:00
|
|
|
<ToolChain
|
2025-09-03 17:47:58 +01:00
|
|
|
toolChain={currentFile.historyInfo.toolChain}
|
|
|
|
displayStyle="badges"
|
|
|
|
size="xs"
|
2025-09-03 17:57:39 +01:00
|
|
|
maxWidth={'180px'}
|
2025-09-03 17:47:58 +01:00
|
|
|
/>
|
2025-09-02 17:24:26 +01:00
|
|
|
</Box>
|
|
|
|
</>
|
|
|
|
)}
|
2025-08-08 15:15:09 +01:00
|
|
|
</Stack>
|
|
|
|
</ScrollArea>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2025-08-22 17:12:14 +01:00
|
|
|
export default FileInfoCard;
|