From 5964f1621e4575eb30351e1793dbfa00360c804e Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 20 Mar 2019 06:56:01 -0700 Subject: [PATCH] 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 --- src/MenuBar.js | 98 +++++++++++++++++++-------------------- src/fb-stubs/constants.js | 3 ++ 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/MenuBar.js b/src/MenuBar.js index 4a44bdfa9..4578910a5 100644 --- a/src/MenuBar.js +++ b/src/MenuBar.js @@ -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 { + 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({ diff --git a/src/fb-stubs/constants.js b/src/fb-stubs/constants.js index 8e7d04fba..04796e3d6 100644 --- a/src/fb-stubs/constants.js +++ b/src/fb-stubs/constants.js @@ -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;