Retry mount fixes
This commit is contained in:
@@ -6,7 +6,6 @@ import CSSModules from 'react-css-modules';
|
||||
import styles from './MountItems.css';
|
||||
import Modal from '../../components/UI/Modal/Modal';
|
||||
import MountItem from '../../components/MountItem/MountItem';
|
||||
import RootElem from '../../hoc/RootElem/RootElem';
|
||||
|
||||
const Constants = require('../../constants');
|
||||
|
||||
@@ -18,6 +17,7 @@ if (!process.versions.hasOwnProperty('electron')) {
|
||||
class MountItems extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
this.state[provider] = {
|
||||
AllowMount: false,
|
||||
@@ -25,6 +25,7 @@ class MountItems extends Component {
|
||||
Mounted: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.on(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
|
||||
ipcRenderer.on(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
|
||||
@@ -72,18 +73,19 @@ class MountItems extends Component {
|
||||
};
|
||||
|
||||
detectMounts = ()=> {
|
||||
if (!this.state.DisplayRetry) {
|
||||
this.props.mountsBusy(true);
|
||||
ipcRenderer.send(Constants.IPC_Detect_Mounts, {
|
||||
Directory: this.props.directory,
|
||||
Version: this.props.version,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
handleMountLocationChanged = (storageType, value) => {
|
||||
if (this.props.platform === 'win32') {
|
||||
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.props.changed(storageType, value);
|
||||
}
|
||||
};
|
||||
@@ -91,8 +93,7 @@ class MountItems extends Component {
|
||||
handleMountUnMount = (storageType, mount, location) => {
|
||||
if (!location || (location.trim().length === 0)) {
|
||||
this.props.errorHandler('Mount location is not set');
|
||||
} else {
|
||||
if (ipcRenderer) {
|
||||
} else if (ipcRenderer) {
|
||||
let allowAction = true;
|
||||
if (mount && (this.props.platform !== 'win32')) {
|
||||
const result = ipcRenderer.sendSync(Constants.IPC_Check_Mount_Location, {
|
||||
@@ -105,7 +106,7 @@ class MountItems extends Component {
|
||||
}
|
||||
|
||||
if (allowAction) {
|
||||
const state = {
|
||||
const storageState = {
|
||||
...this.state[storageType],
|
||||
AllowMount: false,
|
||||
};
|
||||
@@ -113,7 +114,7 @@ class MountItems extends Component {
|
||||
this.props.mountsBusy(true);
|
||||
|
||||
this.setState({
|
||||
[storageType]: state,
|
||||
[storageType]: storageState,
|
||||
}, () => {
|
||||
if (mount) {
|
||||
ipcRenderer.send(Constants.IPC_Mount_Drive, {
|
||||
@@ -134,11 +135,10 @@ class MountItems extends Component {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onDetectMountsReply = (event, arg) => {
|
||||
if (arg.data.Success) {
|
||||
if (!this.state.DisplayRetry && arg.data.Success) {
|
||||
let state = {};
|
||||
let mountsBusy = false;
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
@@ -199,7 +199,13 @@ class MountItems extends Component {
|
||||
retryItems[storageType] = {
|
||||
RetrySeconds: 10,
|
||||
};
|
||||
const storageState = {
|
||||
...this.state[arg.data.StorageType],
|
||||
AllowMount: false,
|
||||
Mounted: false,
|
||||
};
|
||||
this.setState({
|
||||
[storageType]: storageState,
|
||||
DisplayRetry: true,
|
||||
RetryItems: retryItems,
|
||||
}, () => {
|
||||
@@ -252,21 +258,18 @@ class MountItems extends Component {
|
||||
for (const storageType in this.state.RetryItems) {
|
||||
if (this.state.RetryItems.hasOwnProperty(storageType)) {
|
||||
retryListCount++;
|
||||
retryList.push((
|
||||
<RootElem key={retryList.length}>
|
||||
<p>Retrying {storageType} in {this.state.RetryItems[storageType].RetrySeconds}(s)</p>
|
||||
<Button clicked={()=>this.cancelRetryMount(storageType, ()=> this.detectMounts())}>Cancel {storageType}</Button>
|
||||
</RootElem>
|
||||
));
|
||||
retryList.push(<Button
|
||||
clicked={()=>this.cancelRetryMount(storageType, ()=> this.detectMounts())}
|
||||
key={'b' + retryListCount}>Cancel {storageType} Auto-Retry ({this.state.RetryItems[storageType].RetrySeconds}s)]</Button>);
|
||||
if (retryListCount < Object.keys(this.state.RetryItems).length) {
|
||||
retryList.push(<div style={{paddingTop: '8px'}} key={'b'+retryList.length}/>);
|
||||
retryList.push(<div style={{paddingTop: '8px'}} key={'d' + retryListCount}/>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
retryDisplay = (
|
||||
<Modal>
|
||||
<Box dxStyle={{padding: '8px', minWidth: '60vw'}}>
|
||||
<Box dxStyle={{padding: '8px', minWidth: '70vw'}}>
|
||||
<h1 style={{textAlign: 'center'}}>Mount Failed</h1>
|
||||
{retryList}
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user