Redux changes and refactoring

This commit is contained in:
Scott E. Graves
2019-06-07 23:13:05 -05:00
parent 6499ff4f79
commit 4b93c298c2
9 changed files with 75 additions and 45 deletions

View File

@@ -16,9 +16,9 @@ import Text from './components/UI/Text/Text';
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
import {setProviderState} from './redux/actions/mount_actions';
import {detectUIUpgrade, loadReleases, setActiveRelease, setDismissUIUpgrade, setReleaseUpgradeAvailable} from './redux/actions/release_version_actions';
import {detectUIUpgrade, loadReleases, setActiveRelease, setDismissUIUpgrade, setInstalledVersion, setReleaseUpgradeAvailable} from './redux/actions/release_version_actions';
import {downloadItem, setAllowDownload} from './redux/actions/download_actions';
import {installDependency, installRelease, installUpgrade} from './redux/actions/install_actions';
import {installDependency, installRelease, installUpgrade, setMissingDependencies} from './redux/actions/install_actions';
import {notifyError} from './redux/actions/error_actions';
const Constants = require('./constants');
@@ -32,11 +32,6 @@ class App extends IPCContainer {
this.setRequestHandler(Constants.IPC_Get_State_Reply, this.onGetStateReply);
}
state = {
MissingDependencies: [],
InstalledVersion: 'none',
};
checkVersionInstalled = () => {
this.props.setAllowDownload(false);
const selectedVersion = this.getSelectedVersion();
@@ -152,11 +147,8 @@ class App extends IPCContainer {
}
this.props.setReleaseUpgradeAvailable(upgradeAvailable);
this.props.setAllowDownload(true);
this.setState({
MissingDependencies: arg.data.Dependencies,
InstalledVersion: installedVersion,
});
this.props.setInstalledVersion(installedVersion);
this.props.setMissingDependencies(arg.data.Dependencies);
};
if (arg.data.Success) {
@@ -258,7 +250,7 @@ class App extends IPCContainer {
};
waitForDependencyInstall = (source, url) => {
const dep = this.state.MissingDependencies.find(d => {
const dep = this.props.MissingDependencies.find(d => {
return d.download === url;
});
@@ -285,10 +277,10 @@ class App extends IPCContainer {
!this.props.MountsBusy &&
!this.props.DownloadActive &&
(selectedVersion !== 'unavailable') &&
(selectedVersion !== this.state.InstalledVersion);
(selectedVersion !== this.props.InstalledVersion);
const missingDependencies = (this.state.MissingDependencies.length > 0);
const allowMount = this.state.InstalledVersion !== 'none' &&
const missingDependencies = (this.props.MissingDependencies.length > 0);
const allowMount = this.props.InstalledVersion !== 'none' &&
!missingDependencies &&
!this.props.InstallActive;
@@ -337,9 +329,7 @@ class App extends IPCContainer {
if (showDependencies) {
dependencyDisplay = (
<Modal>
<DependencyList allowDownload={this.props.DownloadType !== Constants.INSTALL_TYPES.Dependency}
dependencies={this.state.MissingDependencies}
onDownload={this.handleDownloadDependency}/>
<DependencyList onDownload={this.handleDownloadDependency}/>
</Modal>
);
}
@@ -368,11 +358,8 @@ class App extends IPCContainer {
mainContent.push((
<div key={'rvd_' + key++}
style={{height: '32%'}}>
<ReleaseVersionDisplay disabled={this.props.DownloadActive || this.props.InstallActive || this.props.MountsBusy}
downloadClicked={this.handleDownloadRelease}
downloadDisabled={!downloadEnabled}
releaseExtracting={this.props.InstallType === Constants.INSTALL_TYPES.Release}
text={this.state.InstalledVersion + ' [' + this.props.AppPlatform + ']'}/>
<ReleaseVersionDisplay downloadClicked={this.handleDownloadRelease}
downloadDisabled={!downloadEnabled}/>
</div>
));
@@ -381,8 +368,7 @@ class App extends IPCContainer {
<div key={'md_' + key++}>
<MountItems allowConfig={allowConfig}
allowSiaPrime={allowSiaPrime}
noConsoleSupported={noConsoleSupported}
version={this.state.InstalledVersion}/>
noConsoleSupported={noConsoleSupported}/>
</div>
));
}
@@ -440,7 +426,9 @@ const mapStateToProps = state => {
DownloadType: state.download.DownloadType,
InstallActive: state.install.InstallActive,
InstallType: state.install.InstallType,
InstalledVersion: state.relver.InstalledVersion,
LocationsLookup: state.relver.LocationsLookup,
MissingDependencies: state.install.MissingDependencies,
MountsBusy: state.mounts.MountsBusy,
Platform: state.common.Platform,
ProviderState: state.mounts.ProviderState,
@@ -466,6 +454,8 @@ const mapDispatchToProps = dispatch => {
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
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)),
};