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

ELECTRON-978 (Implement native file picker modal window) #540

Closed
wants to merge 2 commits into from

Conversation

KiranNiranjan
Copy link
Member

@KiranNiranjan KiranNiranjan commented Dec 26, 2018

Description

Exposes an API to the web app to open a native file picker modal ELECTRON-978

Solution Approach

Expose an API which invokes dialog.showOpenDialog inturn

Screenshot

screenshot 2018-12-26 at 5 24 56 pm

Related PRs

List related PRs against other branches / repositories:

branch PR
SFE-Client-App #13157
SFE-Packages #2239

QA Checklist

  • Unit-Tests
  • Automation-Tests

Copy link
Contributor

@keerthi16 keerthi16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link

@vrbsm vrbsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

js/preload/preloadMain.js Show resolved Hide resolved
const browserWindow = remote.getCurrentWindow();
const { type, title, defaultPath, multiSelect, filters } = options;
const properties = [ type ];
if (multiSelect) properties.push('multiSelections');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use braces around the if statement for consistency.

js/preload/preloadMain.js Show resolved Hide resolved
const properties = [ type ];
if (multiSelect) properties.push('multiSelections');
remote.dialog.showOpenDialog(browserWindow, { title, defaultPath, properties, filters }, (filePaths) => {
if (!filePaths) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use braces around the if statement for consistency.

const files = filePaths.map((file) => {
const mimeType = mime.lookup(file);
const filename = file.substring(file.lastIndexOf('/') + 1);
return new File([ fs.readFileSync(file) ], filename, { type: mimeType });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file(s) is big & the system is slow, the UI thread will be blocked. Please use async version.

@VishwasShashidhar
Copy link
Contributor

We don't need this work around anymore as the issue has been fixed on Electron framework electron/electron#16340

@lock
Copy link

lock bot commented Jul 10, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 10, 2019
@KiranNiranjan KiranNiranjan deleted the ELECTRON-978 branch January 10, 2024 07:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants