[Application configuration support] [Fix component unmount leak]

This commit is contained in:
Scott E. Graves
2018-09-30 11:00:23 -05:00
parent f11ddb6d75
commit 9968116242
17 changed files with 880 additions and 164 deletions

View File

@@ -1,18 +1,20 @@
import React, {Component} from 'react';
import CSSModules from 'react-css-modules';
import styles from './App.css';
import Box from './components/UI/Box/Box';
import DropDown from './components/UI/DropDown/DropDown';
import * as Constants from './constants';
import axios from 'axios';
import MountItems from './containers/MountItems/MountItems';
import DependencyList from './components/DependencyList/DependencyList';
import styles from './App.css';
import Box from './components/UI/Box/Box';
import Button from './components/UI/Button/Button';
import Modal from './components/UI/Modal/Modal';
import Configuration from './containers/Configuration/Configuration';
import CSSModules from 'react-css-modules';
import DependencyList from './components/DependencyList/DependencyList';
import DownloadProgress from './components/DownloadProgress/DownloadProgress';
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
import DropDown from './components/UI/DropDown/DropDown';
import Loading from './components/UI/Loading/Loading';
import Modal from './components/UI/Modal/Modal';
import MountItems from './containers/MountItems/MountItems';
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
const Scheduler = require('node-schedule');
let ipcRenderer = null;
@@ -208,6 +210,7 @@ class App extends Component {
AllowOptions: false,
AllowDownload: false,
AutoMountChecked: false,
ConfigStorageType: null,
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingDependency: false,
@@ -313,6 +316,18 @@ class App extends Component {
this.saveState(this.state.Release, this.state.Version, sia, hyperspace);
};
handleConfigClicked = (storageType) => {
this.setState({
ConfigStorageType: storageType,
})
};
handleConfigClosed = () => {
this.setState({
ConfigStorageType: null,
});
};
handleDependencyDownload = (url) => {
if (ipcRenderer) {
const items = url.split('/');
@@ -440,30 +455,62 @@ class App extends Component {
const selectedVersion = (this.state.Version === -1) ?
'unavailable' :
this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
const downloadEnabled = this.state.AllowDownload &&
!this.state.MountsBusy &&
!this.state.DownloadActive &&
(((selectedVersion !== 'unavailable') && (selectedVersion !== this.state.RepertoryVersion)));
(selectedVersion !== 'unavailable') &&
(selectedVersion !== this.state.RepertoryVersion);
const allowMount = this.state.RepertoryVersion !== 'none';
const missingDependencies = (this.state.MissingDependencies.length > 0);
const allowConfig = this.state.LocationsLookup[selectedVersion] &&
!this.state.LocationsLookup[selectedVersion].config_allowed;
const showDependencies = missingDependencies &&
!this.state.DownloadActive;
const showConfig = !missingDependencies &&
this.state.ConfigStorageType &&
allowConfig;
const showUpgrade = !showConfig &&
!missingDependencies &&
!this.state.DownloadActive &&
this.state.UpgradeAvailable &&
!this.state.UpgradeDismissed;
let configDisplay = null;
if (showConfig) {
configDisplay = (
<Modal>
<Configuration closed={this.handleConfigClosed}
directory={Constants.DATA_LOCATIONS[this.state.Platform]}
storageType={this.state.ConfigStorageType}
version={selectedVersion} />
</Modal>
);
}
let mountDisplay = null;
if (allowMount) {
mountDisplay = <MountItems platform={this.state.Platform}
sia={this.state.Sia}
hyperspace={this.state.Hyperspace}
changed={this.handleMountLocationChanged}
processAutoMount={!this.state.AutoMountChecked}
autoMountProcessed={this.notifyAutoMountProcessed}
mountDisplay = <MountItems allowConfig={allowConfig}
autoMountChanged={this.handleAutoMountChanged}
mountsBusy={this.notifyMountsBusy}
version={this.state.RepertoryVersion}
autoMountProcessed={this.notifyAutoMountProcessed}
changed={this.handleMountLocationChanged}
configClicked={this.handleConfigClicked}
directory={Constants.DATA_LOCATIONS[this.state.Platform]}
disabled={!allowMount}/>;
disabled={!allowMount}
hyperspace={this.state.Hyperspace}
mountsBusy={this.notifyMountsBusy}
platform={this.state.Platform}
processAutoMount={!this.state.AutoMountChecked}
sia={this.state.Sia}
version={this.state.RepertoryVersion}/>;
}
let dependencyDisplay = null;
if (missingDependencies && !this.state.DownloadActive) {
if (showDependencies) {
dependencyDisplay = (
<Modal>
<DependencyList allowDownload={!this.state.DownloadingDependency}
@@ -478,8 +525,8 @@ class App extends Component {
if (this.state.DownloadActive) {
downloadDisplay = (
<Modal>
<DownloadProgress progress={this.state.DownloadProgress}
display={this.state.DownloadName}/>
<DownloadProgress display={this.state.DownloadName}
progress={this.state.DownloadProgress}/>
</Modal>);
}
@@ -487,19 +534,16 @@ class App extends Component {
if (this.state.ExtractActive) {
releaseDisplay = <h3 style={{textAlign: 'center'}}>{'Activating <' + selectedVersion + '>'}</h3>
} else {
releaseDisplay = <Button disabled={!downloadEnabled}
clicked={this.handleReleaseDownload}>Install</Button>;
releaseDisplay = <Button clicked={this.handleReleaseDownload}
disabled={!downloadEnabled}>Install</Button>;
}
let upgradeDisplay = null;
if (!missingDependencies &&
!this.state.DownloadActive &&
this.state.UpgradeAvailable &&
!this.state.UpgradeDismissed) {
if (showUpgrade) {
upgradeDisplay = (
<Modal>
<UpgradeUI upgrade={this.handleUIDownload}
cancel={()=>this.setState({UpgradeDismissed: true})}/>
<UpgradeUI cancel={()=>this.setState({UpgradeDismissed: true})}
upgrade={this.handleUIDownload}/>
</Modal>
);
}
@@ -510,28 +554,30 @@ class App extends Component {
<table width='100%' cellPadding='2'>
<tbody>
<tr>
<td width='33.33%'>
<td width='33.333%'>
<h2>Release</h2>
</td>
<td width='33.33%'>
<h2>Version<UpgradeIcon release available={this.state.VersionAvailable}/></h2>
<td width='33.333%'>
<h2>Version<UpgradeIcon
release
available={this.state.VersionAvailable}/></h2>
</td>
<td width='33.33%'>
<td width='33.333%'>
<h2>Installed</h2>
</td>
</tr>
<tr>
<td>
<DropDown disabled={this.state.DownloadActive || this.state.ExtractActive || this.state.MountsBusy}
<DropDown changed={this.handleReleaseChanged}
disabled={this.state.DownloadActive || this.state.ExtractActive || this.state.MountsBusy}
items={this.state.ReleaseTypes}
selected={this.state.Release}
changed={this.handleReleaseChanged}/>
selected={this.state.Release}/>
</td>
<td>
<DropDown disabled={this.state.DownloadActive || this.state.ExtractActive || this.state.MountsBusy}
<DropDown changed={this.handleVersionChanged}
disabled={this.state.DownloadActive || this.state.ExtractActive || this.state.MountsBusy}
items={this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]]}
selected={this.state.Version}
changed={this.handleVersionChanged}/>
selected={this.state.Version}/>
</td>
<td>
{this.state.RepertoryVersion}
@@ -558,15 +604,24 @@ class App extends Component {
{dependencyDisplay}
{upgradeDisplay}
{downloadDisplay}
<Box dxDark dxStyle={{height: '9.3%', padding: '2px'}}>
<table cellPadding={0} cellSpacing={0} style={{margin: 0, padding: 0}}>
{configDisplay}
<Box dxStyle={{height: '9.3%', padding: '2px'}}>
<table cellPadding={0}
cellSpacing={0}
style={{margin: 0, padding: 0}}
width="100%">
<tbody style={{margin: 0, padding: 0}}>
<tr style={{margin: 0, padding: 0}}>
<td width='33%' style={{margin: 0, padding: 0}}/>
<td width='33%' style={{margin: 0, padding: 0}}>
<td style={{margin: 0, padding: 0}}
width='33.333%'/>
<td style={{margin: 0, padding: 0}}
width='33.333%'>
<h1 style={{'textAlign': 'center'}}>{'Repertory UI v' + this.props.version}</h1>
</td>
<td width='33%' style={{margin: 0, padding: 0}} align='right' valign='middle'>
<td align='right'
style={{margin: 0, padding: 0}}
valign='middle'
width='33.333%'>
<UpgradeIcon
available={this.state.UpgradeAvailable}
clicked={()=>this.setState({UpgradeDismissed: false})}/>