From fa8925ab690523c2fdedb7d03dc70753f3cbbd88 Mon Sep 17 00:00:00 2001 From: "LAPTOP-O016UC3M\\Qi Chen" <16399091+binaricat@users.noreply.github.com> Date: Fri, 19 Dec 2025 12:00:03 +0800 Subject: [PATCH] Improves SFTP modal UI polish and initial loading Loads initial directory contents on mount for better UX. Enhances file list area scrolling and stickiness of table header. Unifies sort icons and cleans up redundant JSX for readability. Refines context menu layout and action consistency. --- components/SFTPModal.tsx | 45 ++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/components/SFTPModal.tsx b/components/SFTPModal.tsx index e090792c6..fdd1a3f0f 100644 --- a/components/SFTPModal.tsx +++ b/components/SFTPModal.tsx @@ -546,9 +546,12 @@ const SFTPModal: React.FC = ({ home ?? (navigator.platform.toLowerCase().includes("win") ? "C:\\" : "/"); setCurrentPath(startPath); + loadFiles(startPath); })(); } else { - setCurrentPath("/"); + const startPath = "/"; + setCurrentPath(startPath); + loadFiles(startPath); } return; } @@ -1202,7 +1205,7 @@ const SFTPModal: React.FC = ({ {/* File List */}
= ({
{t("sftp.emptyDirectory")}
-
- {t("sftp.dragDropToUpload")} -
+
{t("sftp.dragDropToUpload")}
)} {/* Table Header with sortable columns and resize handles */} {files.length > 0 && (
= ({ {t("sftp.columns.name")} {sortField === "name" && ( - {sortOrder === "asc" ? "↑" : "↓"} + {sortOrder === "asc" ? "^" : "v"} )}
= ({ {t("sftp.columns.size")} {sortField === "size" && ( - {sortOrder === "asc" ? "↑" : "↓"} + {sortOrder === "asc" ? "^" : "v"} )}
= ({ {t("sftp.columns.modified")} {sortField === "modified" && ( - {sortOrder === "asc" ? "↑" : "↓"} + {sortOrder === "asc" ? "^" : "v"} )}
= ({
{getFileIcon(file.name, file.type === "directory")}
- - {file.name} - + {file.name}
- {file.type === "directory" - ? "--" - : formatBytes(file.size)} + {file.type === "directory" ? "--" : formatBytes(file.size)}
{formatDate(file.lastModified, resolvedLocale)} @@ -1347,7 +1344,7 @@ const SFTPModal: React.FC = ({ variant="ghost" size="icon" className="h-7 w-7 hover:text-destructive" - onClick={(e) => { + onClick={(e) => { e.stopPropagation(); handleDelete(file); }} @@ -1374,16 +1371,14 @@ const SFTPModal: React.FC = ({ )} {file.type === "file" && ( handleDownload(file)}> - {" "} - {t("sftp.context.download")} + {t("sftp.context.download")} )} handleDelete(file)} > - {" "} - {t("sftp.context.delete")} + {t("sftp.context.delete")} @@ -1397,23 +1392,19 @@ const SFTPModal: React.FC = ({ inputRef.current?.click()}> {t("sftp.uploadFiles")} - loadFiles(currentPath, { force: true })} - > + loadFiles(currentPath, { force: true })}> {t("sftp.context.refresh")} {selectedFiles.size > 0 && ( <> - {" "} - {t("sftp.context.downloadSelected", { count: selectedFiles.size })} + {t("sftp.context.downloadSelected", { count: selectedFiles.size })} - {" "} - {t("sftp.context.deleteSelected", { count: selectedFiles.size })} + {t("sftp.context.deleteSelected", { count: selectedFiles.size })} )}