From d5a9bec3dab89dbb51010052413211484e4fd0f3 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Mon, 6 Nov 2023 19:10:35 +0100 Subject: [PATCH] WebClient: allow bulk move or copy actions Signed-off-by: Nicola Murino --- internal/common/connection.go | 10 +- internal/httpd/api_http_user.go | 4 +- templates/webclient/files.html | 277 +++++++++++++++++++++++--------- 3 files changed, 211 insertions(+), 80 deletions(-) diff --git a/internal/common/connection.go b/internal/common/connection.go index 76061738..e1dedad0 100644 --- a/internal/common/connection.go +++ b/internal/common/connection.go @@ -1133,22 +1133,24 @@ func (c *BaseConnection) checkFolderRename(fsSrc, fsDst vfs.Fs, fsSourcePath, fs if util.IsDirOverlapped(virtualSourcePath, virtualTargetPath, true, "/") { c.Log(logger.LevelDebug, "renaming the folder %q->%q is not supported: nested folders", virtualSourcePath, virtualTargetPath) - return c.GetOpUnsupportedError() + return fmt.Errorf("nested rename %q => %q is not supported: %w", + virtualSourcePath, virtualTargetPath, c.GetOpUnsupportedError()) } if util.IsDirOverlapped(fsSourcePath, fsTargetPath, true, c.User.FsConfig.GetPathSeparator()) { c.Log(logger.LevelDebug, "renaming the folder %q->%q is not supported: nested fs folders", fsSourcePath, fsTargetPath) - return c.GetOpUnsupportedError() + return fmt.Errorf("nested fs rename %q => %q is not supported: %w", + fsSourcePath, fsTargetPath, c.GetOpUnsupportedError()) } if c.User.HasVirtualFoldersInside(virtualSourcePath) { c.Log(logger.LevelDebug, "renaming the folder %q is not supported: it has virtual folders inside it", virtualSourcePath) - return c.GetOpUnsupportedError() + return fmt.Errorf("folder %q has virtual folders inside it: %w", virtualSourcePath, c.GetOpUnsupportedError()) } if c.User.HasVirtualFoldersInside(virtualTargetPath) { c.Log(logger.LevelDebug, "renaming the folder %q is not supported, the target %q has virtual folders inside it", virtualSourcePath, virtualTargetPath) - return c.GetOpUnsupportedError() + return fmt.Errorf("folder %q has virtual folders inside it: %w", virtualTargetPath, c.GetOpUnsupportedError()) } if err := c.checkRecursiveRenameDirPermissions(fsSrc, fsDst, fsSourcePath, fsTargetPath, virtualSourcePath, virtualTargetPath, fi); err != nil { diff --git a/internal/httpd/api_http_user.go b/internal/httpd/api_http_user.go index 53db4352..9bb8c7d8 100644 --- a/internal/httpd/api_http_user.go +++ b/internal/httpd/api_http_user.go @@ -147,7 +147,7 @@ func renameUserFsEntry(w http.ResponseWriter, r *http.Request) { } } else { if err := connection.Rename(oldName, newName); err != nil { - sendAPIResponse(w, r, err, fmt.Sprintf("Unable to rename %q -> %q", oldName, newName), + sendAPIResponse(w, r, err, fmt.Sprintf("Unable to rename %q => %q", oldName, newName), getMappedStatusCode(err)) return } @@ -178,7 +178,7 @@ func copyUserFsEntry(w http.ResponseWriter, r *http.Request) { } err = connection.Copy(source, target) if err != nil { - sendAPIResponse(w, r, err, fmt.Sprintf("Unable to copy %q -> %q", source, target), + sendAPIResponse(w, r, err, fmt.Sprintf("Unable to copy %q => %q", source, target), getMappedStatusCode(err)) return } diff --git a/templates/webclient/files.html b/templates/webclient/files.html index abe9ef07..ca0f003b 100644 --- a/templates/webclient/files.html +++ b/templates/webclient/files.html @@ -74,6 +74,14 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). {{- end}} + {{- if not .ShareUploadBaseURL}} + {{- if or .CanRename .CanAddFiles}} + + {{- end}} {{- if .CanShare}} {{- end}} + {{- end}} {{- if .CanDelete}}