Refactoring
This commit is contained in:
58
src/App.js
58
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 ? (<Modal {...modalProps}>{jsx}</Modal>) : 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 = (
|
||||
<Modal critical>
|
||||
<ErrorDetails/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
let configDisplay = null;
|
||||
if (showConfig) {
|
||||
configDisplay = (
|
||||
<Modal>
|
||||
<Configuration version={selectedVersion} />
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
let dependencyDisplay = null;
|
||||
if (showDependencies) {
|
||||
dependencyDisplay = (
|
||||
<Modal>
|
||||
<DependencyList onDownload={this.handleDownloadDependency}/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
let downloadDisplay = null;
|
||||
if (this.props.DownloadActive) {
|
||||
downloadDisplay = (
|
||||
<Modal>
|
||||
<DownloadProgress/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
let upgradeDisplay = null;
|
||||
if (showUpgrade) {
|
||||
upgradeDisplay = (
|
||||
<Modal>
|
||||
<UpgradeUI upgrade={this.handleDownloadUpgrade}/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
const configDisplay = this.createModalConditionally(showConfig, <Configuration version={selectedVersion} />);
|
||||
const dependencyDisplay = this.createModalConditionally(showDependencies, <DependencyList onDownload={this.handleDownloadDependency}/>);
|
||||
const downloadDisplay = this.createModalConditionally(this.props.DownloadActive, <DownloadProgress/>);
|
||||
const errorDisplay = this.createModalConditionally(this.props.DisplayError, <ErrorDetails/>, true);
|
||||
const upgradeDisplay = this.createModalConditionally(showUpgrade, <UpgradeUI upgrade={this.handleDownloadUpgrade}/>);
|
||||
|
||||
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)),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user