2026-04-10 17:41:19 +01:00
|
|
|
import React from "react";
|
|
|
|
|
import { Stack, Box, Text, Button, ActionIcon, Center } from "@mantine/core";
|
|
|
|
|
import PictureAsPdfIcon from "@mui/icons-material/PictureAsPdf";
|
|
|
|
|
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
|
|
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import { getFileSize } from "@app/utils/fileUtils";
|
|
|
|
|
import { StirlingFileStub } from "@app/types/fileContext";
|
|
|
|
|
import { PrivateContent } from "@app/components/shared/PrivateContent";
|
2025-08-08 15:15:09 +01:00
|
|
|
|
|
|
|
|
interface CompactFileDetailsProps {
|
2025-09-16 15:08:11 +01:00
|
|
|
currentFile: StirlingFileStub | null;
|
2025-08-08 15:15:09 +01:00
|
|
|
thumbnail: string | null;
|
2025-09-16 15:08:11 +01:00
|
|
|
selectedFiles: StirlingFileStub[];
|
2025-08-08 15:15:09 +01:00
|
|
|
currentFileIndex: number;
|
|
|
|
|
numberOfFiles: number;
|
|
|
|
|
isAnimating: boolean;
|
|
|
|
|
onPrevious: () => void;
|
|
|
|
|
onNext: () => void;
|
|
|
|
|
onOpenFiles: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CompactFileDetails: React.FC<CompactFileDetailsProps> = ({
|
|
|
|
|
currentFile,
|
|
|
|
|
thumbnail,
|
|
|
|
|
selectedFiles,
|
|
|
|
|
currentFileIndex,
|
|
|
|
|
numberOfFiles,
|
|
|
|
|
isAnimating,
|
|
|
|
|
onPrevious,
|
|
|
|
|
onNext,
|
2026-04-10 17:41:19 +01:00
|
|
|
onOpenFiles,
|
2025-08-08 15:15:09 +01:00
|
|
|
}) => {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const hasSelection = selectedFiles.length > 0;
|
|
|
|
|
const hasMultipleFiles = numberOfFiles > 1;
|
2026-03-25 11:00:40 +00:00
|
|
|
const showOwner = Boolean(
|
2026-04-10 17:41:19 +01:00
|
|
|
currentFile && (currentFile.remoteOwnedByCurrentUser === false || currentFile.remoteSharedViaLink),
|
2026-03-25 11:00:40 +00:00
|
|
|
);
|
2026-04-10 17:41:19 +01:00
|
|
|
const ownerLabel = currentFile ? currentFile.remoteOwnerUsername || t("fileManager.ownerUnknown", "Unknown") : "";
|
2025-08-08 15:15:09 +01:00
|
|
|
|
|
|
|
|
return (
|
2026-04-10 17:41:19 +01:00
|
|
|
<Stack gap="xs" style={{ height: "100%" }}>
|
2025-08-08 15:15:09 +01:00
|
|
|
{/* Compact mobile layout */}
|
2026-04-10 17:41:19 +01:00
|
|
|
<Box style={{ display: "flex", gap: "0.75rem", alignItems: "center" }}>
|
2025-08-08 15:15:09 +01:00
|
|
|
{/* Small preview */}
|
2026-04-10 17:41:19 +01:00
|
|
|
<Box
|
|
|
|
|
style={{
|
|
|
|
|
width: "7.5rem",
|
|
|
|
|
height: "9.375rem",
|
|
|
|
|
flexShrink: 0,
|
|
|
|
|
position: "relative",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-08-08 15:15:09 +01:00
|
|
|
{currentFile && thumbnail ? (
|
2025-11-10 11:24:14 +00:00
|
|
|
<PrivateContent>
|
|
|
|
|
<img
|
|
|
|
|
src={thumbnail}
|
|
|
|
|
alt={currentFile.name}
|
|
|
|
|
style={{
|
2026-04-10 17:41:19 +01:00
|
|
|
maxWidth: "100%",
|
|
|
|
|
maxHeight: "100%",
|
|
|
|
|
objectFit: "contain",
|
|
|
|
|
borderRadius: "0.25rem",
|
|
|
|
|
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)",
|
2025-11-10 11:24:14 +00:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</PrivateContent>
|
2025-08-08 15:15:09 +01:00
|
|
|
) : currentFile ? (
|
2026-04-10 17:41:19 +01:00
|
|
|
<Center
|
|
|
|
|
style={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
height: "100%",
|
|
|
|
|
backgroundColor: "var(--mantine-color-gray-1)",
|
|
|
|
|
borderRadius: 4,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<PictureAsPdfIcon style={{ fontSize: 20, color: "var(--mantine-color-gray-6)" }} />
|
2025-08-08 15:15:09 +01:00
|
|
|
</Center>
|
|
|
|
|
) : null}
|
|
|
|
|
</Box>
|
2025-09-22 11:46:56 +01:00
|
|
|
|
2025-08-08 15:15:09 +01:00
|
|
|
{/* File info */}
|
|
|
|
|
<Box style={{ flex: 1, minWidth: 0 }}>
|
2025-11-10 11:24:14 +00:00
|
|
|
<Text size="sm" fw={500} truncate>
|
2026-04-10 17:41:19 +01:00
|
|
|
<PrivateContent>{currentFile ? currentFile.name : "No file selected"}</PrivateContent>
|
2025-08-08 15:15:09 +01:00
|
|
|
</Text>
|
|
|
|
|
<Text size="xs" c="dimmed">
|
2026-04-10 17:41:19 +01:00
|
|
|
{currentFile ? getFileSize(currentFile) : ""}
|
2025-08-08 15:15:09 +01:00
|
|
|
{selectedFiles.length > 1 && ` • ${selectedFiles.length} files`}
|
2025-09-16 15:08:11 +01:00
|
|
|
{currentFile && ` • v${currentFile.versionNumber || 1}`}
|
2025-08-08 15:15:09 +01:00
|
|
|
</Text>
|
|
|
|
|
{hasMultipleFiles && (
|
|
|
|
|
<Text size="xs" c="blue">
|
|
|
|
|
{currentFileIndex + 1} of {selectedFiles.length}
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
2025-09-16 15:08:11 +01:00
|
|
|
{/* Compact tool chain for mobile */}
|
|
|
|
|
{currentFile?.toolHistory && currentFile.toolHistory.length > 0 && (
|
|
|
|
|
<Text size="xs" c="dimmed">
|
2026-04-10 17:41:19 +01:00
|
|
|
{currentFile.toolHistory.map((tool) => t(`home.${tool.toolId}.title`, tool.toolId)).join(" → ")}
|
2025-09-16 15:08:11 +01:00
|
|
|
</Text>
|
|
|
|
|
)}
|
2026-03-25 11:00:40 +00:00
|
|
|
{currentFile && showOwner && (
|
|
|
|
|
<Text size="xs" c="dimmed">
|
2026-04-10 17:41:19 +01:00
|
|
|
{t("fileManager.owner", "Owner")}: {ownerLabel}
|
2026-03-25 11:00:40 +00:00
|
|
|
</Text>
|
|
|
|
|
)}
|
2025-08-08 15:15:09 +01:00
|
|
|
</Box>
|
2025-09-22 11:46:56 +01:00
|
|
|
|
2025-08-08 15:15:09 +01:00
|
|
|
{/* Navigation arrows for multiple files */}
|
|
|
|
|
{hasMultipleFiles && (
|
2026-04-10 17:41:19 +01:00
|
|
|
<Box style={{ display: "flex", gap: "0.25rem" }}>
|
|
|
|
|
<ActionIcon variant="subtle" size="sm" onClick={onPrevious} disabled={isAnimating}>
|
2025-08-08 15:15:09 +01:00
|
|
|
<ChevronLeftIcon style={{ fontSize: 16 }} />
|
|
|
|
|
</ActionIcon>
|
2026-04-10 17:41:19 +01:00
|
|
|
<ActionIcon variant="subtle" size="sm" onClick={onNext} disabled={isAnimating}>
|
2025-08-08 15:15:09 +01:00
|
|
|
<ChevronRightIcon style={{ fontSize: 16 }} />
|
|
|
|
|
</ActionIcon>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
2025-09-22 11:46:56 +01:00
|
|
|
|
2025-08-08 15:15:09 +01:00
|
|
|
{/* Action Button */}
|
2025-09-22 11:46:56 +01:00
|
|
|
<Button
|
|
|
|
|
size="sm"
|
2025-08-08 15:15:09 +01:00
|
|
|
onClick={onOpenFiles}
|
|
|
|
|
disabled={!hasSelection}
|
|
|
|
|
fullWidth
|
2025-09-22 11:46:56 +01:00
|
|
|
style={{
|
2026-04-10 17:41:19 +01:00
|
|
|
backgroundColor: hasSelection ? "var(--btn-open-file)" : "var(--mantine-color-gray-4)",
|
|
|
|
|
color: "white",
|
2025-08-08 15:15:09 +01:00
|
|
|
}}
|
|
|
|
|
>
|
2025-09-22 11:46:56 +01:00
|
|
|
{selectedFiles.length > 1
|
2026-04-10 17:41:19 +01:00
|
|
|
? t("fileManager.openFiles", `Open ${selectedFiles.length} Files`)
|
|
|
|
|
: t("fileManager.openFile", "Open File")}
|
2025-08-08 15:15:09 +01:00
|
|
|
</Button>
|
|
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-09-22 11:46:56 +01:00
|
|
|
export default CompactFileDetails;
|