feat: remove folders & create folder

This commit is contained in:
nikita
2026-04-05 03:28:31 +03:00
parent 5073cfd357
commit 178c3b53f7
6 changed files with 206 additions and 38 deletions
@@ -46,6 +46,10 @@ export const FileExplorer: React.FC<FileExplorerProps> = ({
const handleEmptyContextMenu = (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
// Загружаем интерпретаторы перед открытием меню
if (store.interpreters.length === 0) {
store.fetchInterpreters();
}
store.setContextMenu({ x: e.clientX, y: e.clientY, node: null });
};
@@ -55,6 +59,13 @@ export const FileExplorer: React.FC<FileExplorerProps> = ({
store.setContextMenu({ x: e.clientX, y: e.clientY, node });
};
// Загружаем интерпретаторы при монтировании компонента
useEffect(() => {
if (store.interpreters.length === 0) {
store.fetchInterpreters();
}
}, []);
const filteredFiles = store.searchQuery
? (files.children || [])
.map((child) => filterTree(child, store.searchQuery))
@@ -320,8 +331,13 @@ export const FileExplorer: React.FC<FileExplorerProps> = ({
? store.dialog.node.name
: ""
}
onConfirm={store.handleDialogConfirm}
onConfirm={(value, interpreterId) => {
store.handleDialogConfirm(value, interpreterId);
}}
onCancel={() => store.setDialog(null)}
interpreters={
store.dialog.type === "newFile" ? store.interpreters : undefined
}
/>
)}
</div>
@@ -1,10 +1,12 @@
import React, { useState, useRef, useEffect } from "react";
import type { Interpreter } from "../types";
interface InputDialogProps {
title: string;
initialValue?: string;
onConfirm: (value: string) => void;
onConfirm: (value: string, interpreterId?: number) => void;
onCancel: () => void;
interpreters?: Interpreter[];
}
export const InputDialog: React.FC<InputDialogProps> = ({
@@ -12,8 +14,12 @@ export const InputDialog: React.FC<InputDialogProps> = ({
initialValue = "",
onConfirm,
onCancel,
interpreters,
}) => {
const [value, setValue] = useState(initialValue);
const [interpreterId, setInterpreterId] = useState<number | undefined>(
interpreters?.[0]?.id,
);
const inputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
@@ -21,6 +27,8 @@ export const InputDialog: React.FC<InputDialogProps> = ({
inputRef.current?.select();
}, []);
const showInterpreterDropdown = interpreters && interpreters.length > 0;
return (
<div
style={{
@@ -59,7 +67,7 @@ export const InputDialog: React.FC<InputDialogProps> = ({
{title}
</h3>
<p style={{ margin: "0 0 16px 0", color: "#858585", fontSize: "12px" }}>
Enter a new name
Enter a name
</p>
<input
ref={inputRef}
@@ -67,7 +75,9 @@ export const InputDialog: React.FC<InputDialogProps> = ({
value={value}
onChange={(e) => setValue(e.target.value)}
onKeyDown={(e) =>
e.key === "Enter" && value.trim() && onConfirm(value.trim())
e.key === "Enter" &&
value.trim() &&
onConfirm(value.trim(), interpreterId)
}
style={{
width: "100%",
@@ -77,10 +87,48 @@ export const InputDialog: React.FC<InputDialogProps> = ({
borderRadius: "6px",
color: "#ccc",
fontSize: "14px",
marginBottom: "20px",
marginBottom: showInterpreterDropdown ? "12px" : "20px",
outline: "none",
}}
/>
{/* Interpreter dropdown */}
{showInterpreterDropdown && (
<div style={{ marginBottom: "20px" }}>
<label
style={{
display: "block",
fontSize: "12px",
color: "#858585",
marginBottom: "6px",
}}
>
Interpreter
</label>
<select
value={interpreterId}
onChange={(e) => setInterpreterId(Number(e.target.value))}
style={{
width: "100%",
padding: "10px",
backgroundColor: "#3c3c3c",
border: "1px solid #3e3e42",
borderRadius: "6px",
color: "#ccc",
fontSize: "14px",
outline: "none",
cursor: "pointer",
}}
>
{interpreters.map((interp) => (
<option key={interp.id} value={interp.id}>
{interp.label}
</option>
))}
</select>
</div>
)}
<div
style={{ display: "flex", gap: "12px", justifyContent: "flex-end" }}
>
@@ -99,7 +147,9 @@ export const InputDialog: React.FC<InputDialogProps> = ({
Cancel
</button>
<button
onClick={() => value.trim() && onConfirm(value.trim())}
onClick={() =>
value.trim() && onConfirm(value.trim(), interpreterId)
}
style={{
padding: "6px 16px",
backgroundColor: "#0e639c",