Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: promisify dialog.showOpenDialog() #16973

Merged
merged 3 commits into from Mar 5, 2019

Conversation

@codebytere
Copy link
Member

commented Feb 14, 2019

Description of Change

Promisifies dialog.showOpenDialog().

cc @ckerr @MarshallOfSound @deepak1556

Checklist

Release Notes

Notes: Split dialog.showOpenDialog() into a synchronous version and a version that returns a Promise

@codebytere codebytere added the wip label Feb 14, 2019

@codebytere codebytere requested a review from as a code owner Feb 14, 2019

@codebytere codebytere requested a review from as a code owner Feb 14, 2019

@codebytere codebytere changed the title [wip] feat: promisify dialog.showOpenDialog() feat: promisify dialog.showOpenDialog() Feb 14, 2019

@codebytere codebytere removed the wip label Feb 14, 2019

@codebytere codebytere force-pushed the promisify-showopendialog branch from 4bcec77 to bb9cbc7 Feb 14, 2019

@codebytere codebytere changed the title feat: promisify dialog.showOpenDialog() [wip] feat: promisify dialog.showOpenDialog() Feb 15, 2019

@codebytere codebytere force-pushed the promisify-showopendialog branch 2 times, most recently from f0169e8 to 0cca779 Feb 15, 2019

@codebytere codebytere changed the title [wip] feat: promisify dialog.showOpenDialog() feat: promisify dialog.showOpenDialog() Feb 15, 2019

@codebytere codebytere changed the title feat: promisify dialog.showOpenDialog() [wip] feat: promisify dialog.showOpenDialog() Feb 16, 2019

@codebytere codebytere force-pushed the promisify-showopendialog branch from 4fd58e0 to c056a03 Feb 16, 2019

@codebytere codebytere changed the title [wip] feat: promisify dialog.showOpenDialog() feat: promisify dialog.showOpenDialog() Feb 16, 2019

@codebytere codebytere force-pushed the promisify-showopendialog branch from c056a03 to 10cc766 Feb 19, 2019

@codebytere

This comment has been minimized.

Copy link
Member Author

commented Feb 19, 2019

Needs rebase on #17050 once it's merged.

@codebytere codebytere force-pushed the promisify-showopendialog branch 2 times, most recently from d3f91d1 to 2bca51f Feb 20, 2019

Show resolved Hide resolved atom/browser/ui/file_dialog_gtk.cc Outdated
Show resolved Hide resolved atom/browser/ui/file_dialog_win.cc Outdated

@zcbenz zcbenz referenced this pull request Feb 25, 2019

Merged

feat: promisify dialog.showSaveDialog() #17054

5 of 6 tasks complete

@codebytere codebytere force-pushed the promisify-showopendialog branch from f517b0e to 271d772 Feb 26, 2019

@codebytere codebytere force-pushed the promisify-showopendialog branch 3 times, most recently from ac6dc6e to 6f4ba16 Feb 27, 2019

@codebytere codebytere force-pushed the promisify-showopendialog branch from 6f4ba16 to 9d9098a Mar 1, 2019

@miniak
Copy link
Contributor

left a comment

can you please include this change as well a757e25?
it refactors the ELECTRON_INSPECTOR_SELECT_FILE IPC handler to use the promisified version of dialog.showOpenDialog()

Show resolved Hide resolved atom/browser/ui/file_dialog_gtk.cc Outdated
Show resolved Hide resolved atom/browser/ui/file_dialog_gtk.cc Outdated
@codebytere

This comment has been minimized.

Copy link
Member Author

commented Mar 4, 2019

@miniak i'd rather that be a separate PR once this gets merged so they can be reviewed separately and not create scope creep

@codebytere codebytere force-pushed the promisify-showopendialog branch from 0efad7d to 674cb11 Mar 4, 2019

@miniak

This comment has been minimized.

Copy link
Contributor

commented Mar 4, 2019

@miniak

miniak approved these changes Mar 4, 2019

Show resolved Hide resolved lib/browser/api/dialog.js Outdated
Show resolved Hide resolved lib/browser/api/dialog.js
Show resolved Hide resolved docs/api/dialog.md Outdated
@miniak
Copy link
Contributor

left a comment

this fix needs to be included to avoid breaking devtools

diff --git a/lib/browser/chrome-devtools.js b/lib/browser/chrome-devtools.js
index f2db33344..b3aa84f0f 100644
--- a/lib/browser/chrome-devtools.js
+++ b/lib/browser/chrome-devtools.js
@@ -86,9 +86,9 @@ ipcMainUtils.handle('ELECTRON_INSPECTOR_SELECT_FILE', function (event) {
   return new Promise((resolve, reject) => {
     assertChromeDevTools(event.sender, 'window.UI.createFileSelectorElement()')
 
-    dialog.showOpenDialog({}, function (files) {
-      if (files) {
-        const path = files[0]
+    dialog.showOpenDialog({}, function (result) {
+      if (!result.canceled) {
+        const path = result.filePaths[0]
         fs.readFile(path, (error, data) => {
           if (error) {
             reject(error)
@zcbenz

zcbenz approved these changes Mar 5, 2019

@miniak

miniak approved these changes Mar 5, 2019

@codebytere codebytere merged commit e059851 into master Mar 5, 2019

14 of 15 checks passed

Artifact Comparison Changes Detected
Details
Semantic Pull Request ready to be squashed
Details
WIP Ready for review
Details
appveyor: win-ia32-debug AppVeyor build succeeded
Details
appveyor: win-ia32-testing AppVeyor build succeeded
Details
appveyor: win-ia32-testing-pr AppVeyor build succeeded
Details
appveyor: win-x64-debug AppVeyor build succeeded
Details
appveyor: win-x64-testing AppVeyor build succeeded
Details
appveyor: win-x64-testing-pr AppVeyor build succeeded
Details
build-linux Workflow: build-linux
Details
build-mac Workflow: build-mac
Details
electron-arm-testing Build #20190305.7 succeeded
Details
electron-arm64-testing Build #20190305.7 succeeded
Details
lint Workflow: lint
Details
release-notes Release notes found
@release-clerk

This comment has been minimized.

Copy link

commented Mar 5, 2019

Release Notes Persisted

Split dialog.showOpenDialog() into a synchronous version and a version that returns a Promise

@codebytere codebytere deleted the promisify-showopendialog branch Mar 5, 2019

@miniak miniak referenced this pull request Mar 5, 2019

Merged

refactor: make ELECTRON_INSPECTOR_SELECT_FILE handler async #17235

3 of 3 tasks complete

Kiku-Reise added a commit to Kiku-Reise/electron that referenced this pull request May 16, 2019

feat: promisify dialog.showOpenDialog() (electron#16973)
* feat: promisify dialog.showOpenDialog()

* address feedback from review

* address feedback from review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.