mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fix: [Bug] Do not render editor action buttons (save/discard) when displaying non-code files (#4903)
This commit is contained in:
parent
8dee334236
commit
38dc41ca42
@ -12,6 +12,18 @@ import CodeEditorCompoonent from "./code-editor-component";
|
||||
import { useFiles } from "#/context/files";
|
||||
import { EditorActions } from "#/components/editor-actions";
|
||||
|
||||
const ASSET_FILE_TYPES = [
|
||||
".png",
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".bmp",
|
||||
".gif",
|
||||
".pdf",
|
||||
".mp4",
|
||||
".webm",
|
||||
".ogg",
|
||||
];
|
||||
|
||||
export const clientLoader = async () => {
|
||||
const token = localStorage.getItem("token");
|
||||
return json({ token });
|
||||
@ -104,6 +116,10 @@ function CodeEditor() {
|
||||
if (selectedPath) discardChanges(selectedPath);
|
||||
};
|
||||
|
||||
const isAssetFileType = selectedPath
|
||||
? ASSET_FILE_TYPES.some((ext) => selectedPath.endsWith(ext))
|
||||
: false;
|
||||
|
||||
return (
|
||||
<div className="flex h-full bg-neutral-900 relative">
|
||||
<FileExplorer
|
||||
@ -112,7 +128,7 @@ function CodeEditor() {
|
||||
error={errors.getFiles}
|
||||
/>
|
||||
<div className="w-full">
|
||||
{selectedPath && (
|
||||
{selectedPath && !isAssetFileType && (
|
||||
<div className="flex w-full items-center justify-between self-end p-2">
|
||||
<span className="text-sm text-neutral-500">{selectedPath}</span>
|
||||
<EditorActions
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user