Fix broken URL export
Summary: Fixes broken export through URL. Also fixes an issue where we suppress an exception Reviewed By: mweststrate Differential Revision: D19517066 fbshipit-source-id: c68b6a1bcbc8b0588e0db9032268033a42b43c61
This commit is contained in:
committed by
Facebook Github Bot
parent
5a19004732
commit
d31ea742f5
@@ -22,7 +22,7 @@ import {
|
||||
import ShareSheetErrorList from './ShareSheetErrorList';
|
||||
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
||||
import {ReactReduxContext} from 'react-redux';
|
||||
import {store} from '../store';
|
||||
import {MiddlewareAPI} from '../reducers/index';
|
||||
|
||||
const Container = styled(FlexColumn)({
|
||||
padding: 20,
|
||||
@@ -70,6 +70,12 @@ type State = {
|
||||
};
|
||||
|
||||
export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
static contextType = ReactReduxContext;
|
||||
|
||||
get store(): MiddlewareAPI {
|
||||
return this.context.store;
|
||||
}
|
||||
|
||||
state: State = {
|
||||
errorArray: [],
|
||||
result: {kind: 'pending'},
|
||||
@@ -80,13 +86,13 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
idler = new Idler();
|
||||
|
||||
dispatchAndUpdateToolBarStatus(msg: string) {
|
||||
store.dispatch(
|
||||
this.store.dispatch(
|
||||
setExportStatusComponent(
|
||||
<CancellableExportStatus
|
||||
msg={msg}
|
||||
onCancel={() => {
|
||||
this.idler.cancel();
|
||||
store.dispatch(unsetShare());
|
||||
this.store.dispatch(unsetShare());
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
@@ -101,16 +107,21 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
return;
|
||||
}
|
||||
const {errorArray} = await reportPlatformFailures(
|
||||
exportStoreToFile(this.props.file, store, this.idler, (msg: string) => {
|
||||
if (this.state.runInBackground) {
|
||||
this.dispatchAndUpdateToolBarStatus(msg);
|
||||
} else {
|
||||
this.setState({statusUpdate: msg});
|
||||
}
|
||||
}),
|
||||
exportStoreToFile(
|
||||
this.props.file,
|
||||
this.store,
|
||||
this.idler,
|
||||
(msg: string) => {
|
||||
if (this.state.runInBackground) {
|
||||
this.dispatchAndUpdateToolBarStatus(msg);
|
||||
} else {
|
||||
this.setState({statusUpdate: msg});
|
||||
}
|
||||
},
|
||||
),
|
||||
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`,
|
||||
);
|
||||
store.dispatch(unsetShare());
|
||||
this.store.dispatch(unsetShare());
|
||||
if (this.state.runInBackground) {
|
||||
new Notification('Sharable Flipper trace created', {
|
||||
body: `Flipper trace exported to the ${this.props.file}`,
|
||||
@@ -125,6 +136,7 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
this.setState({errorArray: [], result: {kind: 'error', error: err}});
|
||||
}
|
||||
this.props.logger.trackTimeSince(mark, 'export:file-error');
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +209,7 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
cancelAndHide(store: any) {
|
||||
cancelAndHide(store: MiddlewareAPI) {
|
||||
store.dispatch(unsetShare());
|
||||
this.props.onHide();
|
||||
this.idler.cancel();
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
} from 'flipper';
|
||||
import React, {Component} from 'react';
|
||||
import {ReactReduxContext} from 'react-redux';
|
||||
import {store} from '../store';
|
||||
import {
|
||||
setExportStatusComponent,
|
||||
unsetShare,
|
||||
@@ -40,6 +39,8 @@ import {performance} from 'perf_hooks';
|
||||
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
||||
import {getInstance as getLogger} from '../fb-stubs/Logger';
|
||||
import {resetSupportFormV2State} from '../reducers/supportForm';
|
||||
import {MiddlewareAPI} from '../reducers/index';
|
||||
|
||||
export const SHARE_FLIPPER_TRACE_EVENT = 'share-flipper-link';
|
||||
|
||||
const Container = styled(FlexColumn)({
|
||||
@@ -83,6 +84,8 @@ type State = {
|
||||
};
|
||||
|
||||
export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
static contextType = ReactReduxContext;
|
||||
|
||||
state: State = {
|
||||
errorArray: [],
|
||||
result: null,
|
||||
@@ -90,16 +93,20 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
runInBackground: false,
|
||||
};
|
||||
|
||||
get store(): MiddlewareAPI {
|
||||
return this.context.store;
|
||||
}
|
||||
|
||||
idler = new Idler();
|
||||
|
||||
dispatchAndUpdateToolBarStatus(msg: string) {
|
||||
store.dispatch(
|
||||
this.store.dispatch(
|
||||
setExportStatusComponent(
|
||||
<CancellableExportStatus
|
||||
msg={msg}
|
||||
onCancel={() => {
|
||||
this.idler.cancel();
|
||||
store.dispatch(unsetShare());
|
||||
this.store.dispatch(unsetShare());
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
@@ -118,7 +125,7 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
}
|
||||
};
|
||||
const {serializedString, errorArray} = await reportPlatformFailures(
|
||||
exportStore(store.getState(), this.idler, statusUpdate),
|
||||
exportStore(this.store, this.idler, statusUpdate),
|
||||
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_LINK`,
|
||||
);
|
||||
const uploadMarker = `${EXPORT_FLIPPER_TRACE_EVENT}:upload`;
|
||||
@@ -131,19 +138,19 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
`${SHARE_FLIPPER_TRACE_EVENT}`,
|
||||
);
|
||||
getLogger().trackTimeSince(uploadMarker, uploadMarker, {
|
||||
plugins: store.getState().plugins.selectedPlugins,
|
||||
plugins: this.store.getState().plugins.selectedPlugins,
|
||||
});
|
||||
this.setState({errorArray, result});
|
||||
const flipperUrl = (result as DataExportResult).flipperUrl;
|
||||
if (flipperUrl) {
|
||||
clipboard.writeText(String(flipperUrl));
|
||||
store.dispatch(setExportURL(flipperUrl));
|
||||
this.store.dispatch(setExportURL(flipperUrl));
|
||||
new Notification('Sharable Flipper trace created', {
|
||||
body: 'URL copied to clipboard',
|
||||
requireInteraction: true,
|
||||
});
|
||||
}
|
||||
store.dispatch(resetSupportFormV2State());
|
||||
this.store.dispatch(resetSupportFormV2State());
|
||||
this.props.logger.trackTimeSince(mark, 'export:url-success');
|
||||
} catch (e) {
|
||||
if (!this.state.runInBackground) {
|
||||
@@ -161,8 +168,9 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
}
|
||||
this.setState({result});
|
||||
}
|
||||
store.dispatch(unsetShare());
|
||||
this.store.dispatch(unsetShare());
|
||||
this.props.logger.trackTimeSince(mark, 'export:url-error');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +192,7 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
cancelAndHide = (store: any) => () => {
|
||||
cancelAndHide = (store: MiddlewareAPI) => () => {
|
||||
store.dispatch(unsetShare());
|
||||
this.hideSheet();
|
||||
};
|
||||
|
||||
@@ -607,7 +607,7 @@ export async function exportStore(
|
||||
|
||||
export const exportStoreToFile = (
|
||||
exportFilePath: string,
|
||||
store: Store,
|
||||
store: MiddlewareAPI,
|
||||
idler?: Idler,
|
||||
statusUpdate?: (msg: string) => void,
|
||||
): Promise<{errorArray: Array<Error>}> => {
|
||||
|
||||
Reference in New Issue
Block a user