Refactoring

This commit is contained in:
Scott E. Graves
2019-07-15 14:54:28 -05:00
parent d7759402f6
commit f006beb8d9
14 changed files with 261 additions and 355 deletions

View File

@@ -25,7 +25,7 @@ export default connect(mapStateToProps)(props => {
<a
href={void(0)}
className={'DependencyLink'}
onClick={()=>{props.onDownload(props.download); return false;}}><u>Install</u></a> :
onClick={()=>{props.onDownload(); return false;}}><u>Install</u></a> :
'Installing...'}
</td>
</tr>

View File

@@ -1,8 +1,11 @@
import React from 'react';
import './DependencyList.css';
import {connect} from 'react-redux';
import * as Constants from '../../constants';
import Dependency from './Dependency/Dependency';
import Box from '../UI/Box/Box';
import {downloadItem} from '../../redux/actions/download_actions';
import {extractFileNameFromURL} from '../../utils';
const mapStateToProps = state => {
return {
@@ -10,13 +13,18 @@ const mapStateToProps = state => {
};
};
export default connect(mapStateToProps)(props => {
const mapDispatchToProps = (dispatch) => {
return {
downloadItem: (name, type, url) => dispatch(downloadItem(name, type, url))
};
};
export default connect(mapStateToProps, mapDispatchToProps)(props => {
const items = props.MissingDependencies.map((k, i)=> {
return (
<Dependency download={k.download}
key={i}
<Dependency key={i}
name={k.display}
onDownload={props.onDownload}/>
onDownload={()=>props.downloadItem(extractFileNameFromURL(k.download), Constants.INSTALL_TYPES.Dependency, k.download)}/>
);
});

View File

@@ -8,6 +8,7 @@ import Text from '../UI/Text/Text';
import Button from '../UI/Button/Button';
import UpgradeIcon from '../UpgradeIcon/UpgradeIcon';
import {setActiveRelease} from "../../redux/actions/release_version_actions";
import {downloadItem} from '../../redux/actions/download_actions';
const mapStateToProps = state => {
return {
@@ -16,6 +17,7 @@ const mapStateToProps = state => {
InstallActive: state.install.InstallActive,
InstallType: state.install.InstallType,
InstalledVersion: state.relver.InstalledVersion,
LocationsLookup: state.relver.LocationsLookup,
MountsBusy: state.mounts.MountsBusy,
Release: state.relver.Release,
ReleaseUpgradeAvailable: state.relver.ReleaseUpgradeAvailable,
@@ -26,11 +28,17 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
downloadItem: (name, type, urls) => dispatch(downloadItem(name, type, urls)),
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
}
};
export default connect(mapStateToProps, mapDispatchToProps)(props => {
const handleDownloadRelease = () => {
const fileName = props.version + '.zip';
props.downloadItem(fileName, Constants.INSTALL_TYPES.Release, props.LocationsLookup[props.version].urls);
};
const handleReleaseChanged = e => {
const release = parseInt(e.target.value, 10);
const releaseVersion = props.VersionLookup[Constants.RELEASE_TYPES[release]].length - 1;
@@ -88,7 +96,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
));
} else {
optionsDisplay.push((
<Button clicked={props.downloadClicked}
<Button clicked={handleDownloadRelease}
col={dimensions => (dimensions.columns / 3) * 2}
colSpan={20}
key={key++}

View File

@@ -1,17 +1,37 @@
import {connect} from 'react-redux';
import Button from '../UI/Button/Button';
import Box from '../UI/Box/Box';
import * as Constants from '../../constants';
import React from 'react';
import './UpgradeUI.css';
import {setDismissUIUpgrade} from '../../redux/actions/release_version_actions';
import {downloadItem} from '../../redux/actions/download_actions';
const mapStateToProps = state => {
return {
Platform: state.common.Platform,
UpgradeData: state.relver.UpgradeData,
UpgradeVersion: state.relver.UpgradeVersion,
}
};
const mapDispatchToProps = dispatch => {
return {
downloadItem: (name, type, urls) => dispatch(downloadItem(name, type, urls)),
setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)),
};
};
export default connect(null, mapDispatchToProps)(props => {
export default connect(mapStateToProps, mapDispatchToProps)(props => {
const handleDownload = () => {
const name = (props.Platform === 'win32') ?
'upgrade.exe' :
(props.Platform === 'darwin') ?
'upgrade.dmg' :
'repertory-ui_' + props.UpgradeVersion + '_linux_x86_64.AppImage';
props.downloadItem(name, Constants.INSTALL_TYPES.Upgrade, props.UpgradeData.urls);
};
return (
<Box dxStyle={{width: '180px', height: 'auto', padding: '5px'}}>
<div style={{width: '100%', height: 'auto'}}>
@@ -22,7 +42,7 @@ export default connect(null, mapDispatchToProps)(props => {
<tr>
<td width="50%">
<Button buttonStyles={{width: '100%'}}
clicked={props.upgrade}>Install</Button>
clicked={handleDownload}>Install</Button>
</td>
<td width="50%">
<Button buttonStyles={{width: '100%'}}