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

@@ -1,7 +1,15 @@
import React from 'react';
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 (
<div className={'Dependency'}>
<table width="100%">
@@ -11,7 +19,7 @@ export default props => {
<h3>{props.name}</h3>
</td>
<td>
{props.allowDownload ?
{props.AllowDownload ?
<a href={void(0)} className={'DependencyLink'} onClick={()=>{props.onDownload(props.download); return false;}}><u>Install</u></a> :
'Installing...'}
</td>
@@ -20,4 +28,4 @@ export default props => {
</table>
</div>
);
};
});

View File

@@ -1,13 +1,19 @@
import React from 'react';
import './DependencyList.css';
import {connect} from 'react-redux';
import Dependency from './Dependency/Dependency';
import Box from '../UI/Box/Box';
export default props => {
const items = props.dependencies.map((k, i)=> {
const mapStateToProps = state => {
return {
MissingDependencies: state.install.MissingDependencies,
};
};
export default connect(mapStateToProps)(props => {
const items = props.MissingDependencies.map((k, i)=> {
return (
<Dependency allowDownload={props.allowDownload}
download={k.download}
<Dependency download={k.download}
key={i}
name={k.display}
onDownload={props.onDownload}/>
@@ -22,5 +28,4 @@ export default props => {
{items}
</Box>
);
};
});