diff --git a/src/App.js b/src/App.js index c7a193214..2030980e7 100644 --- a/src/App.js +++ b/src/App.js @@ -26,6 +26,7 @@ import { ACTIVE_SHEET_SHARE_DATA, ACTIVE_SHEET_SIGN_IN, ACTIVE_SHEET_SHARE_DATA_IN_FILE, + ACTIVE_SHEET_PLUGIN_SHEET, } from './reducers/application.js'; import type {Logger} from './fb-interfaces/Logger.js'; @@ -66,28 +67,29 @@ export class App extends React.Component { } getSheet = (onHide: () => mixed) => { - if (this.props.activeSheet === ACTIVE_SHEET_BUG_REPORTER) { - return ( - - ); - } else if (this.props.activeSheet === ACTIVE_SHEET_PLUGIN_DEBUGGER) { - return ; - } else if (this.props.activeSheet === ACTIVE_SHEET_SHARE_DATA) { - return ; - } else if (this.props.activeSheet === ACTIVE_SHEET_SIGN_IN) { - return ; - } else if (this.props.activeSheet === ACTIVE_SHEET_SHARE_DATA_IN_FILE) { - const {exportFile} = this.props; - if (!exportFile) { - throw new Error('Tried to export data without passing the file path'); - } - return ; - } else { - // contents are added via React.Portal - return null; + switch (this.props.activeSheet) { + case ACTIVE_SHEET_BUG_REPORTER: + return ( + + ); + case ACTIVE_SHEET_PLUGIN_DEBUGGER: + return ; + case ACTIVE_SHEET_SHARE_DATA: + return ; + case ACTIVE_SHEET_SIGN_IN: + return ; + case ACTIVE_SHEET_SHARE_DATA_IN_FILE: + return ( + + ); + case ACTIVE_SHEET_PLUGIN_SHEET: + // Currently unused. + return null; + default: + return null; } }; diff --git a/src/chrome/ShareSheetExportFile.js b/src/chrome/ShareSheetExportFile.js index b4a374084..2abcccdfb 100644 --- a/src/chrome/ShareSheetExportFile.js +++ b/src/chrome/ShareSheetExportFile.js @@ -65,7 +65,7 @@ const Padder = styled('div')( type Props = { onHide: () => mixed, - file: string, + file: ?string, }; type State = { errorArray: Array, @@ -86,6 +86,10 @@ export default class ShareSheetExportFile extends Component { }; async componentDidMount() { + if (!this.props.file) { + return; + } + try { const {errorArray} = await reportPlatformFailures( exportStoreToFile(this.props.file, this.context.store), @@ -98,6 +102,10 @@ export default class ShareSheetExportFile extends Component { } render() { + if (!this.props.file) { + return this.renderNoFileError(); + } + const {result} = this.state; if (result) { const {success, error} = result; @@ -161,4 +169,20 @@ export default class ShareSheetExportFile extends Component { ); } } + + renderNoFileError() { + return ( + +
+ No file selected +
+ + + + +
+ ); + } }