Make it possible to export support form V2 with meta data
Summary: This diff enables a full roundtrip of exporting a bug report to file / link, and importing it again. Styling is not part of this story. Reviewed By: jknoxville Differential Revision: D18636418 fbshipit-source-id: ef9a8e3622bdac9361f612d51415a593f4268b80
This commit is contained in:
committed by
Facebook Github Bot
parent
f33666a4b9
commit
dd65ec6ed0
@@ -7,6 +7,9 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import electron from 'electron';
|
||||
import {getInstance as getLogger} from '../fb-stubs/Logger';
|
||||
import {Store, MiddlewareAPI} from '../reducers';
|
||||
import {DeviceExport} from '../devices/BaseDevice';
|
||||
@@ -33,6 +36,12 @@ import {promisify} from 'util';
|
||||
import promiseTimeout from './promiseTimeout';
|
||||
import {Idler} from './Idler';
|
||||
import {setStaticView} from '../reducers/connections';
|
||||
import {
|
||||
SupportFormV2State,
|
||||
resetSupportFormV2State,
|
||||
} from '../reducers/supportForm';
|
||||
import {setSelectPluginsToExportActiveSheet} from '../reducers/application';
|
||||
|
||||
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
|
||||
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
|
||||
export const EXPORT_FLIPPER_TRACE_TIME_SERIALIZATION_EVENT = `${EXPORT_FLIPPER_TRACE_EVENT}:serialization`;
|
||||
@@ -49,7 +58,7 @@ export type ExportType = {
|
||||
pluginStates: PluginStatesExportState;
|
||||
activeNotifications: Array<PluginNotification>;
|
||||
};
|
||||
supportRequestDetails?: SupportRequestDetailsMetaData;
|
||||
supportRequestDetails?: SupportFormV2State;
|
||||
};
|
||||
|
||||
type ProcessPluginStatesOptions = {
|
||||
@@ -83,15 +92,6 @@ type AddSaltToDeviceSerialOptions = {
|
||||
statusUpdate?: (msg: string) => void;
|
||||
};
|
||||
|
||||
export type SupportRequestDetailsMetaData = {
|
||||
title: string;
|
||||
app: string;
|
||||
description: string;
|
||||
commitHash: string;
|
||||
screenshots: {image: string; description: string}[];
|
||||
videos: {url: string; description: string}[];
|
||||
};
|
||||
|
||||
export function processClients(
|
||||
clients: Array<ClientExport>,
|
||||
serial: string,
|
||||
@@ -545,6 +545,7 @@ export function exportStore(
|
||||
idler,
|
||||
);
|
||||
if (exportData != null) {
|
||||
exportData.supportRequestDetails = store.getState().supportForm?.supportFormV2;
|
||||
statusUpdate && statusUpdate('Serializing Flipper data...');
|
||||
const serializedString = JSON.stringify(exportData);
|
||||
if (serializedString.length <= 0) {
|
||||
@@ -578,6 +579,7 @@ export const exportStoreToFile = (
|
||||
({serializedString, errorArray}) => {
|
||||
return promisify(fs.writeFile)(exportFilePath, serializedString).then(
|
||||
() => {
|
||||
store.dispatch(resetSupportFormV2State());
|
||||
return {errorArray};
|
||||
},
|
||||
);
|
||||
@@ -697,3 +699,37 @@ export function showOpenDialog(store: Store) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function startFileExport(dispatch: Store['dispatch']) {
|
||||
electron.remote.dialog
|
||||
.showSaveDialog(
|
||||
// @ts-ignore This appears to work but isn't allowed by the types
|
||||
null,
|
||||
{
|
||||
title: 'FlipperExport',
|
||||
defaultPath: path.join(os.homedir(), 'FlipperExport.flipper'),
|
||||
},
|
||||
)
|
||||
.then(async (result: electron.SaveDialogReturnValue) => {
|
||||
const file = result.filePath;
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
dispatch(
|
||||
setSelectPluginsToExportActiveSheet({
|
||||
type: 'file',
|
||||
file: file,
|
||||
closeOnFinish: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function startLinkExport(dispatch: Store['dispatch']) {
|
||||
dispatch(
|
||||
setSelectPluginsToExportActiveSheet({
|
||||
type: 'link',
|
||||
closeOnFinish: false,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user