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);
|
||||
@@ -6,7 +6,7 @@ import './MountItems.css';
|
||||
import Modal from '../../components/UI/Modal/Modal';
|
||||
import MountItem from '../../components/MountItem/MountItem';
|
||||
import IPCContainer from '../IPCContainer/IPCContainer';
|
||||
import {setBusy} from '../../redux/actions/mount_actions';
|
||||
import {displayConfiguration, setAutoMountProcessed, setBusy} from '../../redux/actions/mount_actions';
|
||||
|
||||
const Constants = require('../../constants');
|
||||
|
||||
@@ -71,7 +71,6 @@ class MountItems extends IPCContainer {
|
||||
if (!this.state.DisplayRetry) {
|
||||
this.props.setMountsBusy(true);
|
||||
this.sendRequest(Constants.IPC_Detect_Mounts, {
|
||||
Directory: this.props.directory,
|
||||
Version: this.props.version,
|
||||
});
|
||||
}
|
||||
@@ -88,7 +87,7 @@ class MountItems extends IPCContainer {
|
||||
};
|
||||
|
||||
handleMountLocationChanged = (storageType, value) => {
|
||||
if (this.props.platform === 'win32') {
|
||||
if (this.props.Platform === 'win32') {
|
||||
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
|
||||
} else {
|
||||
this.props.changed(storageType, value);
|
||||
@@ -102,13 +101,12 @@ class MountItems extends IPCContainer {
|
||||
let allowAction = true;
|
||||
if (mount) {
|
||||
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
||||
Directory: this.props.directory,
|
||||
StorageType: storageType,
|
||||
Version: this.props.version
|
||||
}).data;
|
||||
if (result.Success) {
|
||||
if (result.Valid) {
|
||||
if (this.props.platform !== 'win32') {
|
||||
if (this.props.Platform !== 'win32') {
|
||||
result = this.sendSyncRequest(Constants.IPC_Check_Mount_Location, {
|
||||
Location: location,
|
||||
});
|
||||
@@ -140,7 +138,6 @@ class MountItems extends IPCContainer {
|
||||
}, () => {
|
||||
if (mount) {
|
||||
this.sendRequest(Constants.IPC_Mount_Drive, {
|
||||
Directory: this.props.directory,
|
||||
Location: location,
|
||||
NoConsoleSupported: this.props.noConsoleSupported,
|
||||
StorageType: storageType,
|
||||
@@ -148,7 +145,6 @@ class MountItems extends IPCContainer {
|
||||
});
|
||||
} else {
|
||||
this.sendRequest(Constants.IPC_Unmount_Drive, {
|
||||
Directory: this.props.directory,
|
||||
Location: location,
|
||||
StorageType: storageType,
|
||||
Version: this.props.version,
|
||||
@@ -179,7 +175,7 @@ class MountItems extends IPCContainer {
|
||||
const providerLower = provider.toLowerCase();
|
||||
let location = data.Locations[provider];
|
||||
if (location.length === 0) {
|
||||
location = (this.props.platform === 'win32') ?
|
||||
location = (this.props.Platform === 'win32') ?
|
||||
this.props[providerLower].MountLocation || data.DriveLetters[provider][0] :
|
||||
this.props[providerLower].MountLocation;
|
||||
}
|
||||
@@ -256,8 +252,9 @@ class MountItems extends IPCContainer {
|
||||
};
|
||||
|
||||
performAutoMount = ()=> {
|
||||
if (this.props.processAutoMount) {
|
||||
this.props.autoMountProcessed();
|
||||
if (!this.props.AutoMountProcessed) {
|
||||
this.props.setAutoMountProcessed(true);
|
||||
|
||||
const processAutoMount = (provider) => {
|
||||
const providerLower = provider.toLowerCase();
|
||||
if (this.props[providerLower].AutoMount &&
|
||||
@@ -313,12 +310,11 @@ class MountItems extends IPCContainer {
|
||||
browseClicked={this.handleBrowseLocation}
|
||||
changed={(e) => this.handleMountLocationChanged(provider, e.target.value)}
|
||||
clicked={this.handleMountUnMount}
|
||||
configClicked={()=>this.props.configClicked(provider)}
|
||||
configClicked={()=>this.props.displayConfiguration(provider)}
|
||||
items={this.state[provider].DriveLetters}
|
||||
key={'mi_' + items.length}
|
||||
location={this.props[providerLower].MountLocation}
|
||||
mounted={this.state[provider].Mounted}
|
||||
platform={this.props.platform}
|
||||
title={provider} />
|
||||
));
|
||||
if (items.length !== this.state.length) {
|
||||
@@ -335,10 +331,19 @@ class MountItems extends IPCContainer {
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
setMountsBusy: busy => dispatch(setBusy(busy))
|
||||
AutoMountProcessed: state.mounts.AutoMountProcessed,
|
||||
Platform: state.common.Platform,
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(null, mapDispatchToProps)(MountItems);
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
displayConfiguration: storageType => dispatch(displayConfiguration(storageType)),
|
||||
setAutoMountProcessed: processed => dispatch(setAutoMountProcessed(processed)),
|
||||
setMountsBusy: busy => dispatch(setBusy(busy)),
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(MountItems);
|
||||
Reference in New Issue
Block a user