Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

New electron dialog changes #11906

Merged
merged 2 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
runtime = electron
target_arch = x64
brave_electron_version = 4.7.9
brave_electron_version = 5.0.0
chromedriver_version = 2.33
target = v4.7.9
target = v5.0.0
disturl=https://brave-laptop-binaries.s3.amazonaws.com/atom-shell/dist/
build_from_source = true
18 changes: 8 additions & 10 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,22 @@ const onBootStateFile = (state) => {

const promptForRecoveryKeyFile = () => {
const defaultRecoveryKeyFilePath = path.join(electron.app.getPath('userData'), '/brave_wallet_recovery.txt')
let files
if (process.env.SPECTRON) {
// skip the dialog for tests
console.log(`for test, trying to recover keys from path: ${defaultRecoveryKeyFilePath}`)
files = [defaultRecoveryKeyFilePath]
return defaultRecoveryKeyFilePath
} else {
const dialog = electron.dialog
files = dialog.showOpenDialog({
properties: ['openFile'],
const BrowserWindow = electron.BrowserWindow
dialog.showDialog(BrowserWindow.getFocusedWindow(), {
type: 'select-open-file',
defaultPath: defaultRecoveryKeyFilePath,
filters: [{
name: 'TXT files',
extensions: ['txt']
}]
extensions: [['txt']],
includeAllFiles: false
}, (files) => {
return (files && files.length ? files[0] : null)
})
}

return (files && files.length ? files[0] : null)
}

const logError = (state, err, caller) => {
Expand Down
12 changes: 5 additions & 7 deletions app/browser/bookmarksExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ const showDialog = (state) => {
let personal = []
let other = []

dialog.showSaveDialog(focusedWindow, {
dialog.showDialog(focusedWindow, {
defaultPath: defaultPath,
filters: [{
name: 'HTML',
extensions: ['html']
}]
}, (fileName) => {
if (fileName) {
type: 'select-saveas-file',
extensions: [['html']]
}, (fileNames) => {
if (fileNames && fileNames.length === 1) {
personal = createBookmarkArray(state)
other = createBookmarkArray(state, -1, false)
try {
Expand Down
4 changes: 2 additions & 2 deletions app/browser/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const createFileSubmenu = () => {
label: locale.translation('openFile'),
accelerator: 'CmdOrCtrl+O',
click: (item, focusedWindow) => {
dialog.showOpenDialog(focusedWindow, {
properties: ['openFile', 'multiSelections']
dialog.showDialog(focusedWindow, {
type: 'select-open-multi-file'
}, (paths) => {
if (paths) {
paths.forEach((path) => {
Expand Down
10 changes: 5 additions & 5 deletions app/browser/reducers/downloadsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ const downloadsReducer = (state, action) => {
case appConstants.APP_SELECT_DEFAULT_DOWNLOAD_PATH:
const focusedWindow = BrowserWindow.getFocusedWindow()

dialog.showOpenDialog(focusedWindow, {
dialog.showDialog(focusedWindow, {
defaultPath: app.getPath('downloads'),
properties: ['openDirectory', 'createDirectory']
}, (folder) => {
if (Array.isArray(folder) && fs.lstatSync(folder[0]).isDirectory()) {
appActions.changeSetting(settings.DOWNLOAD_DEFAULT_PATH, folder[0])
type: 'select-folder'
}, (paths) => {
if (Array.isArray(paths) && fs.lstatSync(paths[0]).isDirectory()) {
appActions.changeSetting(settings.DOWNLOAD_DEFAULT_PATH, paths[0])
}
})
break
Expand Down
18 changes: 8 additions & 10 deletions app/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,15 @@ exports.importHTML = (selected) => {
isImportingBookmarks = true
const state = appStore.getState()
hasBookmarks = bookmarksState.getBookmarks(state).size > 0 || bookmarkFoldersState.getFolders(state).size > 0
const files = dialog.showOpenDialog({
properties: ['openFile'],
filters: [{
name: 'HTML',
extensions: ['html', 'htm']
}]
dialog.showDialog(BrowserWindow.getFocusedWindow(), {
type: 'select-open-file',
extensions: [['html', 'htm']]
}, (files) => {
if (files && files.length === 1) {
const file = files[0]
importer.importHTML(file)
}
})
if (files && files.length > 0) {
const file = files[0]
importer.importHTML(file)
}
}

importer.on('update-supported-browsers', (e, detail) => {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/app/browser/reducers/downloadsReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('downloadsReducer', function () {
let options

before(function () {
stub = sinon.stub(fakeElectron.dialog, 'showOpenDialog', function (arg1, arg2) {
stub = sinon.stub(fakeElectron.dialog, 'showDialog', function (arg1, arg2) {
options = arg2
})
downloadsReducer({}, {actionType: appConstants.APP_SELECT_DEFAULT_DOWNLOAD_PATH})
Expand All @@ -264,7 +264,7 @@ describe('downloadsReducer', function () {
stub.restore()
})

it('calls dialog.showOpenDialog', function () {
it('calls dialog.showDialog', function () {
assert(stub.calledOnce)
})

Expand All @@ -273,7 +273,7 @@ describe('downloadsReducer', function () {
})

it('passes the correct properties object', function () {
assert.deepEqual(options.properties, ['openDirectory', 'createDirectory'])
assert.deepEqual(options.type, 'select-folder')
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/fakeElectron.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const fakeElectron = {
}
},
dialog: {
showOpenDialog: function () { }
showDialog: function () { }
},
Menu: {
setApplicationMenu: (template) => {},
Expand Down
2 changes: 1 addition & 1 deletion tools/cibuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess
import sys
import os.path
MUON_VERSION = '4.7.9'
MUON_VERSION = '5.0.0'
CHROMEDRIVER_VERSION = '2.33'
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
TARGET_ARCH= os.environ['TARGET_ARCH'] if os.environ.has_key('TARGET_ARCH') else 'x64'
Expand Down