[Repertory release notification icon] [Prevent release change when mount is busy] [Initial loading animation]

This commit is contained in:
Scott E. Graves
2018-09-26 02:20:11 -05:00
parent 762a7ec6e3
commit 0f12f7e33a
8 changed files with 119 additions and 57 deletions

View File

@@ -12,7 +12,7 @@ import Modal from './components/UI/Modal/Modal';
import DownloadProgress from './components/DownloadProgress/DownloadProgress';
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
import Loading from './components/UI/Loading/Loading';
const Scheduler = require('node-schedule');
let ipcRenderer = null;
@@ -62,12 +62,21 @@ class App extends Component {
const locationsLookup = {
...response.data.Locations[this.state.Platform],
};
const latestVersion = this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]].length - 1;
let version = this.state.Version;
if (version === -1) {
version = latestVersion;
}
this.setState({
AllowOptions: true,
LocationsLookup: locationsLookup,
Version: version,
VersionAvailable: version !== latestVersion,
VersionLookup: versionLookup,
});
this.checkVersionInstalled(this.state.Release, this.state.Version, versionLookup);
this.checkVersionInstalled(this.state.Release, version, versionLookup);
}).catch(error => {
console.log(error);
});
@@ -212,6 +221,7 @@ class App extends Component {
},
LocationsLookup: {},
MissingDependencies: [],
MountsBusy: false,
Platform: 'unknown',
Release: 3,
ReleaseTypes: [
@@ -228,7 +238,8 @@ class App extends Component {
UpgradeAvailable: false,
UpgradeData: {},
UpgradeDismissed: false,
Version: 0,
Version: -1,
VersionAvailable: false,
VersionLookup: {
Alpha: [
'unavailable'
@@ -341,12 +352,13 @@ class App extends Component {
handleReleaseChanged = (e) => {
const val = parseInt(e.target.value, 10);
const versionIndex = this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]].length - 1;
this.setState({
Release: val,
Version: 0
Version: versionIndex
});
this.saveState(val, 0, this.state.Sia, this.state.Hyperspace);
this.checkVersionInstalled(val, 0);
this.saveState(val, versionIndex, this.state.Sia, this.state.Hyperspace);
this.checkVersionInstalled(val, versionIndex);
};
handleReleaseDownload = () => {
@@ -397,6 +409,10 @@ class App extends Component {
notifyAutoMountProcessed = () => {
this.setState({AutoMountChecked: true});
};
notifyMountsBusy = (busy) => {
this.setState({MountsBusy: busy})
};
saveState = (release, version, sia, hyperspace)=> {
if (ipcRenderer) {
@@ -421,8 +437,11 @@ class App extends Component {
};
render() {
const selectedVersion = this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
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)));
const allowMount = this.state.RepertoryVersion !== 'none';
@@ -437,6 +456,7 @@ class App extends Component {
processAutoMount={!this.state.AutoMountChecked}
autoMountProcessed={this.notifyAutoMountProcessed}
autoMountChanged={this.handleAutoMountChanged}
mountsBusy={this.notifyMountsBusy}
version={this.state.RepertoryVersion}
directory={Constants.DATA_LOCATIONS[this.state.Platform]}
disabled={!allowMount}/>;
@@ -484,51 +504,53 @@ class App extends Component {
);
}
let options = null;
let mainContent = null;
if (this.state.AllowOptions) {
options = (
mainContent = (
<table width='100%' cellPadding='2'>
<tbody>
<tr>
<td width='33%'>
<h2>Release</h2>
</td>
<td width='33%'>
<h2>Version</h2>
</td>
<td width='33%'>
<h2>Installed</h2>
</td>
</tr>
<tr>
<td>
<DropDown disabled={this.state.DownloadActive || this.state.ExtractActive}
items={this.state.ReleaseTypes}
selected={this.state.Release}
changed={this.handleReleaseChanged}/>
</td>
<td>
<DropDown disabled={this.state.DownloadActive || this.state.ExtractActive}
items={this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]]}
selected={this.state.Version}
changed={this.handleVersionChanged}/>
</td>
<td>
{this.state.RepertoryVersion}
</td>
</tr>
<tr>
<td colSpan={3}>
{releaseDisplay}
</td>
</tr>
<tr>
<td colSpan={3}>
{mountDisplay}
</td>
</tr>
<tr>
<td width='33.33%'>
<h2>Release</h2>
</td>
<td width='33.33%'>
<h2>Version<UpgradeIcon release available={this.state.VersionAvailable}/></h2>
</td>
<td width='33.33%'>
<h2>Installed</h2>
</td>
</tr>
<tr>
<td>
<DropDown disabled={this.state.DownloadActive || this.state.ExtractActive || this.state.MountsBusy}
items={this.state.ReleaseTypes}
selected={this.state.Release}
changed={this.handleReleaseChanged}/>
</td>
<td>
<DropDown 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}/>
</td>
<td>
{this.state.RepertoryVersion}
</td>
</tr>
<tr>
<td colSpan={3}>
{releaseDisplay}
</td>
</tr>
<tr>
<td colSpan={3}>
{mountDisplay}
</td>
</tr>
</tbody>
</table>);
} else {
mainContent = <Loading/>
}
return (
@@ -536,7 +558,7 @@ class App extends Component {
{dependencyDisplay}
{upgradeDisplay}
{downloadDisplay}
<Box dxDark dxStyle={{'height': 'auto', 'padding': '2px'}}>
<Box dxDark dxStyle={{height: '9.3%', padding: '2px'}}>
<table cellPadding={0} cellSpacing={0} style={{margin: 0, padding: 0}}>
<tbody style={{margin: 0, padding: 0}}>
<tr style={{margin: 0, padding: 0}}>
@@ -553,8 +575,8 @@ class App extends Component {
</tbody>
</table>
</Box>
<Box dxStyle={{'padding': '4px', 'marginTop': '10px'}}>
{options}
<Box dxStyle={{padding: '4px', marginTop: '10px', height: '90.7%'}}>
{mainContent}
</Box>
</div>
);