Open source Import/Export feature to open source

Summary: Exposes Import/Export feature to open source. This diff also makes sure that, "Shareable Link" option doesn't show up, as it is specific to fb's infrastructure.

Reviewed By: passy

Differential Revision: D14526634

fbshipit-source-id: 3aeb97c91bc00a9c5f01c74c34a5690ec3b5739d
This commit is contained in:
Pritesh Nandgaonkar
2019-03-20 06:56:01 -07:00
committed by Facebook Github Bot
parent fd9b581162
commit 5964f1621e
2 changed files with 52 additions and 49 deletions

View File

@@ -14,7 +14,7 @@ import {
import {setActiveSheet, ACTIVE_SHEET_SHARE_DATA} from './reducers/application';
import type {Store} from './reducers/';
import electron from 'electron';
import {GK} from 'flipper';
import {ENABLE_SHAREABLE_LINK} from 'flipper';
import {remote} from 'electron';
const {dialog} = remote;
import os from 'os';
@@ -188,7 +188,54 @@ function getTemplate(
shell: Object,
store: Store,
): Array<MenuItem> {
const exportSubmenu = [
{
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`,
);
},
);
},
},
];
if (ENABLE_SHAREABLE_LINK) {
exportSubmenu.push({
label: 'Sharable Link',
accelerator: 'CommandOrControl+Shift+E',
click: async function(item: Object, focusedWindow: Object) {
store.dispatch(setActiveSheet(ACTIVE_SHEET_SHARE_DATA));
},
});
}
const template = [
{
label: 'File',
submenu: [
{
label: 'Open File...',
accelerator: 'CommandOrControl+O',
click: function(item: Object, focusedWindow: Object) {
showOpenDialog(store);
},
},
{
label: 'Export',
submenu: exportSubmenu,
},
],
},
{
label: 'Edit',
submenu: [
@@ -317,54 +364,7 @@ function getTemplate(
],
},
];
if (GK.get('flipper_import_export')) {
template.unshift({
label: 'File',
submenu: [
{
label: 'Open File...',
accelerator: 'CommandOrControl+O',
click: function(item: Object, focusedWindow: Object) {
showOpenDialog(store);
},
},
{
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) {
store.dispatch(setActiveSheet(ACTIVE_SHEET_SHARE_DATA));
},
},
],
},
],
});
}
if (process.platform === 'darwin') {
const name = app.getName();
template.unshift({

View File

@@ -17,3 +17,6 @@ export const GRAPH_SECRET_ACCESS_TOKEN = '';
// Provides access to Insights Validation ednpoint on interngraph
export const INSIGHT_INTERN_APP_ID = '';
export const INSIGHT_INTERN_APP_TOKEN = '';
// Enables the flipper data to be exported through shareabale link
export const ENABLE_SHAREABLE_LINK = false;