Redux changes and refactoring
This commit is contained in:
@@ -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