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:
committed by
Facebook Github Bot
parent
259ae35284
commit
9bc54597cf
@@ -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);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user