Migrated ShareSheetExportFile from js to ts

Summary: Migrated ShareSheetExportFile.js to ShareSheetExportFile.tsx

Reviewed By: danielbuechele

Differential Revision: D16734995

fbshipit-source-id: 4528b27be0bfbefe9ddbd371c0bfc8950be6fe1f
This commit is contained in:
Benjamin Elo
2019-08-12 05:49:44 -07:00
committed by Facebook Github Bot
parent 223cfe53d7
commit 4f47f73e5e
2 changed files with 22 additions and 26 deletions

View File

@@ -16,7 +16,7 @@ import ErrorBar from './chrome/ErrorBar.tsx';
import ShareSheet from './chrome/ShareSheet.tsx'; import ShareSheet from './chrome/ShareSheet.tsx';
import SignInSheet from './chrome/SignInSheet.js'; import SignInSheet from './chrome/SignInSheet.js';
import ExportDataPluginSheet from './chrome/ExportDataPluginSheet.tsx'; import ExportDataPluginSheet from './chrome/ExportDataPluginSheet.tsx';
import ShareSheetExportFile from './chrome/ShareSheetExportFile.js'; import ShareSheetExportFile from './chrome/ShareSheetExportFile.tsx';
import PluginContainer from './PluginContainer.js'; import PluginContainer from './PluginContainer.js';
import Sheet from './chrome/Sheet.js'; import Sheet from './chrome/Sheet.js';
import {ipcRenderer, remote} from 'electron'; import {ipcRenderer, remote} from 'electron';

View File

@@ -11,26 +11,22 @@ import {
colors, colors,
Text, Text,
LoadingIndicator, LoadingIndicator,
Component,
FlexRow, FlexRow,
Spacer, Spacer,
} from 'flipper'; } from 'flipper';
import { import React, {Component} from 'react';
setExportStatusComponent, import {setExportStatusComponent, unsetShare} from '../reducers/application';
unsetShare,
} from '../reducers/application.tsx';
import {reportPlatformFailures} from '../utils/metrics'; import {reportPlatformFailures} from '../utils/metrics';
import CancellableExportStatus from './CancellableExportStatus.tsx'; import CancellableExportStatus from './CancellableExportStatus';
// $FlowFixMe: Missing type defs for node built-in.
import {performance} from 'perf_hooks'; import {performance} from 'perf_hooks';
import type {Logger} from '../fb-interfaces/Logger.js'; import {Logger} from '../fb-interfaces/Logger.js';
import {Idler} from '../utils/Idler'; import {Idler} from '../utils/Idler';
import { import {
exportStoreToFile, exportStoreToFile,
EXPORT_FLIPPER_TRACE_EVENT, EXPORT_FLIPPER_TRACE_EVENT,
} from '../utils/exportData.tsx'; } from '../utils/exportData';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ShareSheetErrorList from './ShareSheetErrorList.tsx'; import ShareSheetErrorList from './ShareSheetErrorList';
const Container = styled(FlexColumn)({ const Container = styled(FlexColumn)({
padding: 20, padding: 20,
@@ -65,19 +61,22 @@ const InfoText = styled(Text)({
}); });
type Props = { type Props = {
onHide: () => mixed, onHide: () => any;
file: ?string, file: string | null | undefined;
logger: Logger, logger: Logger;
}; };
type State = { type State = {
errorArray: Array<Error>, errorArray: Array<Error>;
result: ?{ result:
success: boolean, | {
error: ?Error, success: boolean;
}, error: Error | null | undefined;
statusUpdate: ?string, }
runInBackground: boolean, | null
| undefined;
statusUpdate: string | null | undefined;
runInBackground: boolean;
}; };
export default class ShareSheetExportFile extends Component<Props, State> { export default class ShareSheetExportFile extends Component<Props, State> {
@@ -112,8 +111,6 @@ export default class ShareSheetExportFile extends Component<Props, State> {
const mark = 'shareSheetExportFile'; const mark = 'shareSheetExportFile';
performance.mark(mark); performance.mark(mark);
try { try {
// Flow doesn't allow us to check for this earlier because `performance` is untyped
// and could presumably do anything.
if (!this.props.file) { if (!this.props.file) {
return; return;
} }
@@ -134,8 +131,7 @@ export default class ShareSheetExportFile extends Component<Props, State> {
); );
this.context.store.dispatch(unsetShare()); this.context.store.dispatch(unsetShare());
if (this.state.runInBackground) { if (this.state.runInBackground) {
new window.Notification('Sharable Flipper trace created', { new Notification('Sharable Flipper trace created', {
//$FlowFixMe: Already checked that props.file exists
body: `Flipper trace exported to the ${this.props.file}`, body: `Flipper trace exported to the ${this.props.file}`,
requireInteraction: true, requireInteraction: true,
}); });
@@ -187,7 +183,7 @@ export default class ShareSheetExportFile extends Component<Props, State> {
<Container> <Container>
<Title bold>Error</Title> <Title bold>Error</Title>
<ErrorMessage code> <ErrorMessage code>
{error?.message || 'File could not be saved.'} {(error && error.message) || 'File could not be saved.'}
</ErrorMessage> </ErrorMessage>
<FlexRow> <FlexRow>
<Spacer /> <Spacer />