From 5df0028c5a4c17134e8f0d4373bd6c3a96ecb72d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 21:35:40 +0800 Subject: [PATCH] Correctly handle NKShare's "canEdit" in share options view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 5aebe0fb7..3a46cb3fa 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -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() { -- 2.30.2