Browse Source

Add files lock capability check

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 2 years ago
parent
commit
56abd8cfdd

+ 1 - 0
iOSClient/Data/NCElementsJSON.swift

@@ -58,6 +58,7 @@ import UIKit
     @objc public let capabilitiesNotification: Array = ["ocs", "data", "capabilities", "notifications", "ocs-endpoints"]
 
     @objc public let capabilitiesFilesUndelete: Array = ["ocs", "data", "capabilities", "files", "undelete"]
+    @objc public let capabilitiesFilesLockVersion: Array = ["ocs", "data", "capabilities", "files", "locking"]
     @objc public let capabilitiesFilesComments: Array = ["ocs", "data", "capabilities", "files", "comments"]                                            // NC 20
 
     @objc public let capabilitiesHWCEnabled: Array = ["ocs", "data", "capabilities", "handwerkcloud", "enabled"]

+ 1 - 1
iOSClient/Main/Collection Common/NCSelectableNavigationView.swift

@@ -124,7 +124,7 @@ extension NCSelectableNavigationView where Self: UIViewController {
 
         actions.append(.openInAction(selectedMetadatas: selectedMetadatas, viewController: self, completion: tapSelect))
 
-        if !isAnyFolder, canUnlock {
+        if !isAnyFolder, canUnlock, NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFilesLockVersion) >= 1 {
             actions.append(.lockUnlockFiles(shouldLock: !isAnyLocked, metadatas: selectedMetadatas, completion: tapSelect))
         }
 

+ 4 - 2
iOSClient/Main/NCFunctionCenter.swift

@@ -748,9 +748,11 @@ import SVGKit
         var children: [UIMenuElement] = [favorite, offline, openIn, moveCopy, copy, copyPath]
         
         if metadata.canUnlock(as: appDelegate.userId) {
-            children.insert(rename, at: 3)
-            children.insert(lockUnlock, at: 2)
             children.append(delete)
+            children.insert(rename, at: 3)
+            if NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFilesLockVersion) >= 1 {
+                children.insert(lockUnlock, at: 2)
+            }
         } else if enableDeleteLocal {
             children.append(deleteConfirmLocal)
         }

+ 1 - 1
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -106,7 +106,7 @@ extension NCCollectionViewCommon {
             )
         )
 
-        if !metadata.directory, canUnlock {
+        if !metadata.directory, canUnlock, NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFilesLockVersion) >= 1 {
             actions.append(.lockUnlockFiles(shouldLock: !metadata.lock, metadatas: [metadata]))
         }