Correctly handle NKShare's "canEdit" in share options view
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 4 Mar 2024 13:35:40 +0000 (21:35 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 17 Apr 2024 08:38:54 +0000 (16:38 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift

index 5aebe0fb7587ef4916323f7983eba20f3687eb7e..3a46cb3fa3300c3d3297507b8309ff9b18c8ace0 100644 (file)
@@ -34,21 +34,30 @@ class ShareOptionsView: NSView {
     private func update() {
         guard let share = controller?.share else {
             reset()
+            setAllFields(enabled: false)
             saveButton.isEnabled = false
             deleteButton.isEnabled = false
             return
         }
-        labelTextField.stringValue = share.label
-        uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off
-        hideDownloadCheckbox.state = share.hideDownload ? .on : .off
-        passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on
-        passwordSecureField.isHidden = passwordProtectCheckbox.state == .off
-        expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on
-        expirationDatePicker.isHidden = expirationDateCheckbox.state == .off
-        noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on
-        noteTextField.isHidden = noteForRecipientCheckbox.state == .off
+
         deleteButton.isEnabled = share.canDelete
-        saveButton.isEnabled = true
+        saveButton.isEnabled = share.canEdit
+
+        if share.canEdit {
+            setAllFields(enabled: true)
+            labelTextField.stringValue = share.label
+            uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off
+            hideDownloadCheckbox.state = share.hideDownload ? .on : .off
+            passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on
+            passwordSecureField.isHidden = passwordProtectCheckbox.state == .off
+            expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on
+            expirationDatePicker.isHidden = expirationDateCheckbox.state == .off
+            noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on
+            noteTextField.isHidden = noteForRecipientCheckbox.state == .off
+        } else {
+            setAllFields(enabled: false)
+            reset()
+        }
     }
 
     func reset() {