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 ShareSheetErrorList from './ShareSheetErrorList';
|
||||||
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
||||||
import {ReactReduxContext} from 'react-redux';
|
import {ReactReduxContext} from 'react-redux';
|
||||||
import {store} from '../store';
|
import {MiddlewareAPI} from '../reducers/index';
|
||||||
|
|
||||||
const Container = styled(FlexColumn)({
|
const Container = styled(FlexColumn)({
|
||||||
padding: 20,
|
padding: 20,
|
||||||
@@ -70,6 +70,12 @@ type State = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default class ShareSheetExportFile extends Component<Props, State> {
|
export default class ShareSheetExportFile extends Component<Props, State> {
|
||||||
|
static contextType = ReactReduxContext;
|
||||||
|
|
||||||
|
get store(): MiddlewareAPI {
|
||||||
|
return this.context.store;
|
||||||
|
}
|
||||||
|
|
||||||
state: State = {
|
state: State = {
|
||||||
errorArray: [],
|
errorArray: [],
|
||||||
result: {kind: 'pending'},
|
result: {kind: 'pending'},
|
||||||
@@ -80,13 +86,13 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
|||||||
idler = new Idler();
|
idler = new Idler();
|
||||||
|
|
||||||
dispatchAndUpdateToolBarStatus(msg: string) {
|
dispatchAndUpdateToolBarStatus(msg: string) {
|
||||||
store.dispatch(
|
this.store.dispatch(
|
||||||
setExportStatusComponent(
|
setExportStatusComponent(
|
||||||
<CancellableExportStatus
|
<CancellableExportStatus
|
||||||
msg={msg}
|
msg={msg}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
this.idler.cancel();
|
this.idler.cancel();
|
||||||
store.dispatch(unsetShare());
|
this.store.dispatch(unsetShare());
|
||||||
}}
|
}}
|
||||||
/>,
|
/>,
|
||||||
),
|
),
|
||||||
@@ -101,16 +107,21 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {errorArray} = await reportPlatformFailures(
|
const {errorArray} = await reportPlatformFailures(
|
||||||
exportStoreToFile(this.props.file, store, this.idler, (msg: string) => {
|
exportStoreToFile(
|
||||||
|
this.props.file,
|
||||||
|
this.store,
|
||||||
|
this.idler,
|
||||||
|
(msg: string) => {
|
||||||
if (this.state.runInBackground) {
|
if (this.state.runInBackground) {
|
||||||
this.dispatchAndUpdateToolBarStatus(msg);
|
this.dispatchAndUpdateToolBarStatus(msg);
|
||||||
} else {
|
} else {
|
||||||
this.setState({statusUpdate: msg});
|
this.setState({statusUpdate: msg});
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`,
|
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`,
|
||||||
);
|
);
|
||||||
store.dispatch(unsetShare());
|
this.store.dispatch(unsetShare());
|
||||||
if (this.state.runInBackground) {
|
if (this.state.runInBackground) {
|
||||||
new Notification('Sharable Flipper trace created', {
|
new Notification('Sharable Flipper trace created', {
|
||||||
body: `Flipper trace exported to the ${this.props.file}`,
|
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.setState({errorArray: [], result: {kind: 'error', error: err}});
|
||||||
}
|
}
|
||||||
this.props.logger.trackTimeSince(mark, 'export:file-error');
|
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());
|
store.dispatch(unsetShare());
|
||||||
this.props.onHide();
|
this.props.onHide();
|
||||||
this.idler.cancel();
|
this.idler.cancel();
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
} from 'flipper';
|
} from 'flipper';
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {ReactReduxContext} from 'react-redux';
|
import {ReactReduxContext} from 'react-redux';
|
||||||
import {store} from '../store';
|
|
||||||
import {
|
import {
|
||||||
setExportStatusComponent,
|
setExportStatusComponent,
|
||||||
unsetShare,
|
unsetShare,
|
||||||
@@ -40,6 +39,8 @@ import {performance} from 'perf_hooks';
|
|||||||
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
||||||
import {getInstance as getLogger} from '../fb-stubs/Logger';
|
import {getInstance as getLogger} from '../fb-stubs/Logger';
|
||||||
import {resetSupportFormV2State} from '../reducers/supportForm';
|
import {resetSupportFormV2State} from '../reducers/supportForm';
|
||||||
|
import {MiddlewareAPI} from '../reducers/index';
|
||||||
|
|
||||||
export const SHARE_FLIPPER_TRACE_EVENT = 'share-flipper-link';
|
export const SHARE_FLIPPER_TRACE_EVENT = 'share-flipper-link';
|
||||||
|
|
||||||
const Container = styled(FlexColumn)({
|
const Container = styled(FlexColumn)({
|
||||||
@@ -83,6 +84,8 @@ type State = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default class ShareSheetExportUrl extends Component<Props, State> {
|
export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||||
|
static contextType = ReactReduxContext;
|
||||||
|
|
||||||
state: State = {
|
state: State = {
|
||||||
errorArray: [],
|
errorArray: [],
|
||||||
result: null,
|
result: null,
|
||||||
@@ -90,16 +93,20 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
|||||||
runInBackground: false,
|
runInBackground: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get store(): MiddlewareAPI {
|
||||||
|
return this.context.store;
|
||||||
|
}
|
||||||
|
|
||||||
idler = new Idler();
|
idler = new Idler();
|
||||||
|
|
||||||
dispatchAndUpdateToolBarStatus(msg: string) {
|
dispatchAndUpdateToolBarStatus(msg: string) {
|
||||||
store.dispatch(
|
this.store.dispatch(
|
||||||
setExportStatusComponent(
|
setExportStatusComponent(
|
||||||
<CancellableExportStatus
|
<CancellableExportStatus
|
||||||
msg={msg}
|
msg={msg}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
this.idler.cancel();
|
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(
|
const {serializedString, errorArray} = await reportPlatformFailures(
|
||||||
exportStore(store.getState(), this.idler, statusUpdate),
|
exportStore(this.store, this.idler, statusUpdate),
|
||||||
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_LINK`,
|
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_LINK`,
|
||||||
);
|
);
|
||||||
const uploadMarker = `${EXPORT_FLIPPER_TRACE_EVENT}:upload`;
|
const uploadMarker = `${EXPORT_FLIPPER_TRACE_EVENT}:upload`;
|
||||||
@@ -131,19 +138,19 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
|||||||
`${SHARE_FLIPPER_TRACE_EVENT}`,
|
`${SHARE_FLIPPER_TRACE_EVENT}`,
|
||||||
);
|
);
|
||||||
getLogger().trackTimeSince(uploadMarker, uploadMarker, {
|
getLogger().trackTimeSince(uploadMarker, uploadMarker, {
|
||||||
plugins: store.getState().plugins.selectedPlugins,
|
plugins: this.store.getState().plugins.selectedPlugins,
|
||||||
});
|
});
|
||||||
this.setState({errorArray, result});
|
this.setState({errorArray, result});
|
||||||
const flipperUrl = (result as DataExportResult).flipperUrl;
|
const flipperUrl = (result as DataExportResult).flipperUrl;
|
||||||
if (flipperUrl) {
|
if (flipperUrl) {
|
||||||
clipboard.writeText(String(flipperUrl));
|
clipboard.writeText(String(flipperUrl));
|
||||||
store.dispatch(setExportURL(flipperUrl));
|
this.store.dispatch(setExportURL(flipperUrl));
|
||||||
new Notification('Sharable Flipper trace created', {
|
new Notification('Sharable Flipper trace created', {
|
||||||
body: 'URL copied to clipboard',
|
body: 'URL copied to clipboard',
|
||||||
requireInteraction: true,
|
requireInteraction: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
store.dispatch(resetSupportFormV2State());
|
this.store.dispatch(resetSupportFormV2State());
|
||||||
this.props.logger.trackTimeSince(mark, 'export:url-success');
|
this.props.logger.trackTimeSince(mark, 'export:url-success');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!this.state.runInBackground) {
|
if (!this.state.runInBackground) {
|
||||||
@@ -161,8 +168,9 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
|||||||
}
|
}
|
||||||
this.setState({result});
|
this.setState({result});
|
||||||
}
|
}
|
||||||
store.dispatch(unsetShare());
|
this.store.dispatch(unsetShare());
|
||||||
this.props.logger.trackTimeSince(mark, 'export:url-error');
|
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());
|
store.dispatch(unsetShare());
|
||||||
this.hideSheet();
|
this.hideSheet();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -607,7 +607,7 @@ export async function exportStore(
|
|||||||
|
|
||||||
export const exportStoreToFile = (
|
export const exportStoreToFile = (
|
||||||
exportFilePath: string,
|
exportFilePath: string,
|
||||||
store: Store,
|
store: MiddlewareAPI,
|
||||||
idler?: Idler,
|
idler?: Idler,
|
||||||
statusUpdate?: (msg: string) => void,
|
statusUpdate?: (msg: string) => void,
|
||||||
): Promise<{errorArray: Array<Error>}> => {
|
): Promise<{errorArray: Array<Error>}> => {
|
||||||
|
|||||||
Reference in New Issue
Block a user