Serialize Store
Summary:
This diff adds the capability to export the flipper data to a file. With this diff you can click on the "Export Flipper" option from the "Edit" menu in menubar. It will export it in the file at this location
`~/.flipper/MessageLogs.json`
We do not exactly export the store, but just the important part of it. We export in the following format
```
{
fileVersion: '1.0',
device: {
os: 'iOS',
title: 'iPhone 7',
serial: '',
deviceType: 'physical',
},
clients: [
{
query: {
app: 'Facebook',
},
d: '12345678'
},
{
query: {
app: 'Instagram',
},
id: '12345678'
}
],
store: {
pluginState: {},
notifications: {}
}
}
```
In next diff I will add the capability to select the folder to export the file too.
Reviewed By: danielbuechele
Differential Revision: D13751963
fbshipit-source-id: 7d3d49c6adf8145b2181d2332c7dbd589155cec3
This commit is contained in:
committed by
Facebook Github Bot
parent
fc1d32a3f9
commit
5ef970e5b5
@@ -6,7 +6,8 @@
|
||||
*/
|
||||
|
||||
import type {FlipperPlugin, FlipperDevicePlugin} from './plugin.js';
|
||||
|
||||
import {exportStoreToFile} from './utils/exportData.js';
|
||||
import type {Store} from './reducers/';
|
||||
import electron from 'electron';
|
||||
|
||||
export type DefaultKeyboardAction = 'clear' | 'goToBottom' | 'createPaste';
|
||||
@@ -64,9 +65,13 @@ function actionHandler(action: string) {
|
||||
|
||||
export function setupMenuBar(
|
||||
plugins: Array<Class<FlipperPlugin<> | FlipperDevicePlugin<>>>,
|
||||
store: Store,
|
||||
) {
|
||||
const template = getTemplate(electron.remote.app, electron.remote.shell);
|
||||
|
||||
const template = getTemplate(
|
||||
electron.remote.app,
|
||||
electron.remote.shell,
|
||||
store,
|
||||
);
|
||||
// collect all keyboard actions from all plugins
|
||||
const registeredActions: Set<?KeyboardAction> = new Set(
|
||||
plugins
|
||||
@@ -169,8 +174,24 @@ export function activateMenuItems(
|
||||
);
|
||||
}
|
||||
|
||||
function getTemplate(app: Object, shell: Object): Array<MenuItem> {
|
||||
function getTemplate(
|
||||
app: Object,
|
||||
shell: Object,
|
||||
store: Store,
|
||||
): Array<MenuItem> {
|
||||
const template = [
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Export Data',
|
||||
role: 'export',
|
||||
click: function(item: Object, focusedWindow: Object) {
|
||||
exportStoreToFile(store);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
|
||||
Reference in New Issue
Block a user