Redux changes and refactoring

This commit is contained in:
Scott E. Graves
2019-06-07 16:32:18 -05:00
parent 5c931bb66d
commit 7f3e90773e
9 changed files with 158 additions and 69 deletions

View File

@@ -14,6 +14,7 @@ import {
setMountState,
setProviderState
} from '../../redux/actions/mount_actions';
import {notifyError} from '../../redux/actions/error_actions';
const Constants = require('../../constants');
@@ -101,7 +102,7 @@ class MountItems extends IPCContainer {
handleMountUnMount = (provider, mount, location) => {
if (!location || (location.trim().length === 0)) {
this.props.errorHandler('Mount location is not set');
this.props.notifyError('Mount location is not set');
} else {
let allowAction = true;
if (mount) {
@@ -117,22 +118,22 @@ class MountItems extends IPCContainer {
});
if (!result.Success) {
allowAction = false;
this.props.errorHandler(result.Error.toString());
this.props.notifyError(result.Error.toString());
}
}
} else {
allowAction = false;
if (result.Code === (new Uint32Array([-1]))[0]) {
this.props.errorHandler('Failed to connect to ' + provider + ' daemon');
this.props.notifyError('Failed to connect to ' + provider + ' daemon');
} else if (result.Code === (new Uint32Array([-3]))[0]) {
this.props.errorHandler('Incompatible ' + provider + ' daemon. Please upgrade ' + provider);
this.props.notifyError('Incompatible ' + provider + ' daemon. Please upgrade ' + provider);
} else {
this.props.errorHandler('Version check failed: ' + result.Error);
this.props.notifyError('Version check failed: ' + result.Error);
}
}
} else {
allowAction = false;
this.props.errorHandler(result.Error.toString());
this.props.notifyError(result.Error.toString());
}
}
@@ -201,7 +202,7 @@ class MountItems extends IPCContainer {
this.props.setAutoMountProcessed(true);
} else {
this.props.errorHandler(arg.data.Error);
this.props.notifyError(arg.data.Error);
}
};
@@ -316,6 +317,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
notifyError: (msg, critical, callback) => dispatch(notifyError(msg, critical, callback)),
setAllowMount: (provider, allow) => dispatch(setAllowMount(provider, allow)),
setAutoMountProcessed: processed => dispatch(setAutoMountProcessed(processed)),
setMounted: (provider, mounted) => dispatch(setMounted(provider, mounted)),