diff options
author | Henrik Storch <henrik.storch@nextcloud.com> | 2022-04-20 11:05:58 +0300 |
---|---|---|
committer | Henrik Storch <henrik.storch@nextcloud.com> | 2022-05-10 11:57:22 +0300 |
commit | ad6a7267b937780ea6470b74795faef2ed83669c (patch) | |
tree | 6da698ca0ffc4bd758941dcba7f65d5971a2788d | |
parent | c70bd526b70029e790f5076c5203c4a3efe0cf4f (diff) |
Remove Move option for locked files + fix locked file deletion
- only allow server deletion if all files can be deleted by the user
Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
-rw-r--r-- | iOSClient/Main/NCFunctionCenter.swift | 6 | ||||
-rw-r--r-- | iOSClient/Menu/NCMenuAction.swift | 3 | ||||
-rw-r--r-- | iOSClient/Select/NCSelect.swift | 8 |
3 files changed, 10 insertions, 7 deletions
diff --git a/iOSClient/Main/NCFunctionCenter.swift b/iOSClient/Main/NCFunctionCenter.swift index 2728d6c99..424ada1fd 100644 --- a/iOSClient/Main/NCFunctionCenter.swift +++ b/iOSClient/Main/NCFunctionCenter.swift @@ -535,19 +535,19 @@ import SVGKit } } - func openSelectView(items: [Any]) { + func openSelectView(items: [tableMetadata]) { let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController let topViewController = navigationController.topViewController as! NCSelect var listViewController = [NCSelect]() - var copyItems: [Any] = [] + var copyItems: [tableMetadata] = [] for item in items { copyItems.append(item) } let homeUrl = NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account) - var serverUrl = (copyItems[0] as! Nextcloud.tableMetadata).serverUrl + var serverUrl = copyItems[0].serverUrl // Setup view controllers such that the current view is of the same directory the items to be copied are in while true { diff --git a/iOSClient/Menu/NCMenuAction.swift b/iOSClient/Menu/NCMenuAction.swift index ad166e6a6..b52b92196 100644 --- a/iOSClient/Menu/NCMenuAction.swift +++ b/iOSClient/Menu/NCMenuAction.swift @@ -96,8 +96,7 @@ extension NCMenuAction { } } // else: no metadata selected - let canDeleteServer = selectedMetadatas.contains( - where: { $0.canUnlock(as: (UIApplication.shared.delegate as? AppDelegate)?.userId ?? "") }) + let canDeleteServer = selectedMetadatas.allSatisfy { $0.canUnlock(as: (UIApplication.shared.delegate as? AppDelegate)?.userId ?? "") } var fileList = "" for (ix, metadata) in selectedMetadatas.enumerated() { guard ix < 3 else { fileList += "\n - ..."; break } diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index fdeed063e..75fdbffc5 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -49,7 +49,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent @objc var includeImages = false @objc var enableSelectFile = false @objc var type = "" - @objc var items: [Any] = [] + @objc var items: [tableMetadata] = [] var titleCurrentFolder = NCBrandOptions.shared.brand var serverUrl = "" @@ -141,7 +141,11 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent self.view.addSubview(selectCommandViewSelect!) selectCommandViewSelect?.selectView = self selectCommandViewSelect?.translatesAutoresizingMaskIntoConstraints = false - + let userId = NCManageDatabase.shared.getActiveAccount()?.userId ?? "" + if items.contains(where: { !$0.canUnlock(as: userId) }) { + selectCommandViewSelect?.moveButton?.isEnabled = false + selectCommandViewSelect?.moveButton?.titleLabel?.isEnabled = false + } selectCommandViewSelect?.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true selectCommandViewSelect?.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true selectCommandViewSelect?.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true |