Import from exported file

Summary:
This diff adds the feature to import the exported flipper data. It has the following features

- Dialog to select the file
- Merges the data with an existing store.

Reviewed By: danielbuechele

Differential Revision: D13901944

fbshipit-source-id: 1b9755735419732a34254bdc39d911bcb51ad8fe
This commit is contained in:
Pritesh Nandgaonkar
2019-02-05 09:26:43 -08:00
committed by Facebook Github Bot
parent 259ae35284
commit 9bc54597cf
8 changed files with 129 additions and 22 deletions

View File

@@ -6,10 +6,12 @@
*/
import type {FlipperPlugin, FlipperDevicePlugin} from './plugin.js';
import {exportStoreToFile} from './utils/exportData.js';
import {exportStoreToFile, importFileToStore} from './utils/exportData.js';
import type {Store} from './reducers/';
import electron from 'electron';
import {GK} from 'flipper';
import {remote} from 'electron';
const {dialog} = remote;
export type DefaultKeyboardAction = 'clear' | 'goToBottom' | 'createPaste';
export type TopLevelMenu = 'Edit' | 'View' | 'Window' | 'Help';
@@ -315,12 +317,28 @@ function getTemplate(
label: 'File',
submenu: [
{
label: 'Export Data',
label: 'Export Data...',
role: 'export',
click: function(item: Object, focusedWindow: Object) {
exportStoreToFile(store);
},
},
{
label: 'Import Data...',
role: 'import',
click: function(item: Object, focusedWindow: Object) {
dialog.showOpenDialog(
{
properties: ['openFile'],
},
(files: Array<string>) => {
if (files !== undefined && files.length > 0) {
importFileToStore(files[0], store);
}
},
);
},
},
],
});
}