diff --git a/src/App.js b/src/App.js index 7f36a25..3c2d92f 100644 --- a/src/App.js +++ b/src/App.js @@ -25,8 +25,7 @@ import { checkInstalled, installDependency, installRelease, - installUpgrade, - setMissingDependencies + installUpgrade } from './redux/actions/install_actions'; import { detectUIUpgrade, @@ -78,6 +77,11 @@ class App extends Component { Scheduler.cancelJob(this.scheduledUpdateJob); } + createModalConditionally = (condition, jsx, critical) => { + const modalProps = {critical: critical}; + return condition ? ({jsx}) : null; + }; + detectUpgrades = () => { if (this.props.AppPlatform !== 'unknown') { this.props.loadReleases(); @@ -263,50 +267,11 @@ class App extends Component { missingDependencies && !this.props.DownloadActive; - let errorDisplay = null; - if (this.props.DisplayError) { - errorDisplay = ( - - - - ); - } - - let configDisplay = null; - if (showConfig) { - configDisplay = ( - - - - ); - } - - let dependencyDisplay = null; - if (showDependencies) { - dependencyDisplay = ( - - - - ); - } - - let downloadDisplay = null; - if (this.props.DownloadActive) { - downloadDisplay = ( - - - - ); - } - - let upgradeDisplay = null; - if (showUpgrade) { - upgradeDisplay = ( - - - - ); - } + const configDisplay = this.createModalConditionally(showConfig, ); + const dependencyDisplay = this.createModalConditionally(showDependencies, ); + const downloadDisplay = this.createModalConditionally(this.props.DownloadActive, ); + const errorDisplay = this.createModalConditionally(this.props.DisplayError, , true); + const upgradeDisplay = this.createModalConditionally(showUpgrade, ); let mainContent = []; if (this.props.AppReady) { @@ -412,7 +377,6 @@ const mapDispatchToProps = dispatch => { setAllowDownload: allow => dispatch(setAllowDownload(allow)), setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)), setInstalledVersion: version => dispatch(setInstalledVersion(version)), - setMissingDependencies: dependencies => dispatch(setMissingDependencies(dependencies)), setProviderState: (provider, state) => dispatch(setProviderState(provider, state)), setReleaseUpgradeAvailable: available => dispatch(setReleaseUpgradeAvailable(available)), };