Added cancel mount retry
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
# Changelog #
|
# Changelog #
|
||||||
## 1.0.2 ##
|
## 1.0.2 ##
|
||||||
* Launch hidden (notification icon only)
|
* Option to launch application hidden (notification icon only)
|
||||||
|
* Close window to notification area
|
||||||
|
* Unmount on application exit
|
||||||
|
* Ability to cancel mount retry on unexpected failure
|
||||||
* OS X support
|
* OS X support
|
||||||
* SiaPrime support
|
* SiaPrime support
|
||||||
* Unmount on application exit
|
|
||||||
* Partial Linux support
|
* Partial Linux support
|
||||||
* Close to notification area
|
|
||||||
|
|
||||||
## 1.0.1 ##
|
## 1.0.1 ##
|
||||||
* Added configuration settings for Repertory 1.0.0-alpha.2 and above
|
* Added configuration settings for Repertory 1.0.0-alpha.2 and above
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Component} from 'react';
|
import {Component} from 'react';
|
||||||
|
import Box from '../../components/UI/Box/Box';
|
||||||
|
import Button from '../../components/UI/Button/Button';
|
||||||
import CSSModules from 'react-css-modules';
|
import CSSModules from 'react-css-modules';
|
||||||
import styles from './MountItems.css';
|
import styles from './MountItems.css';
|
||||||
|
import Modal from '../../components/UI/Modal/Modal';
|
||||||
import MountItem from '../../components/MountItem/MountItem';
|
import MountItem from '../../components/MountItem/MountItem';
|
||||||
|
import RootElem from '../../hoc/RootElem/RootElem';
|
||||||
|
|
||||||
const Constants = require('../../constants');
|
const Constants = require('../../constants');
|
||||||
|
|
||||||
@@ -30,9 +34,36 @@ class MountItems extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {};
|
retryIntervals = {};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
DisplayRetry: false,
|
||||||
|
RetryItems: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
cancelRetryMount = (storageType, stateCallback) => {
|
||||||
|
clearInterval(this.retryIntervals[storageType]);
|
||||||
|
delete this.retryIntervals[storageType];
|
||||||
|
|
||||||
|
if (stateCallback) {
|
||||||
|
let retryItems = {
|
||||||
|
...this.state.RetryItems,
|
||||||
|
};
|
||||||
|
delete retryItems[storageType];
|
||||||
|
this.setState({
|
||||||
|
DisplayRetry: Object.keys(retryItems) > 0,
|
||||||
|
RetryItems: retryItems,
|
||||||
|
}, stateCallback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
componentWillUnmount = () => {
|
componentWillUnmount = () => {
|
||||||
|
for (const storageType in this.state.RetryItems) {
|
||||||
|
if (this.state.RetryItems.hasOwnProperty(storageType)) {
|
||||||
|
this.cancelRetryMount(storageType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
ipcRenderer.removeListener(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
|
ipcRenderer.removeListener(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
|
||||||
ipcRenderer.removeListener(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
|
ipcRenderer.removeListener(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
|
||||||
@@ -160,7 +191,36 @@ class MountItems extends Component {
|
|||||||
|
|
||||||
onUnmountDriveReply = (event, arg) => {
|
onUnmountDriveReply = (event, arg) => {
|
||||||
if (arg && arg.data && !arg.data.Expected && arg.data.Location && this.props[arg.data.StorageType.toLowerCase()].AutoRestart) {
|
if (arg && arg.data && !arg.data.Expected && arg.data.Location && this.props[arg.data.StorageType.toLowerCase()].AutoRestart) {
|
||||||
this.handleMountUnMount(arg.data.StorageType, true, arg.data.Location)
|
const storageType = arg.data.StorageType;
|
||||||
|
if (!this.state.RetryItems[storageType]) {
|
||||||
|
let retryItems = {
|
||||||
|
...this.state.RetryItems
|
||||||
|
};
|
||||||
|
retryItems[storageType] = {
|
||||||
|
RetrySeconds: 10,
|
||||||
|
};
|
||||||
|
this.setState({
|
||||||
|
DisplayRetry: true,
|
||||||
|
RetryItems: retryItems,
|
||||||
|
}, () => {
|
||||||
|
this.retryIntervals[storageType] = setInterval(() => {
|
||||||
|
let retryItems = {
|
||||||
|
...this.state.RetryItems,
|
||||||
|
};
|
||||||
|
const retrySeconds = retryItems[storageType].RetrySeconds - 1;
|
||||||
|
if (retrySeconds === 0) {
|
||||||
|
this.cancelRetryMount(storageType, () => {
|
||||||
|
this.handleMountUnMount(storageType, true, arg.data.Location);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
retryItems[storageType].RetrySeconds = retrySeconds;
|
||||||
|
this.setState({
|
||||||
|
RetryItems: retryItems,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.detectMounts();
|
this.detectMounts();
|
||||||
}
|
}
|
||||||
@@ -177,6 +237,7 @@ class MountItems extends Component {
|
|||||||
this.handleMountUnMount(provider, true, this.props[providerLower].MountLocation);
|
this.handleMountUnMount(provider, true, this.props[providerLower].MountLocation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
processAutoMount(provider);
|
processAutoMount(provider);
|
||||||
}
|
}
|
||||||
@@ -184,6 +245,30 @@ class MountItems extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let retryDisplay;
|
||||||
|
if (this.state.DisplayRetry) {
|
||||||
|
let retryList = [];
|
||||||
|
for (const storageType in this.state.RetryItems) {
|
||||||
|
if (this.state.RetryItems.hasOwnProperty(storageType)) {
|
||||||
|
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>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
retryDisplay = (
|
||||||
|
<Modal>
|
||||||
|
<Box dxStyle={{padding: '8px', minWidth: '60vw'}}>
|
||||||
|
<h1 style={{textAlign: 'center'}}>Mount Failed</h1>
|
||||||
|
{retryList}
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
let items = [];
|
let items = [];
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
const providerLower = provider.toLowerCase();
|
const providerLower = provider.toLowerCase();
|
||||||
@@ -212,6 +297,7 @@ class MountItems extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div styleName='MountItems'>
|
<div styleName='MountItems'>
|
||||||
|
{retryDisplay}
|
||||||
{items}
|
{items}
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user