-
+
Confirm Delete
diff --git a/src/ui/apps/File Manager/FileManagerHomeView.tsx b/src/ui/apps/File Manager/FileManagerHomeView.tsx
index 3ac98b16..ae75804e 100644
--- a/src/ui/apps/File Manager/FileManagerHomeView.tsx
+++ b/src/ui/apps/File Manager/FileManagerHomeView.tsx
@@ -32,17 +32,17 @@ interface FileManagerHomeViewProps {
}
export function FileManagerHomeView({
- recent,
- pinned,
- shortcuts,
- onOpenFile,
- onRemoveRecent,
- onPinFile,
- onUnpinFile,
- onOpenShortcut,
- onRemoveShortcut,
- onAddShortcut
- }: FileManagerHomeViewProps) {
+ recent,
+ pinned,
+ shortcuts,
+ onOpenFile,
+ onRemoveRecent,
+ onPinFile,
+ onUnpinFile,
+ onOpenShortcut,
+ onRemoveShortcut,
+ onAddShortcut
+ }: FileManagerHomeViewProps) {
const [tab, setTab] = useState<'recent' | 'pinned' | 'shortcuts'>('recent');
const [newShortcut, setNewShortcut] = useState('');
@@ -128,7 +128,8 @@ export function FileManagerHomeView({
-
+
{recent.length === 0 ? (
No recent files.
@@ -145,7 +146,8 @@ export function FileManagerHomeView({
-
+
{pinned.length === 0 ? (
No pinned files.
@@ -190,7 +192,8 @@ export function FileManagerHomeView({
Add
-
+
{shortcuts.length === 0 ? (
No shortcuts.
diff --git a/src/ui/apps/File Manager/FileManagerLeftSidebar.tsx b/src/ui/apps/File Manager/FileManagerLeftSidebar.tsx
index 28f5e08b..eb754f4a 100644
--- a/src/ui/apps/File Manager/FileManagerLeftSidebar.tsx
+++ b/src/ui/apps/File Manager/FileManagerLeftSidebar.tsx
@@ -83,7 +83,6 @@ const FileManagerLeftSidebar = forwardRef(function FileManagerSidebar(
}>>({});
const [fetchingFiles, setFetchingFiles] = useState(false);
- // Context menu state
const [contextMenu, setContextMenu] = useState<{
visible: boolean;
x: number;
@@ -96,21 +95,18 @@ const FileManagerLeftSidebar = forwardRef(function FileManagerSidebar(
item: null
});
- // Rename state
const [renamingItem, setRenamingItem] = useState<{
item: any;
newName: string;
} | null>(null);
useEffect(() => {
- // when host changes, set path and connect
const nextPath = host?.defaultPath || '/';
setCurrentPath(nextPath);
onPathChange?.(nextPath);
(async () => {
await connectToSSH(host);
})();
- // eslint-disable-next-line react-hooks/exhaustive-deps
}, [host?.id]);
async function connectToSSH(server: SSHHost): Promise
{
@@ -282,35 +278,28 @@ const FileManagerLeftSidebar = forwardRef(function FileManagerSidebar(
const handleContextMenu = (e: React.MouseEvent, item: any) => {
e.preventDefault();
-
- // Get viewport dimensions
+
const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight;
-
- // Context menu dimensions (approximate)
- const menuWidth = 160; // min-w-[160px]
- const menuHeight = 80; // Approximate height for 2 menu items
-
- // Calculate position
+
+ const menuWidth = 160;
+ const menuHeight = 80;
+
let x = e.clientX;
let y = e.clientY;
-
- // Adjust X position if menu would go off right edge
+
if (x + menuWidth > viewportWidth) {
x = e.clientX - menuWidth;
}
-
- // Adjust Y position if menu would go off bottom edge
+
if (y + menuHeight > viewportHeight) {
y = e.clientY - menuHeight;
}
-
- // Ensure menu doesn't go off left edge
+
if (x < 0) {
x = 0;
}
-
- // Ensure menu doesn't go off top edge
+
if (y < 0) {
y = 0;
}
@@ -369,12 +358,10 @@ const FileManagerLeftSidebar = forwardRef(function FileManagerSidebar(
};
const startDelete = (item: any) => {
- // Call the parent's delete handler instead of managing locally
onDeleteItem?.(item);
closeContextMenu();
};
- // Close context menu when clicking outside
useEffect(() => {
const handleClickOutside = () => closeContextMenu();
document.addEventListener('click', handleClickOutside);
@@ -392,7 +379,7 @@ const FileManagerLeftSidebar = forwardRef(function FileManagerSidebar(
{host && (
-
+
- {/* Context Menu */}
{contextMenu.visible && contextMenu.item && (
- {/* SSH Connections */}
-
-
-
SSH Connections
-
-
-
-
- {sshConnections.map((conn) => (
-
-
-
-
-
-
- ))}
-
-
- {/* File/Folder Viewer */}
(null);
const [newFileName, setNewFileName] = useState('');
const [newFolderName, setNewFolderName] = useState('');
@@ -46,18 +46,18 @@ export function FileManagerOperations({
const [renamePath, setRenamePath] = useState('');
const [renameIsDirectory, setRenameIsDirectory] = useState(false);
const [newName, setNewName] = useState('');
-
+
const [isLoading, setIsLoading] = useState(false);
const fileInputRef = useRef(null);
const handleFileUpload = async () => {
if (!uploadFile || !sshSessionId) return;
-
+
setIsLoading(true);
try {
const content = await uploadFile.text();
- const { uploadSSHFile } = await import('@/ui/main-axios.ts');
-
+ const {uploadSSHFile} = await import('@/ui/main-axios.ts');
+
await uploadSSHFile(sshSessionId, currentPath, uploadFile.name, content);
onSuccess(`File "${uploadFile.name}" uploaded successfully`);
setShowUpload(false);
@@ -72,11 +72,11 @@ export function FileManagerOperations({
const handleCreateFile = async () => {
if (!newFileName.trim() || !sshSessionId) return;
-
+
setIsLoading(true);
try {
- const { createSSHFile } = await import('@/ui/main-axios.ts');
-
+ const {createSSHFile} = await import('@/ui/main-axios.ts');
+
await createSSHFile(sshSessionId, currentPath, newFileName.trim());
onSuccess(`File "${newFileName.trim()}" created successfully`);
setShowCreateFile(false);
@@ -91,11 +91,11 @@ export function FileManagerOperations({
const handleCreateFolder = async () => {
if (!newFolderName.trim() || !sshSessionId) return;
-
+
setIsLoading(true);
try {
- const { createSSHFolder } = await import('@/ui/main-axios.ts');
-
+ const {createSSHFolder} = await import('@/ui/main-axios.ts');
+
await createSSHFolder(sshSessionId, currentPath, newFolderName.trim());
onSuccess(`Folder "${newFolderName.trim()}" created successfully`);
setShowCreateFolder(false);
@@ -110,11 +110,11 @@ export function FileManagerOperations({
const handleDelete = async () => {
if (!deletePath || !sshSessionId) return;
-
+
setIsLoading(true);
try {
- const { deleteSSHItem } = await import('@/ui/main-axios.ts');
-
+ const {deleteSSHItem} = await import('@/ui/main-axios.ts');
+
await deleteSSHItem(sshSessionId, deletePath, deleteIsDirectory);
onSuccess(`${deleteIsDirectory ? 'Folder' : 'File'} deleted successfully`);
setShowDelete(false);
@@ -130,11 +130,11 @@ export function FileManagerOperations({
const handleRename = async () => {
if (!renamePath || !newName.trim() || !sshSessionId) return;
-
+
setIsLoading(true);
try {
- const { renameSSHItem } = await import('@/ui/main-axios.ts');
-
+ const {renameSSHItem} = await import('@/ui/main-axios.ts');
+
await renameSSHItem(sshSessionId, renamePath, newName.trim());
onSuccess(`${renameIsDirectory ? 'Folder' : 'File'} renamed successfully`);
setShowRename(false);
@@ -179,7 +179,7 @@ export function FileManagerOperations({
if (!sshSessionId) {
return (
-
+
Connect to SSH to use file operations
);
@@ -187,7 +187,6 @@ export function FileManagerOperations({
return (
- {/* Operation Buttons */}
- {/* Current Path Display */}
-
+
Current Path:
{currentPath}
-
+
- {/* Upload File Modal */}
{showUpload && (
-
+
Upload File
@@ -266,15 +263,15 @@ export function FileManagerOperations({
onClick={() => setShowUpload(false)}
className="h-8 w-8 p-0"
>
-
+
-
+
{uploadFile ? (
-
+
{uploadFile.name}
{(uploadFile.size / 1024).toFixed(2)} KB
@@ -290,7 +287,7 @@ export function FileManagerOperations({
) : (
-
+
Click to select a file
-
+
-
+