From ef0d9fb77e0abb95eeb02e5dcbcf94f97b3d8afb Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Tue, 25 Oct 2022 05:31:48 -0700 Subject: [PATCH] Export Flipper state as a part of the universal export Summary: Design doc: https://docs.google.com/document/d/1HLCFl46RfqG0o1mSt8SWrwf_HMfOCRg_oENioc1rkvQ/edit# Create Flipper export as a part on the universal export Reviewed By: passy Differential Revision: D40468242 fbshipit-source-id: b1b8e4df3b630c6163bb383482123c12dfc6e118 --- .../src/sandy-chrome/LeftRail.tsx | 11 +++++--- .../flipper-ui-core/src/utils/exportData.tsx | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx b/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx index 993bc1d90..b545fa739 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx @@ -59,6 +59,7 @@ import constants from '../fb-stubs/constants'; import { canFileExport, canOpenDialog, + exportEverythingEverywhereAllAtOnce, showOpenDialog, startFileExport, startLinkExport, @@ -433,10 +434,12 @@ function DebugLogsButton({ } function ExportEverythingEverywhereAllAtOnceButton() { - const startLogsExportTracked = useTrackedCallback( + const store = useStore(); + + const exportEverythingEverywhereAllAtOnceTracked = useTrackedCallback( 'Debug data export', - startLogsExport, - [], + () => exportEverythingEverywhereAllAtOnce(store), + [store], ); return ( @@ -444,7 +447,7 @@ function ExportEverythingEverywhereAllAtOnceButton() { icon={} title="Export Flipper debug data" onClick={() => { - startLogsExportTracked(); + exportEverythingEverywhereAllAtOnceTracked(); }} small /> diff --git a/desktop/flipper-ui-core/src/utils/exportData.tsx b/desktop/flipper-ui-core/src/utils/exportData.tsx index 7e85ade9d..635ad5399 100644 --- a/desktop/flipper-ui-core/src/utils/exportData.tsx +++ b/desktop/flipper-ui-core/src/utils/exportData.tsx @@ -612,6 +612,31 @@ export async function startLogsExport() { await getRenderHostInstance().exportFile?.(serializedLogs); } +export async function exportEverythingEverywhereAllAtOnce( + store: MiddlewareAPI, +) { + // TODO: Show a progress dialog + // TODO: Pack all files in a single archive + + // Step 1: Export Flipper logs + await startLogsExport(); + + // Step 2: Export device logs + // TODO: Implement me + + // Step 3: Export Flipper State + // TODO: Export all plugins automatically + const plugins = await selectPlugins(); + if (plugins === false) { + return; // cancelled + } + // TODO: no need to put this in the store, + // need to be cleaned up later in combination with SupportForm + store.dispatch(selectedPlugins(plugins)); + const {serializedString} = await exportStore(store); + await getRenderHostInstance().exportFile?.(serializedString); +} + export async function startFileExport(dispatch: Store['dispatch']) { const file = await getRenderHostInstance().showSaveDialog?.({ title: 'FlipperExport',