Continue move to redux
This commit is contained in:
77
src/App.js
77
src/App.js
@@ -16,6 +16,7 @@ import Text from './components/UI/Text/Text';
|
||||
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
|
||||
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
|
||||
import IPCContainer from './containers/IPCContainer/IPCContainer';
|
||||
import {detectUIUpgrade, setDismissUIUpgrade} from './redux/actions/release_version_actions';
|
||||
|
||||
const Constants = require('./constants');
|
||||
const Scheduler = require('node-schedule');
|
||||
@@ -38,7 +39,6 @@ class App extends IPCContainer {
|
||||
this.setRequestHandler(Constants.IPC_Extract_Release_Complete, this.onExtractReleaseComplete);
|
||||
this.setRequestHandler(Constants.IPC_Get_State_Reply, this.onGetStateReply);
|
||||
this.setRequestHandler(Constants.IPC_Grab_Releases_Reply, this.onGrabReleasesReply);
|
||||
this.setRequestHandler(Constants.IPC_Grab_UI_Releases_Reply, this.onGrabUiReleasesReply);
|
||||
this.setRequestHandler(Constants.IPC_Install_Dependency_Reply, this.onInstallDependencyReply);
|
||||
this.setRequestHandler(Constants.IPC_Install_Upgrade_Reply, this.onInstallUpgradeReply);
|
||||
|
||||
@@ -63,16 +63,7 @@ class App extends IPCContainer {
|
||||
LocationsLookup: {},
|
||||
MissingDependencies: [],
|
||||
Release: 2,
|
||||
ReleaseTypes: [
|
||||
'Release',
|
||||
'RC',
|
||||
'Beta',
|
||||
'Alpha',
|
||||
],
|
||||
InstalledVersion: 'none',
|
||||
UpgradeAvailable: false,
|
||||
UpgradeData: {},
|
||||
UpgradeDismissed: false,
|
||||
Version: -1,
|
||||
VersionAvailable: false,
|
||||
VersionLookup: {
|
||||
@@ -149,13 +140,13 @@ class App extends IPCContainer {
|
||||
};
|
||||
|
||||
getSelectedVersion = () => {
|
||||
return this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
|
||||
return this.state.VersionLookup[Constants.RELEASE_TYPES[this.state.Release]][this.state.Version];
|
||||
};
|
||||
|
||||
grabReleases = () => {
|
||||
if (this.props.AppPlatform !== 'unknown') {
|
||||
this.sendRequest(Constants.IPC_Grab_Releases);
|
||||
this.sendRequest(Constants.IPC_Grab_UI_Releases);
|
||||
this.props.detectUIUpgrade();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -210,7 +201,7 @@ class App extends IPCContainer {
|
||||
|
||||
handleReleaseChanged = (e) => {
|
||||
const val = parseInt(e.target.value, 10);
|
||||
const versionIndex = this.state.VersionLookup[this.state.ReleaseTypes[val]].length - 1;
|
||||
const versionIndex = this.state.VersionLookup[Constants.RELEASE_TYPES[val]].length - 1;
|
||||
this.setState({
|
||||
Release: val,
|
||||
Version: versionIndex
|
||||
@@ -241,7 +232,7 @@ class App extends IPCContainer {
|
||||
DownloadingUpgrade: true,
|
||||
DownloadName: 'UI Upgrade',
|
||||
}, ()=> {
|
||||
const url = this.state.UpgradeData.urls[0];
|
||||
const url = this.props.UpgradeData.urls[0];
|
||||
this.sendRequest(Constants.IPC_Download_File, {
|
||||
Filename: this.props.Platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
|
||||
URL: url,
|
||||
@@ -300,7 +291,7 @@ class App extends IPCContainer {
|
||||
let versionAvailable = false;
|
||||
|
||||
if (installedVersion !== 'none') {
|
||||
const latestVersion = this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]].length - 1;
|
||||
const latestVersion = this.state.VersionLookup[Constants.RELEASE_TYPES[this.state.Release]].length - 1;
|
||||
let version = this.state.Version;
|
||||
if (version === -1) {
|
||||
version = latestVersion;
|
||||
@@ -386,9 +377,9 @@ class App extends IPCContainer {
|
||||
|
||||
onGrabReleasesReply = ()=> {
|
||||
const doUpdate = (locationsLookup, versionLookup) => {
|
||||
const latestVersion = versionLookup[this.state.ReleaseTypes[this.state.Release]].length - 1;
|
||||
const latestVersion = versionLookup[Constants.RELEASE_TYPES[this.state.Release]].length - 1;
|
||||
let version = this.state.Version;
|
||||
if ((version === -1) || !versionLookup[this.state.ReleaseTypes[this.state.Release]][version]) {
|
||||
if ((version === -1) || !versionLookup[Constants.RELEASE_TYPES[this.state.Release]][version]) {
|
||||
version = latestVersion;
|
||||
this.saveState(version);
|
||||
}
|
||||
@@ -437,29 +428,6 @@ class App extends IPCContainer {
|
||||
});
|
||||
};
|
||||
|
||||
onGrabUiReleasesReply = ()=> {
|
||||
axios
|
||||
.get(Constants.UI_RELEASES_URL)
|
||||
.then(response => {
|
||||
const data = response.data;
|
||||
if (data.Versions &&
|
||||
data.Versions[this.props.AppPlatform] &&
|
||||
(data.Versions[this.props.AppPlatform].length > 0) &&
|
||||
(data.Versions[this.props.AppPlatform][0] !== this.props.version)) {
|
||||
this.setState({
|
||||
UpgradeAvailable: true,
|
||||
UpgradeDismissed: false,
|
||||
UpgradeData: data.Locations[this.props.AppPlatform][data.Versions[this.props.AppPlatform][0]],
|
||||
});
|
||||
}
|
||||
}).catch(() => {
|
||||
this.setState({
|
||||
UpgradeAvailable: false,
|
||||
UpgradeData: {},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
onInstallDependencyReply = (event, arg) => {
|
||||
if (arg.data.Success && arg.data.Source.toLowerCase().endsWith('.dmg')) {
|
||||
this.waitForDependencyInstall(arg.data.URL);
|
||||
@@ -572,11 +540,11 @@ class App extends IPCContainer {
|
||||
this.props.DisplayConfiguration &&
|
||||
allowConfig;
|
||||
|
||||
const showUpgrade = this.state.UpgradeAvailable &&
|
||||
const showUpgrade = this.props.UpgradeAvailable &&
|
||||
!this.state.DisplayError &&
|
||||
!showConfig &&
|
||||
!this.state.DownloadActive &&
|
||||
!this.state.UpgradeDismissed;
|
||||
!this.props.UpgradeDismissed;
|
||||
|
||||
const showDependencies = !showUpgrade &&
|
||||
missingDependencies &&
|
||||
@@ -628,8 +596,7 @@ class App extends IPCContainer {
|
||||
if (showUpgrade) {
|
||||
upgradeDisplay = (
|
||||
<Modal>
|
||||
<UpgradeUI cancel={()=>this.setState({UpgradeDismissed: true})}
|
||||
upgrade={this.handleUIDownload}/>
|
||||
<UpgradeUI upgrade={this.handleUIDownload}/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -647,11 +614,10 @@ class App extends IPCContainer {
|
||||
release={this.state.Release}
|
||||
releaseChanged={this.handleReleaseChanged}
|
||||
releaseExtracting={this.state.ExtractActive}
|
||||
releaseTypes={this.state.ReleaseTypes}
|
||||
version={this.state.Version}
|
||||
versionAvailable={this.state.VersionAvailable}
|
||||
versionChanged={this.handleVersionChanged}
|
||||
versions={this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]]}/>
|
||||
versions={this.state.VersionLookup[Constants.RELEASE_TYPES[this.state.Release]]}/>
|
||||
</div>
|
||||
));
|
||||
|
||||
@@ -694,12 +660,12 @@ class App extends IPCContainer {
|
||||
colSpan={'remain'}
|
||||
row={0}
|
||||
rowSpan={'remain'}
|
||||
text={'Repertory UI v' + this.props.version}
|
||||
text={'Repertory UI v' + this.props.Version}
|
||||
textAlign={'center'}
|
||||
type={'Heading1'}/>
|
||||
<UpgradeIcon
|
||||
available={this.state.UpgradeAvailable}
|
||||
clicked={()=>this.setState({UpgradeDismissed: false})}
|
||||
available={this.props.UpgradeAvailable}
|
||||
clicked={()=>this.props.setDismissUIUpgrade(false)}
|
||||
col={dimensions => dimensions.columns - 6}
|
||||
colSpan={5}
|
||||
row={1}
|
||||
@@ -724,7 +690,18 @@ const mapStateToProps = state => {
|
||||
DisplayConfiguration: state.mounts.DisplayConfiguration,
|
||||
MountsBusy: state.mounts.MountsBusy,
|
||||
Platform: state.common.Platform,
|
||||
UpgradeAvailable: state.relver.UpgradeAvailable,
|
||||
UpgradeData: state.relver.UpgradeData,
|
||||
UpgradeDismissed: state.relver.UpgradeDismissed,
|
||||
Version: state.common.Version,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(App);
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
detectUIUpgrade: () => dispatch(detectUIUpgrade()),
|
||||
setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(App);
|
||||
|
||||
Reference in New Issue
Block a user