Redux changes and refactoring
This commit is contained in:
42
src/App.js
42
src/App.js
@@ -16,9 +16,9 @@ import Text from './components/UI/Text/Text';
|
|||||||
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
|
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
|
||||||
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
|
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
|
||||||
import {setProviderState} from './redux/actions/mount_actions';
|
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 {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';
|
import {notifyError} from './redux/actions/error_actions';
|
||||||
|
|
||||||
const Constants = require('./constants');
|
const Constants = require('./constants');
|
||||||
@@ -32,11 +32,6 @@ class App extends IPCContainer {
|
|||||||
this.setRequestHandler(Constants.IPC_Get_State_Reply, this.onGetStateReply);
|
this.setRequestHandler(Constants.IPC_Get_State_Reply, this.onGetStateReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
|
||||||
MissingDependencies: [],
|
|
||||||
InstalledVersion: 'none',
|
|
||||||
};
|
|
||||||
|
|
||||||
checkVersionInstalled = () => {
|
checkVersionInstalled = () => {
|
||||||
this.props.setAllowDownload(false);
|
this.props.setAllowDownload(false);
|
||||||
const selectedVersion = this.getSelectedVersion();
|
const selectedVersion = this.getSelectedVersion();
|
||||||
@@ -152,11 +147,8 @@ class App extends IPCContainer {
|
|||||||
}
|
}
|
||||||
this.props.setReleaseUpgradeAvailable(upgradeAvailable);
|
this.props.setReleaseUpgradeAvailable(upgradeAvailable);
|
||||||
this.props.setAllowDownload(true);
|
this.props.setAllowDownload(true);
|
||||||
|
this.props.setInstalledVersion(installedVersion);
|
||||||
this.setState({
|
this.props.setMissingDependencies(arg.data.Dependencies);
|
||||||
MissingDependencies: arg.data.Dependencies,
|
|
||||||
InstalledVersion: installedVersion,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (arg.data.Success) {
|
if (arg.data.Success) {
|
||||||
@@ -258,7 +250,7 @@ class App extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
waitForDependencyInstall = (source, url) => {
|
waitForDependencyInstall = (source, url) => {
|
||||||
const dep = this.state.MissingDependencies.find(d => {
|
const dep = this.props.MissingDependencies.find(d => {
|
||||||
return d.download === url;
|
return d.download === url;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -285,10 +277,10 @@ class App extends IPCContainer {
|
|||||||
!this.props.MountsBusy &&
|
!this.props.MountsBusy &&
|
||||||
!this.props.DownloadActive &&
|
!this.props.DownloadActive &&
|
||||||
(selectedVersion !== 'unavailable') &&
|
(selectedVersion !== 'unavailable') &&
|
||||||
(selectedVersion !== this.state.InstalledVersion);
|
(selectedVersion !== this.props.InstalledVersion);
|
||||||
|
|
||||||
const missingDependencies = (this.state.MissingDependencies.length > 0);
|
const missingDependencies = (this.props.MissingDependencies.length > 0);
|
||||||
const allowMount = this.state.InstalledVersion !== 'none' &&
|
const allowMount = this.props.InstalledVersion !== 'none' &&
|
||||||
!missingDependencies &&
|
!missingDependencies &&
|
||||||
!this.props.InstallActive;
|
!this.props.InstallActive;
|
||||||
|
|
||||||
@@ -337,9 +329,7 @@ class App extends IPCContainer {
|
|||||||
if (showDependencies) {
|
if (showDependencies) {
|
||||||
dependencyDisplay = (
|
dependencyDisplay = (
|
||||||
<Modal>
|
<Modal>
|
||||||
<DependencyList allowDownload={this.props.DownloadType !== Constants.INSTALL_TYPES.Dependency}
|
<DependencyList onDownload={this.handleDownloadDependency}/>
|
||||||
dependencies={this.state.MissingDependencies}
|
|
||||||
onDownload={this.handleDownloadDependency}/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -368,11 +358,8 @@ class App extends IPCContainer {
|
|||||||
mainContent.push((
|
mainContent.push((
|
||||||
<div key={'rvd_' + key++}
|
<div key={'rvd_' + key++}
|
||||||
style={{height: '32%'}}>
|
style={{height: '32%'}}>
|
||||||
<ReleaseVersionDisplay disabled={this.props.DownloadActive || this.props.InstallActive || this.props.MountsBusy}
|
<ReleaseVersionDisplay downloadClicked={this.handleDownloadRelease}
|
||||||
downloadClicked={this.handleDownloadRelease}
|
downloadDisabled={!downloadEnabled}/>
|
||||||
downloadDisabled={!downloadEnabled}
|
|
||||||
releaseExtracting={this.props.InstallType === Constants.INSTALL_TYPES.Release}
|
|
||||||
text={this.state.InstalledVersion + ' [' + this.props.AppPlatform + ']'}/>
|
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -381,8 +368,7 @@ class App extends IPCContainer {
|
|||||||
<div key={'md_' + key++}>
|
<div key={'md_' + key++}>
|
||||||
<MountItems allowConfig={allowConfig}
|
<MountItems allowConfig={allowConfig}
|
||||||
allowSiaPrime={allowSiaPrime}
|
allowSiaPrime={allowSiaPrime}
|
||||||
noConsoleSupported={noConsoleSupported}
|
noConsoleSupported={noConsoleSupported}/>
|
||||||
version={this.state.InstalledVersion}/>
|
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -440,7 +426,9 @@ const mapStateToProps = state => {
|
|||||||
DownloadType: state.download.DownloadType,
|
DownloadType: state.download.DownloadType,
|
||||||
InstallActive: state.install.InstallActive,
|
InstallActive: state.install.InstallActive,
|
||||||
InstallType: state.install.InstallType,
|
InstallType: state.install.InstallType,
|
||||||
|
InstalledVersion: state.relver.InstalledVersion,
|
||||||
LocationsLookup: state.relver.LocationsLookup,
|
LocationsLookup: state.relver.LocationsLookup,
|
||||||
|
MissingDependencies: state.install.MissingDependencies,
|
||||||
MountsBusy: state.mounts.MountsBusy,
|
MountsBusy: state.mounts.MountsBusy,
|
||||||
Platform: state.common.Platform,
|
Platform: state.common.Platform,
|
||||||
ProviderState: state.mounts.ProviderState,
|
ProviderState: state.mounts.ProviderState,
|
||||||
@@ -466,6 +454,8 @@ const mapDispatchToProps = dispatch => {
|
|||||||
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
|
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
|
||||||
setAllowDownload: allow => dispatch(setAllowDownload(allow)),
|
setAllowDownload: allow => dispatch(setAllowDownload(allow)),
|
||||||
setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)),
|
setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)),
|
||||||
|
setInstalledVersion: version => dispatch(setInstalledVersion(version)),
|
||||||
|
setMissingDependencies: dependencies => dispatch(setMissingDependencies(dependencies)),
|
||||||
setProviderState: (provider, state) => dispatch(setProviderState(provider, state)),
|
setProviderState: (provider, state) => dispatch(setProviderState(provider, state)),
|
||||||
setReleaseUpgradeAvailable: available => dispatch(setReleaseUpgradeAvailable(available)),
|
setReleaseUpgradeAvailable: available => dispatch(setReleaseUpgradeAvailable(available)),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './Dependency.css';
|
import './Dependency.css';
|
||||||
|
import {connect} from 'react-redux';
|
||||||
|
import * as Constants from '../../../constants';
|
||||||
|
|
||||||
export default props => {
|
const mapStateToProps = state => {
|
||||||
|
return {
|
||||||
|
AllowDownload: (state.download.DownloadType !== Constants.INSTALL_TYPES.Dependency),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(props => {
|
||||||
return (
|
return (
|
||||||
<div className={'Dependency'}>
|
<div className={'Dependency'}>
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
@@ -11,7 +19,7 @@ export default props => {
|
|||||||
<h3>{props.name}</h3>
|
<h3>{props.name}</h3>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{props.allowDownload ?
|
{props.AllowDownload ?
|
||||||
<a href={void(0)} className={'DependencyLink'} onClick={()=>{props.onDownload(props.download); return false;}}><u>Install</u></a> :
|
<a href={void(0)} className={'DependencyLink'} onClick={()=>{props.onDownload(props.download); return false;}}><u>Install</u></a> :
|
||||||
'Installing...'}
|
'Installing...'}
|
||||||
</td>
|
</td>
|
||||||
@@ -20,4 +28,4 @@ export default props => {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './DependencyList.css';
|
import './DependencyList.css';
|
||||||
|
import {connect} from 'react-redux';
|
||||||
import Dependency from './Dependency/Dependency';
|
import Dependency from './Dependency/Dependency';
|
||||||
import Box from '../UI/Box/Box';
|
import Box from '../UI/Box/Box';
|
||||||
|
|
||||||
export default props => {
|
const mapStateToProps = state => {
|
||||||
const items = props.dependencies.map((k, i)=> {
|
return {
|
||||||
|
MissingDependencies: state.install.MissingDependencies,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(props => {
|
||||||
|
const items = props.MissingDependencies.map((k, i)=> {
|
||||||
return (
|
return (
|
||||||
<Dependency allowDownload={props.allowDownload}
|
<Dependency download={k.download}
|
||||||
download={k.download}
|
|
||||||
key={i}
|
key={i}
|
||||||
name={k.display}
|
name={k.display}
|
||||||
onDownload={props.onDownload}/>
|
onDownload={props.onDownload}/>
|
||||||
@@ -22,5 +28,4 @@ export default props => {
|
|||||||
{items}
|
{items}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
});
|
||||||
};
|
|
||||||
@@ -11,6 +11,12 @@ import {setActiveRelease} from "../../redux/actions/release_version_actions";
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
|
AppPlatform: state.common.AppPlatform,
|
||||||
|
DownloadActive: state.download.DownloadActive,
|
||||||
|
InstallActive: state.install.InstallActive,
|
||||||
|
InstallType: state.install.InstallType,
|
||||||
|
InstalledVersion: state.relver.InstalledVersion,
|
||||||
|
MountsBusy: state.mounts.MountsBusy,
|
||||||
Release: state.relver.Release,
|
Release: state.relver.Release,
|
||||||
ReleaseUpgradeAvailable: state.relver.ReleaseUpgradeAvailable,
|
ReleaseUpgradeAvailable: state.relver.ReleaseUpgradeAvailable,
|
||||||
ReleaseVersion: state.relver.Version,
|
ReleaseVersion: state.relver.Version,
|
||||||
@@ -35,9 +41,13 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
|||||||
props.setActiveRelease(props.Release, parseInt(e.target.value, 10));
|
props.setActiveRelease(props.Release, parseInt(e.target.value, 10));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const text = props.InstalledVersion + ' [' + props.AppPlatform + ']';
|
||||||
|
const disabled = props.DownloadActive || props.InstallActive || props.MountsBusy;
|
||||||
|
const releaseExtracting = (props.InstallType === Constants.INSTALL_TYPES.Release);
|
||||||
|
|
||||||
let optionsDisplay = [];
|
let optionsDisplay = [];
|
||||||
let key = 0;
|
let key = 0;
|
||||||
if (props.releaseExtracting) {
|
if (releaseExtracting) {
|
||||||
optionsDisplay.push((
|
optionsDisplay.push((
|
||||||
<Text col={dimensions => (dimensions.columns / 3) * 2}
|
<Text col={dimensions => (dimensions.columns / 3) * 2}
|
||||||
colSpan={'remain'}
|
colSpan={'remain'}
|
||||||
@@ -53,7 +63,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
|||||||
key={key++}
|
key={key++}
|
||||||
row={5}
|
row={5}
|
||||||
rowSpan={7}
|
rowSpan={7}
|
||||||
text={props.text}
|
text={text}
|
||||||
textAlign={'left'}/>
|
textAlign={'left'}/>
|
||||||
));
|
));
|
||||||
} else if (props.downloadDisabled) {
|
} else if (props.downloadDisabled) {
|
||||||
@@ -73,7 +83,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
|||||||
key={key++}
|
key={key++}
|
||||||
row={5}
|
row={5}
|
||||||
rowSpan={7}
|
rowSpan={7}
|
||||||
text={props.text}
|
text={text}
|
||||||
textAlign={'left'}/>
|
textAlign={'left'}/>
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
@@ -97,7 +107,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
|||||||
type={'Heading2'}/>
|
type={'Heading2'}/>
|
||||||
<DropDown changed={handleReleaseChanged}
|
<DropDown changed={handleReleaseChanged}
|
||||||
colSpan={remain=>remain / 3 - 1}
|
colSpan={remain=>remain / 3 - 1}
|
||||||
disabled={props.disabled}
|
disabled={disabled}
|
||||||
items={Constants.RELEASE_TYPES}
|
items={Constants.RELEASE_TYPES}
|
||||||
row={5}
|
row={5}
|
||||||
rowSpan={7}
|
rowSpan={7}
|
||||||
@@ -116,7 +126,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
|||||||
<DropDown changed={handleVersionChanged}
|
<DropDown changed={handleVersionChanged}
|
||||||
col={dimensions => dimensions.columns / 3}
|
col={dimensions => dimensions.columns / 3}
|
||||||
colSpan={remain=>remain / 2 - 1}
|
colSpan={remain=>remain / 2 - 1}
|
||||||
disabled={props.disabled}
|
disabled={disabled}
|
||||||
items={props.VersionLookup[Constants.RELEASE_TYPES[props.Release]]}
|
items={props.VersionLookup[Constants.RELEASE_TYPES[props.Release]]}
|
||||||
row={5}
|
row={5}
|
||||||
rowSpan={7}
|
rowSpan={7}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class MountItems extends IPCContainer {
|
|||||||
if (!this.state.DisplayRetry) {
|
if (!this.state.DisplayRetry) {
|
||||||
this.props.setMountsBusy(true);
|
this.props.setMountsBusy(true);
|
||||||
this.sendRequest(Constants.IPC_Detect_Mounts, {
|
this.sendRequest(Constants.IPC_Detect_Mounts, {
|
||||||
Version: this.props.version,
|
Version: this.props.InstalledVersion,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -108,7 +108,7 @@ class MountItems extends IPCContainer {
|
|||||||
if (mount) {
|
if (mount) {
|
||||||
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
Version: this.props.version
|
Version: this.props.InstalledVersion
|
||||||
}).data;
|
}).data;
|
||||||
if (result.Success) {
|
if (result.Success) {
|
||||||
if (result.Valid) {
|
if (result.Valid) {
|
||||||
@@ -146,13 +146,13 @@ class MountItems extends IPCContainer {
|
|||||||
Location: location,
|
Location: location,
|
||||||
NoConsoleSupported: this.props.noConsoleSupported,
|
NoConsoleSupported: this.props.noConsoleSupported,
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
Version: this.props.version,
|
Version: this.props.InstalledVersion,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.sendRequest(Constants.IPC_Unmount_Drive, {
|
this.sendRequest(Constants.IPC_Unmount_Drive, {
|
||||||
Location: location,
|
Location: location,
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
Version: this.props.version,
|
Version: this.props.InstalledVersion,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,6 +309,7 @@ class MountItems extends IPCContainer {
|
|||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
AutoMountProcessed: state.mounts.AutoMountProcessed,
|
AutoMountProcessed: state.mounts.AutoMountProcessed,
|
||||||
|
InstalledVersion: state.relver.InstalledVersion,
|
||||||
MountState: state.mounts.MountState,
|
MountState: state.mounts.MountState,
|
||||||
Platform: state.common.Platform,
|
Platform: state.common.Platform,
|
||||||
ProviderState: state.mounts.ProviderState,
|
ProviderState: state.mounts.ProviderState,
|
||||||
|
|||||||
@@ -78,3 +78,4 @@ export const installUpgrade = (source, sha256, signature, skipVerification, comp
|
|||||||
|
|
||||||
export const setInstallActive = createAction('install/setInstallActive');
|
export const setInstallActive = createAction('install/setInstallActive');
|
||||||
export const setInstallComplete = createAction('install/setInstallComplete');
|
export const setInstallComplete = createAction('install/setInstallComplete');
|
||||||
|
export const setMissingDependencies = createAction('install/setMissingDependencies');
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ export const setActiveRelease = (release, version) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const setDismissUIUpgrade = createAction('relver/setDismissUIUpgrade');
|
export const setDismissUIUpgrade = createAction('relver/setDismissUIUpgrade');
|
||||||
|
export const setInstalledVersion = createAction('relver/setInstalledVersion');
|
||||||
|
|
||||||
export const SET_RELEASE_DATA = 'relver/setReleaseData';
|
export const SET_RELEASE_DATA = 'relver/setReleaseData';
|
||||||
export const setReleaseData = (locationsLookup, versionLookup)=> {
|
export const setReleaseData = (locationsLookup, versionLookup)=> {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import {createReducer} from 'redux-starter-kit';
|
import {createReducer} from 'redux-starter-kit';
|
||||||
import {setInstallActive, setInstallComplete} from '../actions/install_actions';
|
import {setInstallActive, setInstallComplete, setMissingDependencies} from '../actions/install_actions';
|
||||||
|
|
||||||
export const installReducer = createReducer({
|
export const installReducer = createReducer({
|
||||||
InstallActive: false,
|
InstallActive: false,
|
||||||
InstallResult: null,
|
InstallResult: null,
|
||||||
InstallType: null,
|
InstallType: null,
|
||||||
|
MissingDependencies: [],
|
||||||
}, {
|
}, {
|
||||||
[setInstallActive]: (state, action) => {
|
[setInstallActive]: (state, action) => {
|
||||||
return {
|
return {
|
||||||
@@ -21,5 +22,11 @@ export const installReducer = createReducer({
|
|||||||
InstallResult: action.payload,
|
InstallResult: action.payload,
|
||||||
InstallType: null,
|
InstallType: null,
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
[setMissingDependencies]: (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
MissingDependencies: action.payload,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -14,6 +14,7 @@ const versionLookup = Constants.RELEASE_TYPES.map(k=> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const releaseVersionReducer = createReducer({
|
export const releaseVersionReducer = createReducer({
|
||||||
|
InstalledVersion: 'none',
|
||||||
LocationsLookup: {},
|
LocationsLookup: {},
|
||||||
Release: 2,
|
Release: 2,
|
||||||
ReleaseUpgradeAvailable: false,
|
ReleaseUpgradeAvailable: false,
|
||||||
@@ -43,6 +44,12 @@ export const releaseVersionReducer = createReducer({
|
|||||||
UpgradeDismissed: action.payload,
|
UpgradeDismissed: action.payload,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
[Actions.setInstalledVersion]: (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
InstalledVersion: action.payload,
|
||||||
|
}
|
||||||
|
},
|
||||||
[Actions.SET_RELEASE_DATA]: (state, action) => {
|
[Actions.SET_RELEASE_DATA]: (state, action) => {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
Reference in New Issue
Block a user