diff --git a/app/browser/api/ledger.js b/app/browser/api/ledger.js index b770e693948..4015bdce4eb 100644 --- a/app/browser/api/ledger.js +++ b/app/browser/api/ledger.js @@ -189,13 +189,11 @@ const promptForRecoveryKeyFile = () => { files = [defaultRecoveryKeyFilePath] } else { const dialog = electron.dialog - files = dialog.showOpenDialog({ - properties: ['openFile'], + files = dialog.showDialog({ + type: 'select-open-file', defaultPath: defaultRecoveryKeyFilePath, - filters: [{ - name: 'TXT files', - extensions: ['txt'] - }] + extensions: [['txt']], + includeAllFiles: false }) } diff --git a/app/browser/bookmarksExporter.js b/app/browser/bookmarksExporter.js index 15c83038106..bf16ccb3215 100644 --- a/app/browser/bookmarksExporter.js +++ b/app/browser/bookmarksExporter.js @@ -34,17 +34,15 @@ 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) - fs.writeFileSync(fileName, createBookmarkHTML(personal, other)) + fs.writeFileSync(fileNames[0], createBookmarkHTML(personal, other)) } }) } diff --git a/app/browser/menu.js b/app/browser/menu.js index 2590beae37b..a8dd9adc945 100644 --- a/app/browser/menu.js +++ b/app/browser/menu.js @@ -57,8 +57,9 @@ const createFileSubmenu = () => { label: locale.translation('openFile'), accelerator: 'CmdOrCtrl+O', click: (item, focusedWindow) => { - dialog.showOpenDialog(focusedWindow, { - properties: ['openFile', 'multiSelections'] + dialog.showDialog(focusedWindow, { + title: locale.translation('openFile'), + type: 'select-open-multi-file' }, (paths) => { if (paths) { paths.forEach((path) => { diff --git a/app/browser/reducers/downloadsReducer.js b/app/browser/reducers/downloadsReducer.js index 49cf11bc295..1ea2860d1b9 100644 --- a/app/browser/reducers/downloadsReducer.js +++ b/app/browser/reducers/downloadsReducer.js @@ -95,9 +95,9 @@ 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'] + type: 'select-folder' }, (folder) => { if (Array.isArray(folder) && fs.lstatSync(folder[0]).isDirectory()) { appActions.changeSetting(settings.DOWNLOAD_DEFAULT_PATH, folder[0]) diff --git a/app/importer.js b/app/importer.js index 34219fd875c..f3125c9517b 100644 --- a/app/importer.js +++ b/app/importer.js @@ -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({ + 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) => { diff --git a/test/unit/app/browser/reducers/downloadsReducerTest.js b/test/unit/app/browser/reducers/downloadsReducerTest.js index d2bd0a0a1a5..03e68bfcdb6 100644 --- a/test/unit/app/browser/reducers/downloadsReducerTest.js +++ b/test/unit/app/browser/reducers/downloadsReducerTest.js @@ -228,7 +228,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}) @@ -238,7 +238,7 @@ describe('downloadsReducer', function () { stub.restore() }) - it('calls dialog.showOpenDialog', function () { + it('calls dialog.showDialog', function () { assert(stub.calledOnce) }) @@ -247,7 +247,7 @@ describe('downloadsReducer', function () { }) it('passes the correct properties object', function () { - assert.deepEqual(options.properties, ['openDirectory', 'createDirectory']) + assert.deepEqual(options.type, 'select-folder') }) }) }) diff --git a/test/unit/lib/fakeElectron.js b/test/unit/lib/fakeElectron.js index 4e096bdadb3..571a5523fd1 100644 --- a/test/unit/lib/fakeElectron.js +++ b/test/unit/lib/fakeElectron.js @@ -65,7 +65,7 @@ const fakeElectron = { } }, dialog: { - showOpenDialog: function () { } + showDialog: function () { } }, Menu: { setApplicationMenu: (template) => {},