diff --git a/ui/src/components/code-editor/view/subcomponents/CodeEditorBinaryFile.tsx b/ui/src/components/code-editor/view/subcomponents/CodeEditorBinaryFile.tsx
index 124e7989..b2046625 100644
--- a/ui/src/components/code-editor/view/subcomponents/CodeEditorBinaryFile.tsx
+++ b/ui/src/components/code-editor/view/subcomponents/CodeEditorBinaryFile.tsx
@@ -101,18 +101,16 @@ function FallbackContent({ title, message, onClose }: { title: string; message:
);
}
-function ImagePreview({ projectName, file, title, message, onClose }: {
- projectName?: string;
+function ImagePreview({ blobUrl, file, title, message, onClose }: {
+ blobUrl: string;
file: CodeEditorFile;
title: string;
message: string;
onClose: () => void;
}) {
- const { blobUrl, error, loading } = useBlobUrl(projectName, file.path, true);
const [imgError, setImgError] = useState(false);
- if (loading) return ;
- if (error || imgError || !blobUrl) {
+ if (imgError || !blobUrl) {
return ;
}
@@ -128,20 +126,10 @@ function ImagePreview({ projectName, file, title, message, onClose }: {
);
}
-function PdfPreview({ projectName, file, title, message, onClose }: {
- projectName?: string;
+function PdfPreview({ blobUrl, file }: {
+ blobUrl: string;
file: CodeEditorFile;
- title: string;
- message: string;
- onClose: () => void;
}) {
- const { blobUrl, error, loading } = useBlobUrl(projectName, file.path, true);
-
- if (loading) return ;
- if (error || !blobUrl) {
- return ;
- }
-
return (
- : isPdf
- ?
- :
;
+ const { blobUrl, error: blobError, loading } = useBlobUrl(projectName, file.path, canPreview);
+
+ let previewContent;
+ if (loading) {
+ previewContent =
;
+ } else if (blobError || !blobUrl) {
+ previewContent =
;
+ } else if (isImage) {
+ previewContent = (
+
+ );
+ } else if (isPdf) {
+ previewContent =
;
+ } else {
+ previewContent =
;
+ }
const headerTopBar = (
@@ -184,6 +189,28 @@ export default function CodeEditorBinaryFile({
+ {canPreview && blobUrl && !loading && !blobError && (
+
+
+
+ )}
{!isSidebar && (