Redux changes and refactoring
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import React from 'react';
|
||||
import './Configuration.css';
|
||||
import {connect} from 'react-redux';
|
||||
import Box from '../../components/UI/Box/Box';
|
||||
import Button from '../../components/UI/Button/Button';
|
||||
import ConfigurationItem from '../../components/ConfigurationItem/ConfigurationItem';
|
||||
import Modal from '../../components/UI/Modal/Modal';
|
||||
import IPCContainer from '../IPCContainer/IPCContainer';
|
||||
import {displayConfiguration} from "../../redux/actions/mount_actions";
|
||||
|
||||
const Constants = require('../../constants');
|
||||
|
||||
@@ -16,8 +18,7 @@ class Configuration extends IPCContainer {
|
||||
this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
|
||||
|
||||
this.sendRequest(Constants.IPC_Get_Config_Template, {
|
||||
Directory: this.props.directory,
|
||||
StorageType: this.props.storageType,
|
||||
StorageType: this.props.DisplayConfiguration,
|
||||
Version: this.props.version,
|
||||
});
|
||||
}
|
||||
@@ -67,7 +68,7 @@ class Configuration extends IPCContainer {
|
||||
ChangedObjectLookup: changedObjectLookup,
|
||||
});
|
||||
} else {
|
||||
this.props.closed();
|
||||
this.props.hideConfiguration();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -151,20 +152,19 @@ class Configuration extends IPCContainer {
|
||||
Template: arg.data.Template,
|
||||
}, ()=> {
|
||||
this.sendRequest(Constants.IPC_Get_Config, {
|
||||
Directory: this.props.directory,
|
||||
StorageType: this.props.storageType,
|
||||
StorageType: this.props.DisplayConfiguration,
|
||||
Version: this.props.version,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.props.errorHandler(arg.data.Error, () => {
|
||||
this.props.closed();
|
||||
this.props.hideConfiguration();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onSetConfigValuesReply = () => {
|
||||
this.props.closed();
|
||||
this.props.hideConfiguration();
|
||||
};
|
||||
|
||||
saveAndClose = () => {
|
||||
@@ -191,9 +191,8 @@ class Configuration extends IPCContainer {
|
||||
}
|
||||
|
||||
this.sendRequest(Constants.IPC_Set_Config_Values, {
|
||||
Directory: this.props.directory,
|
||||
Items: changedItems,
|
||||
StorageType: this.props.storageType,
|
||||
StorageType: this.props.DisplayConfiguration,
|
||||
Version: this.props.version,
|
||||
});
|
||||
});
|
||||
@@ -209,7 +208,7 @@ class Configuration extends IPCContainer {
|
||||
<table width='100%'><tbody>
|
||||
<tr>
|
||||
<td align='center' width='50%'><Button clicked={this.saveAndClose} disabled={this.state.Saving}>Yes</Button></td>
|
||||
<td align='center' width='50%'><Button clicked={this.props.closed} disabled={this.state.Saving}>No</Button></td>
|
||||
<td align='center' width='50%'><Button clicked={this.props.hideConfiguration} disabled={this.state.Saving}>No</Button></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</Box>
|
||||
@@ -264,7 +263,7 @@ class Configuration extends IPCContainer {
|
||||
<b style={{cursor: 'pointer'}}
|
||||
onClick={this.checkSaveRequired}>X</b>
|
||||
</div>
|
||||
<h1 style={{width: '100%', textAlign: 'center'}}>{this.props.storageType + ' Configuration'}</h1>
|
||||
<h1 style={{width: '100%', textAlign: 'center'}}>{this.props.DisplayConfiguration + ' Configuration'}</h1>
|
||||
<div style={{overflowY: 'auto', height: '90%'}}>
|
||||
{objectItems}
|
||||
{(configurationItems.length > 0) ? <h1>Settings</h1> : null}
|
||||
@@ -276,4 +275,16 @@ class Configuration extends IPCContainer {
|
||||
}
|
||||
}
|
||||
|
||||
export default Configuration;
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
DisplayConfiguration: state.mounts.DisplayConfiguration,
|
||||
}
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
hideConfiguration: () => dispatch(displayConfiguration(null)),
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Configuration);
|
||||
Reference in New Issue
Block a user