diff --git a/src/MenuBar.js b/src/MenuBar.js index da0e61303..d3e5c70a3 100644 --- a/src/MenuBar.js +++ b/src/MenuBar.js @@ -12,6 +12,8 @@ import electron from 'electron'; import {GK} from 'flipper'; import {remote} from 'electron'; const {dialog} = remote; +import os from 'os'; +import path from 'path'; export type DefaultKeyboardAction = 'clear' | 'goToBottom' | 'createPaste'; export type TopLevelMenu = 'Edit' | 'View' | 'Window' | 'Help'; @@ -320,7 +322,16 @@ function getTemplate( label: 'Export Data...', role: 'export', click: function(item: Object, focusedWindow: Object) { - exportStoreToFile(store); + dialog.showSaveDialog( + null, + { + title: 'FlipperExport', + defaultPath: path.join(os.homedir(), 'FlipperExport.json'), + }, + file => { + exportStoreToFile(file, store); + }, + ); }, }, { diff --git a/src/utils/exportData.js b/src/utils/exportData.js index eb0af3405..4e5c1bcf1 100644 --- a/src/utils/exportData.js +++ b/src/utils/exportData.js @@ -16,16 +16,7 @@ import {default as BaseDevice} from '../devices/BaseDevice'; import {default as ArchivedDevice} from '../devices/ArchivedDevice'; import {default as Client} from '../Client'; import {getInstance} from '../fb-stubs/Logger.js'; - import fs from 'fs'; -import os from 'os'; -import path from 'path'; - -const exportFilePath = path.join( - os.homedir(), - '.flipper', - 'FlipperExport.json', -); export type ExportType = {| fileVersion: '1.0.0', @@ -138,8 +129,11 @@ export function serializeStore(state: State): ?ExportType { ); } -export const exportStoreToFile = (store: Store): Promise => { - const json = serializeStore(store.getState()); +export const exportStoreToFile = ( + exportFilePath: string, + data: Store, +): Promise => { + const json = serializeStore(data.getState()); if (json) { return new Promise((resolve, reject) => { fs.writeFile(exportFilePath, JSON.stringify(json), err => {