Share Flipper file

Reviewed By: jknoxville

Differential Revision: D14340965

fbshipit-source-id: 9145ae8d409e9d4f8becfd1a19a8a9b3739af3fb
This commit is contained in:
Daniel Büchele
2019-03-06 05:50:05 -08:00
committed by Facebook Github Bot
parent c0a30380dc
commit b304126af3
2 changed files with 43 additions and 21 deletions

View File

@@ -8,6 +8,7 @@
import type {FlipperPlugin, FlipperDevicePlugin} from './plugin.js';
import {
exportStoreToFile,
exportStore,
importFileToStore,
IMPORT_FLIPPER_TRACE_EVENT,
EXPORT_FLIPPER_TRACE_EVENT,
@@ -19,6 +20,7 @@ import {remote} from 'electron';
const {dialog} = remote;
import os from 'os';
import path from 'path';
import {shareFlipperData} from './fb-stubs/user';
import {
reportPlatformFailures,
tryCatchReportPlatformFailures,
@@ -326,27 +328,8 @@ function getTemplate(
label: 'File',
submenu: [
{
label: 'Export Data...',
role: 'export',
click: function(item: Object, focusedWindow: Object) {
dialog.showSaveDialog(
null,
{
title: 'FlipperExport',
defaultPath: path.join(os.homedir(), 'FlipperExport.flipper'),
},
file => {
reportPlatformFailures(
exportStoreToFile(file, store),
`${EXPORT_FLIPPER_TRACE_EVENT}:UI`,
);
},
);
},
},
{
label: 'Import Data...',
role: 'import',
label: 'Open File...',
accelerator: 'CommandOrControl+O',
click: function(item: Object, focusedWindow: Object) {
dialog.showOpenDialog(
{
@@ -362,6 +345,40 @@ function getTemplate(
);
},
},
{
label: 'Export',
submenu: [
{
label: 'File...',
accelerator: 'CommandOrControl+E',
click: function(item: Object, focusedWindow: Object) {
dialog.showSaveDialog(
null,
{
title: 'FlipperExport',
defaultPath: path.join(
os.homedir(),
'FlipperExport.flipper',
),
},
file => {
reportPlatformFailures(
exportStoreToFile(file, store),
`${EXPORT_FLIPPER_TRACE_EVENT}:UI`,
);
},
);
},
},
{
label: 'Sharable Link',
accelerator: 'CommandOrControl+Shift+E',
click: async function(item: Object, focusedWindow: Object) {
shareFlipperData(await exportStore(store));
},
},
],
},
],
});
}