refactor: pass MessageBox params as a struct (#18732)

Historically, we've been passing in all MessageBox parameters individually, which makes augmenting or improving MessageBox functionality challenging because to change or add even one argument requires a huge cascade of argument changes that leaves room for errors.

For other file dialog related APIs, we use a struct (DialogSettings), and so this PR takes a similar approach and refactors MessageBox parameters into a struct (MessageBoxSettings) which we then use to simplify argument passing and which will enable us to more quickly iterate and improve upon functionality in the future.
This commit is contained in:
Shelley Vohr 2019-06-14 08:26:25 -07:00 committed by GitHub
parent ffb53405fb
commit bfcce8aa27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 207 additions and 247 deletions

View file

@ -172,14 +172,25 @@ const messageBox = (sync, window, options) => {
const flags = options.noLink ? messageBoxOptions.noLink : 0
const settings = {
window,
messageBoxType,
buttons,
defaultId,
cancelId,
flags,
title,
message,
detail,
checkboxLabel,
checkboxChecked,
icon
}
if (sync) {
return binding.showMessageBoxSync(messageBoxType, buttons,
defaultId, cancelId, flags, title, message, detail,
checkboxLabel, checkboxChecked, icon, window)
return binding.showMessageBoxSync(settings)
} else {
return binding.showMessageBox(messageBoxType, buttons,
defaultId, cancelId, flags, title, message, detail,
checkboxLabel, checkboxChecked, icon, window)
return binding.showMessageBox(settings)
}
}