Support message, nameFieldLabel and showsTagField for macOS dialog#8556
Support message, nameFieldLabel and showsTagField for macOS dialog#8556kevinsawicki merged 13 commits intoelectron:masterfrom
Conversation
84e21a0 to
8fa5c1d
Compare
kevinsawicki
left a comment
There was a problem hiding this comment.
Looks pretty good, left a few minor comments, thanks for implementing this.
lib/browser/api/dialog.js
Outdated
| } | ||
|
|
||
| if (showsTagField == null) { | ||
| showsTagField = false |
There was a problem hiding this comment.
Looks like the default OS value of this is true if unset so I think this should default to true to not break backwards-compatibility.
https://developer.apple.com/reference/appkit/nssavepanel/1525589-showstagfield?language=objc
atom/browser/ui/file_dialog_mac.mm
Outdated
| SetupDialog(dialog, title, button_label, default_path, filters); | ||
| SetupDialog(dialog, title, button_label, default_path, filters, message, | ||
| // NSOpenPanel does not support name_field_label and shows_tag_field | ||
| "", false); |
There was a problem hiding this comment.
The alignment here appear off, can you align this with the dialog argument on line 165?
atom/browser/ui/file_dialog_mac.mm
Outdated
| SetupDialog(dialog, title, button_label, default_path, filters); | ||
| SetupDialog(dialog, title, button_label, default_path, filters, message, | ||
| // NSOpenPanel does not support name_field_label and shows_tag_field | ||
| "", false); |
There was a problem hiding this comment.
Looks like the alignment here is off, can you align this with the dialog argument on line 142?
atom/browser/api/atom_api_dialog.cc
Outdated
| const file_dialog::Filters& filters, | ||
| const std::string& message, | ||
| const std::string& name_field_label, | ||
| const bool& shows_tag_field, |
There was a problem hiding this comment.
For primitives like bool and int, we don't use references or const, so this should just be bool show_tags_field.
lib/browser/api/dialog.js
Outdated
|
|
||
| let {buttonLabel, defaultPath, filters, properties, title} = options | ||
| let {buttonLabel, defaultPath, filters, properties, title, | ||
| message} = options |
There was a problem hiding this comment.
This is fine to keep on a single line, we don't enforce hard line length limits in JS.
| if (message == null) { | ||
| message = '' | ||
| } else if (typeof message !== 'string') { | ||
| throw new TypeError('Message must be a string') |
There was a problem hiding this comment.
Can you add an assertion for this error in spec/api-dialog-spec.js?
| if (nameFieldLabel == null) { | ||
| nameFieldLabel = '' | ||
| } else if (typeof nameFieldLabel !== 'string') { | ||
| throw new TypeError('Name field label must be a string') |
There was a problem hiding this comment.
Can you add an assertion for this error in spec/api-dialog-spec.js?
|
Thanks for your review! I will make the changes asap. |
Support additional attributes available in macOS's NSSavePanel: message, nameFieldLabel and showsTagField
Support an additional attributes available in macOS's NSOpenPanel: message.
The default value of showsTagField in macOS's NSSavePanel is true. Therefore, in order to follow the standard behavior and not break backwards-compatibility, let's change the default value of showsTagField to true. Reference: https://developer.apple.com/reference/appkit/nssavepanel/1525589-showstagfield?language=objc
The normal convention in the codebase is to not use references or 'const' for primitives like 'bool' and 'int'.
49f6b70 to
347dc83
Compare
|
@kevinsawicki I rebased on top of the latest master and incorporated all of your suggested changes. |
|
Thanks for this @yamgent, I merged #8623 into this branch which added a Great job on this 👍 🚀 |
Fixes #7783.
showSaveDialog() now supports additional attributes for setting the
message,nameFieldLabelandshowsTagField.showOpenDialog() also supports
message(nameFieldLabelandshowsTagFielddoesn't seem to change the dialog box though).