Refactor share sheet selection
Summary: We're if-ing over an enum, so this should be a switch. Also removed the edge case for the share sheet and made the error handling part of the component so the user actually sees it. Reviewed By: jknoxville Differential Revision: D15853056 fbshipit-source-id: 241ed0f2e042b08c4c157db9616175297b683ac3
This commit is contained in:
committed by
Facebook Github Bot
parent
5aaf0c4f29
commit
9c75ea7665
46
src/App.js
46
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<Props> {
|
||||
}
|
||||
|
||||
getSheet = (onHide: () => mixed) => {
|
||||
if (this.props.activeSheet === ACTIVE_SHEET_BUG_REPORTER) {
|
||||
return (
|
||||
<BugReporterDialog
|
||||
bugReporter={this.props.bugReporter}
|
||||
onHide={onHide}
|
||||
/>
|
||||
);
|
||||
} else if (this.props.activeSheet === ACTIVE_SHEET_PLUGIN_DEBUGGER) {
|
||||
return <PluginDebugger onHide={onHide} />;
|
||||
} else if (this.props.activeSheet === ACTIVE_SHEET_SHARE_DATA) {
|
||||
return <ShareSheet onHide={onHide} />;
|
||||
} else if (this.props.activeSheet === ACTIVE_SHEET_SIGN_IN) {
|
||||
return <SignInSheet onHide={onHide} />;
|
||||
} 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 <ShareSheetExportFile onHide={onHide} file={exportFile} />;
|
||||
} else {
|
||||
// contents are added via React.Portal
|
||||
return null;
|
||||
switch (this.props.activeSheet) {
|
||||
case ACTIVE_SHEET_BUG_REPORTER:
|
||||
return (
|
||||
<BugReporterDialog
|
||||
bugReporter={this.props.bugReporter}
|
||||
onHide={onHide}
|
||||
/>
|
||||
);
|
||||
case ACTIVE_SHEET_PLUGIN_DEBUGGER:
|
||||
return <PluginDebugger onHide={onHide} />;
|
||||
case ACTIVE_SHEET_SHARE_DATA:
|
||||
return <ShareSheet onHide={onHide} />;
|
||||
case ACTIVE_SHEET_SIGN_IN:
|
||||
return <SignInSheet onHide={onHide} />;
|
||||
case ACTIVE_SHEET_SHARE_DATA_IN_FILE:
|
||||
return (
|
||||
<ShareSheetExportFile onHide={onHide} file={this.props.exportFile} />
|
||||
);
|
||||
case ACTIVE_SHEET_PLUGIN_SHEET:
|
||||
// Currently unused.
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user