Redux changes and refactoring
This commit is contained in:
@@ -119,7 +119,7 @@ function createWindow() {
|
|||||||
// Unmount all items
|
// Unmount all items
|
||||||
for (const i in mountedLocations) {
|
for (const i in mountedLocations) {
|
||||||
const data = mountedData[mountedLocations[i]];
|
const data = mountedData[mountedLocations[i]];
|
||||||
helpers.stopMountProcessSync(data.Version, data.StorageType);
|
helpers.stopMountProcessSync(data.Version, data.Provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
mountedLocations = [];
|
mountedLocations = [];
|
||||||
@@ -205,10 +205,10 @@ if (!instanceLock) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearManualMountDetection = (storageType) => {
|
const clearManualMountDetection = (provider) => {
|
||||||
if (manualMountDetection[storageType]) {
|
if (manualMountDetection[provider]) {
|
||||||
clearInterval(manualMountDetection[storageType]);
|
clearInterval(manualMountDetection[provider]);
|
||||||
delete manualMountDetection[storageType];
|
delete manualMountDetection[provider];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -223,25 +223,25 @@ const loadUiSettings = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const monitorMount = (sender, storageType, version, pid, location) => {
|
const monitorMount = (sender, provider, version, pid, location) => {
|
||||||
manualMountDetection[storageType] = setInterval(() => {
|
manualMountDetection[provider] = setInterval(() => {
|
||||||
helpers
|
helpers
|
||||||
.detectRepertoryMounts(version)
|
.detectRepertoryMounts(version)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result[storageType].PID !== pid) {
|
if (result[provider].PID !== pid) {
|
||||||
if (result[storageType].PID === -1) {
|
if (result[provider].PID === -1) {
|
||||||
clearManualMountDetection(storageType);
|
clearManualMountDetection(provider);
|
||||||
sender.send(Constants.IPC_Unmount_Drive_Reply, {
|
sender.send(Constants.IPC_Unmount_Drive_Reply, {
|
||||||
data: {
|
data: {
|
||||||
Expected: expectedUnmount[storageType],
|
Expected: expectedUnmount[provider],
|
||||||
Location: location,
|
Location: location,
|
||||||
StorageType: storageType,
|
Provider: provider,
|
||||||
Error: Error(storageType + ' Unmounted').toString(),
|
Error: Error(provider + ' Unmounted').toString(),
|
||||||
Success: false,
|
Success: false,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pid = result[storageType].PID;
|
pid = result[provider].PID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -289,7 +289,7 @@ ipcMain.on(Constants.IPC_Browse_Directory + '_sync', (event, data) => {
|
|||||||
|
|
||||||
ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
|
ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
|
||||||
helpers
|
helpers
|
||||||
.checkDaemonVersion(data.Version, data.StorageType)
|
.checkDaemonVersion(data.Version, data.Provider)
|
||||||
.then(code => {
|
.then(code => {
|
||||||
standardIPCReply(event, Constants.IPC_Check_Daemon_Version_Reply, {
|
standardIPCReply(event, Constants.IPC_Check_Daemon_Version_Reply, {
|
||||||
Valid: (code === 0),
|
Valid: (code === 0),
|
||||||
@@ -304,7 +304,7 @@ ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
|
|||||||
|
|
||||||
ipcMain.on(Constants.IPC_Check_Daemon_Version + '_sync', (event, data) => {
|
ipcMain.on(Constants.IPC_Check_Daemon_Version + '_sync', (event, data) => {
|
||||||
helpers
|
helpers
|
||||||
.checkDaemonVersion(data.Version, data.StorageType)
|
.checkDaemonVersion(data.Version, data.Provider)
|
||||||
.then(code => {
|
.then(code => {
|
||||||
event.returnValue = {
|
event.returnValue = {
|
||||||
data: {
|
data: {
|
||||||
@@ -593,7 +593,7 @@ ipcMain.on(Constants.IPC_Extract_Release, (event, data) => {
|
|||||||
|
|
||||||
ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
|
ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
|
||||||
helpers
|
helpers
|
||||||
.getConfig(data.Version, data.StorageType)
|
.getConfig(data.Version, data.Provider)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.Code === 0) {
|
if (data.Code === 0) {
|
||||||
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
|
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
|
||||||
@@ -610,7 +610,7 @@ ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
|
|||||||
|
|
||||||
ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
|
ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
|
||||||
helpers
|
helpers
|
||||||
.getConfigTemplate(data.Version, data.StorageType)
|
.getConfigTemplate(data.Version, data.Provider)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
|
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
|
||||||
Template: data,
|
Template: data,
|
||||||
@@ -796,15 +796,15 @@ ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
||||||
expectedUnmount[data.StorageType] = false;
|
expectedUnmount[data.Provider] = false;
|
||||||
|
|
||||||
if (mountedLocations.indexOf(data.Location) !== -1) {
|
if (mountedLocations.indexOf(data.Location) !== -1) {
|
||||||
console.log(data.StorageType + ' already mounted: ' + data.Location);
|
console.log(data.Provider + ' already mounted: ' + data.Location);
|
||||||
} else {
|
} else {
|
||||||
mountedLocations.push(data.Location);
|
mountedLocations.push(data.Location);
|
||||||
mountedData[data.Location] = {
|
mountedData[data.Location] = {
|
||||||
Version: data.Version,
|
Version: data.Version,
|
||||||
StorageType: data.StorageType,
|
Provider: data.Provider,
|
||||||
};
|
};
|
||||||
const errorHandler = (pid, error) => {
|
const errorHandler = (pid, error) => {
|
||||||
if (mountedLocations.indexOf(data.Location) !== -1) {
|
if (mountedLocations.indexOf(data.Location) !== -1) {
|
||||||
@@ -813,18 +813,18 @@ ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
standardIPCReply(event, Constants.IPC_Unmount_Drive_Reply, {
|
standardIPCReply(event, Constants.IPC_Unmount_Drive_Reply, {
|
||||||
Expected: expectedUnmount[data.StorageType],
|
Expected: expectedUnmount[data.Provider],
|
||||||
Location: data.Location,
|
Location: data.Location,
|
||||||
StorageType: data.StorageType,
|
Provider: data.Provider,
|
||||||
}, error || Error(data.StorageType + ' Unmounted'));
|
}, error || Error(data.Provider + ' Unmounted'));
|
||||||
};
|
};
|
||||||
helpers
|
helpers
|
||||||
.executeMount(data.Version, data.StorageType, data.Location, data.NoConsoleSupported, (error, pid) => {
|
.executeMount(data.Version, data.Provider, data.Location, data.NoConsoleSupported, (error, pid) => {
|
||||||
errorHandler(pid, error);
|
errorHandler(pid, error);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
standardIPCReply(event, Constants.IPC_Mount_Drive_Reply, {
|
standardIPCReply(event, Constants.IPC_Mount_Drive_Reply, {
|
||||||
StorageType: data.StorageType,
|
Provider: data.Provider,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -843,7 +843,7 @@ ipcMain.on(Constants.IPC_Set_Config_Values, (event, data) => {
|
|||||||
const setConfigValue = (i) => {
|
const setConfigValue = (i) => {
|
||||||
if (i < data.Items.length) {
|
if (i < data.Items.length) {
|
||||||
helpers
|
helpers
|
||||||
.setConfigValue(data.Items[i].Name, data.Items[i].Value, data.StorageType, data.Version)
|
.setConfigValue(data.Items[i].Name, data.Items[i].Value, data.Provider, data.Version)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setConfigValue(++i);
|
setConfigValue(++i);
|
||||||
})
|
})
|
||||||
@@ -871,11 +871,11 @@ ipcMain.on(Constants.IPC_Show_Window + '_sync', event => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
|
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
|
||||||
clearManualMountDetection(data.StorageType);
|
clearManualMountDetection(data.Provider);
|
||||||
|
|
||||||
expectedUnmount[data.StorageType] = true;
|
expectedUnmount[data.Provider] = true;
|
||||||
helpers
|
helpers
|
||||||
.stopMountProcess(data.Version, data.StorageType)
|
.stopMountProcess(data.Version, data.Provider)
|
||||||
.then((result)=> {
|
.then((result)=> {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
})
|
})
|
||||||
|
|||||||
102
src/App.js
102
src/App.js
@@ -15,6 +15,7 @@ import ReleaseVersionDisplay from './components/ReleaseVersionDisplay/ReleaseVer
|
|||||||
import Text from './components/UI/Text/Text';
|
import Text from './components/UI/Text/Text';
|
||||||
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
|
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
|
||||||
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
|
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
|
||||||
|
import {setProviderState} from './redux/actions/mount_actions';
|
||||||
import {detectUIUpgrade, loadReleases, setActiveRelease, setDismissUIUpgrade, setReleaseUpgradeAvailable} from './redux/actions/release_version_actions';
|
import {detectUIUpgrade, loadReleases, setActiveRelease, setDismissUIUpgrade, setReleaseUpgradeAvailable} from './redux/actions/release_version_actions';
|
||||||
|
|
||||||
const Constants = require('./constants');
|
const Constants = require('./constants');
|
||||||
@@ -24,14 +25,6 @@ class App extends IPCContainer {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
|
||||||
this.state[provider] = {
|
|
||||||
AutoMount: false,
|
|
||||||
AutoRestart: false,
|
|
||||||
MountLocation: '',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setRequestHandler(Constants.IPC_Check_Installed_Reply, this.onCheckInstalledReply);
|
this.setRequestHandler(Constants.IPC_Check_Installed_Reply, this.onCheckInstalledReply);
|
||||||
this.setRequestHandler(Constants.IPC_Download_File_Complete, this.onDownloadFileComplete);
|
this.setRequestHandler(Constants.IPC_Download_File_Complete, this.onDownloadFileComplete);
|
||||||
this.setRequestHandler(Constants.IPC_Download_File_Progress, this.onDownloadFileProgress);
|
this.setRequestHandler(Constants.IPC_Download_File_Progress, this.onDownloadFileProgress);
|
||||||
@@ -104,6 +97,10 @@ class App extends IPCContainer {
|
|||||||
(prevProps.VersionLookup !== this.props.VersionLookup)) {
|
(prevProps.VersionLookup !== this.props.VersionLookup)) {
|
||||||
this.saveState();
|
this.saveState();
|
||||||
this.checkVersionInstalled();
|
this.checkVersionInstalled();
|
||||||
|
} else if (Object.keys(this.props.ProviderState).filter(k=> {
|
||||||
|
return this.props.ProviderState[k] !== prevProps.ProviderState[k];
|
||||||
|
}).length > 0) {
|
||||||
|
this.saveState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +128,9 @@ class App extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getSelectedVersion = () => {
|
getSelectedVersion = () => {
|
||||||
return this.props.VersionLookup[Constants.RELEASE_TYPES[this.props.Release]][this.props.ReleaseVersion];
|
return (this.props.ReleaseVersion === -1) ?
|
||||||
|
'unavailable' :
|
||||||
|
this.props.VersionLookup[Constants.RELEASE_TYPES[this.props.Release]][this.props.ReleaseVersion];
|
||||||
};
|
};
|
||||||
|
|
||||||
detectUpgrades = () => {
|
detectUpgrades = () => {
|
||||||
@@ -141,30 +140,6 @@ class App extends IPCContainer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleAutoMountChanged = (storageType, e) => {
|
|
||||||
const state = {
|
|
||||||
...this.state[storageType],
|
|
||||||
AutoMount: e.target.checked,
|
|
||||||
};
|
|
||||||
this.setState({
|
|
||||||
[storageType]: state,
|
|
||||||
}, ()=> {
|
|
||||||
this.saveState();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleAutoRestartChanged = (storageType, e) => {
|
|
||||||
const state = {
|
|
||||||
...this.state[storageType],
|
|
||||||
AutoRestart: e.target.checked,
|
|
||||||
};
|
|
||||||
this.setState({
|
|
||||||
[storageType]: state,
|
|
||||||
}, ()=> {
|
|
||||||
this.saveState();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleDependencyDownload = (url) => {
|
handleDependencyDownload = (url) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
DownloadActive: true,
|
DownloadActive: true,
|
||||||
@@ -178,24 +153,6 @@ class App extends IPCContainer {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMountLocationChanged = (storageType, location) => {
|
|
||||||
const state = {
|
|
||||||
...this.state[storageType],
|
|
||||||
MountLocation: location,
|
|
||||||
};
|
|
||||||
this.setState({
|
|
||||||
[storageType]: state,
|
|
||||||
}, ()=> {
|
|
||||||
this.saveState();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleReleaseChanged = (e) => {
|
|
||||||
const release = parseInt(e.target.value, 10);
|
|
||||||
const releaseVersion = this.props.VersionLookup[Constants.RELEASE_TYPES[release]].length - 1;
|
|
||||||
this.props.setActiveRelease(release, releaseVersion);
|
|
||||||
};
|
|
||||||
|
|
||||||
handleReleaseDownload = () => {
|
handleReleaseDownload = () => {
|
||||||
const selectedVersion = this.getSelectedVersion();
|
const selectedVersion = this.getSelectedVersion();
|
||||||
const fileName = selectedVersion + '.zip';
|
const fileName = selectedVersion + '.zip';
|
||||||
@@ -225,10 +182,6 @@ class App extends IPCContainer {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleVersionChanged = (e) => {
|
|
||||||
this.props.setActiveRelease(this.props.Release, parseInt(e.target.value, 10));
|
|
||||||
};
|
|
||||||
|
|
||||||
installDependency = data => {
|
installDependency = data => {
|
||||||
if (data.Success) {
|
if (data.Success) {
|
||||||
this.sendRequest(Constants.IPC_Install_Dependency, {
|
this.sendRequest(Constants.IPC_Install_Dependency, {
|
||||||
@@ -335,24 +288,19 @@ class App extends IPCContainer {
|
|||||||
if (arg.data) {
|
if (arg.data) {
|
||||||
this.props.setActiveRelease(arg.data.Release, arg.data.Version);
|
this.props.setActiveRelease(arg.data.Release, arg.data.Version);
|
||||||
|
|
||||||
let state = {};
|
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
let data = arg.data[provider] || this.state[provider];
|
let data = arg.data[provider] || this.props.ProviderState[provider];
|
||||||
if (data.AutoMount === undefined) {
|
if (data.AutoMount === undefined) {
|
||||||
data['AutoMount'] = false;
|
data['AutoMount'] = false;
|
||||||
}
|
}
|
||||||
if (data.AutoRestart === undefined) {
|
if (data.AutoRestart === undefined) {
|
||||||
data['AutoRestart'] = false;
|
data['AutoRestart'] = false;
|
||||||
}
|
}
|
||||||
state[provider] = data;
|
this.props.setProviderState(provider, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(state, ()=> {
|
|
||||||
this.detectUpgrades();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.detectUpgrades();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.detectUpgrades();
|
||||||
};
|
};
|
||||||
|
|
||||||
onInstallDependencyReply = (event, arg) => {
|
onInstallDependencyReply = (event, arg) => {
|
||||||
@@ -399,9 +347,10 @@ class App extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
state[provider] = this.state[provider];
|
state[provider] = this.props.ProviderState[provider];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(state);
|
||||||
this.sendRequest(Constants.IPC_Save_State, {
|
this.sendRequest(Constants.IPC_Save_State, {
|
||||||
State: state
|
State: state
|
||||||
});
|
});
|
||||||
@@ -444,9 +393,7 @@ class App extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const selectedVersion = (this.props.ReleaseVersion === -1) ?
|
const selectedVersion = this.getSelectedVersion();
|
||||||
'unavailable' :
|
|
||||||
this.getSelectedVersion();
|
|
||||||
|
|
||||||
const downloadEnabled = this.state.AllowDownload &&
|
const downloadEnabled = this.state.AllowDownload &&
|
||||||
!this.props.MountsBusy &&
|
!this.props.MountsBusy &&
|
||||||
@@ -540,29 +487,20 @@ class App extends IPCContainer {
|
|||||||
<ReleaseVersionDisplay disabled={this.state.DownloadActive || this.state.ExtractActive || this.props.MountsBusy}
|
<ReleaseVersionDisplay disabled={this.state.DownloadActive || this.state.ExtractActive || this.props.MountsBusy}
|
||||||
downloadClicked={this.handleReleaseDownload}
|
downloadClicked={this.handleReleaseDownload}
|
||||||
downloadDisabled={!downloadEnabled}
|
downloadDisabled={!downloadEnabled}
|
||||||
releaseChanged={this.handleReleaseChanged}
|
|
||||||
releaseExtracting={this.state.ExtractActive}
|
releaseExtracting={this.state.ExtractActive}
|
||||||
text={this.state.InstalledVersion + ' [' + this.props.AppPlatform + ']'}
|
saveState={this.saveState}
|
||||||
versionChanged={this.handleVersionChanged}/>
|
text={this.state.InstalledVersion + ' [' + this.props.AppPlatform + ']'}/>
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
|
|
||||||
if (allowMount) {
|
if (allowMount) {
|
||||||
let providerProps = {};
|
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
|
||||||
const providerLower = provider.toLowerCase();
|
|
||||||
providerProps[providerLower] = this.state[provider];
|
|
||||||
}
|
|
||||||
mainContent.push((
|
mainContent.push((
|
||||||
<div key={'md_' + key++}>
|
<div key={'md_' + key++}>
|
||||||
<MountItems {...providerProps}
|
<MountItems allowConfig={allowConfig}
|
||||||
allowConfig={allowConfig}
|
|
||||||
allowSiaPrime={allowSiaPrime}
|
allowSiaPrime={allowSiaPrime}
|
||||||
noConsoleSupported={noConsoleSupported}
|
noConsoleSupported={noConsoleSupported}
|
||||||
autoMountChanged={this.handleAutoMountChanged}
|
|
||||||
autoRestartChanged={this.handleAutoRestartChanged}
|
|
||||||
changed={this.handleMountLocationChanged}
|
|
||||||
errorHandler={this.setErrorState}
|
errorHandler={this.setErrorState}
|
||||||
|
saveState={this.saveState}
|
||||||
version={this.state.InstalledVersion}/>
|
version={this.state.InstalledVersion}/>
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
@@ -618,6 +556,7 @@ const mapStateToProps = state => {
|
|||||||
LocationsLookup: state.relver.LocationsLookup,
|
LocationsLookup: state.relver.LocationsLookup,
|
||||||
MountsBusy: state.mounts.MountsBusy,
|
MountsBusy: state.mounts.MountsBusy,
|
||||||
Platform: state.common.Platform,
|
Platform: state.common.Platform,
|
||||||
|
ProviderState: state.mounts.ProviderState,
|
||||||
Release: state.relver.Release,
|
Release: state.relver.Release,
|
||||||
ReleaseVersion: state.relver.Version,
|
ReleaseVersion: state.relver.Version,
|
||||||
UpgradeAvailable: state.relver.UpgradeAvailable,
|
UpgradeAvailable: state.relver.UpgradeAvailable,
|
||||||
@@ -634,6 +573,7 @@ const mapDispatchToProps = dispatch => {
|
|||||||
loadReleases: ()=> dispatch(loadReleases()),
|
loadReleases: ()=> dispatch(loadReleases()),
|
||||||
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
|
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
|
||||||
setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)),
|
setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)),
|
||||||
|
setProviderState: (provider, state) => dispatch(setProviderState(provider, state)),
|
||||||
setReleaseUpgradeAvailable: available => dispatch(setReleaseUpgradeAvailable(available)),
|
setReleaseUpgradeAvailable: available => dispatch(setReleaseUpgradeAvailable(available)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './MountItem.css';
|
import './MountItem.css';
|
||||||
import {connect} from "react-redux";
|
import {connect} from 'react-redux';
|
||||||
import DropDown from '../UI/DropDown/DropDown';
|
import DropDown from '../UI/DropDown/DropDown';
|
||||||
import Button from '../UI/Button/Button';
|
import Button from '../UI/Button/Button';
|
||||||
import Loader from 'react-loader-spinner';
|
import Loader from 'react-loader-spinner';
|
||||||
@@ -8,14 +8,40 @@ import Text from '../UI/Text/Text';
|
|||||||
import Grid from '../UI/Grid/Grid';
|
import Grid from '../UI/Grid/Grid';
|
||||||
import configureImage from '../../assets/images/configure.png';
|
import configureImage from '../../assets/images/configure.png';
|
||||||
import RootElem from '../../hoc/RootElem/RootElem';
|
import RootElem from '../../hoc/RootElem/RootElem';
|
||||||
|
import {displayConfiguration, setProviderState} from '../../redux/actions/mount_actions';
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
return {
|
return {
|
||||||
Platform: state.common.Platform,
|
Platform: state.common.Platform,
|
||||||
|
ProviderState: state.mounts.ProviderState,
|
||||||
|
State: state.mounts.ProviderState[ownProps.provider]
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(props => {
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
displayConfiguration: provider => dispatch(displayConfiguration(provider)),
|
||||||
|
setProviderState: (provider, state) => dispatch(setProviderState(provider, state)),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||||
|
const handleAutoMountChanged = e => {
|
||||||
|
const state = {
|
||||||
|
...props.ProviderState[props.provider],
|
||||||
|
AutoMount: e.target.checked,
|
||||||
|
};
|
||||||
|
props.setProviderState(props.provider, state);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAutoRestartChanged = e => {
|
||||||
|
const state = {
|
||||||
|
...props.ProviderState[props.provider],
|
||||||
|
AutoRestart: e.target.checked,
|
||||||
|
};
|
||||||
|
props.setProviderState(props.provider, state);
|
||||||
|
};
|
||||||
|
|
||||||
let configButton = null;
|
let configButton = null;
|
||||||
let secondRow = 6;
|
let secondRow = 6;
|
||||||
if (props.allowConfig) {
|
if (props.allowConfig) {
|
||||||
@@ -25,7 +51,7 @@ export default connect(mapStateToProps)(props => {
|
|||||||
rowSpan={6}>
|
rowSpan={6}>
|
||||||
<img alt=''
|
<img alt=''
|
||||||
height={'16px'}
|
height={'16px'}
|
||||||
onClick={props.allowMount ? props.configClicked : (e)=>{e.preventDefault();}}
|
onClick={props.allowMount ? ()=>props.displayConfiguration(props.provider) : e=>{e.preventDefault();}}
|
||||||
src={configureImage}
|
src={configureImage}
|
||||||
style={{padding: 0, border: 0, margin: 0, ...pointer}}
|
style={{padding: 0, border: 0, margin: 0, ...pointer}}
|
||||||
width={'16px'}/>
|
width={'16px'}/>
|
||||||
@@ -43,7 +69,7 @@ export default connect(mapStateToProps)(props => {
|
|||||||
items={props.items}
|
items={props.items}
|
||||||
row={secondRow}
|
row={secondRow}
|
||||||
rowSpan={7}
|
rowSpan={7}
|
||||||
selected={props.items.indexOf(props.location)}/>;
|
selected={props.items.indexOf(props.State.MountLocation)}/>;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
inputColumnSpan = 58;
|
inputColumnSpan = 58;
|
||||||
@@ -60,11 +86,11 @@ export default connect(mapStateToProps)(props => {
|
|||||||
size={4096}
|
size={4096}
|
||||||
className={'MountItemInput'}
|
className={'MountItemInput'}
|
||||||
type={'text'}
|
type={'text'}
|
||||||
value={props.location}/>
|
value={props.State.MountLocation}/>
|
||||||
</RootElem>
|
</RootElem>
|
||||||
));
|
));
|
||||||
inputControls.push((
|
inputControls.push((
|
||||||
<Button clicked={()=>props.browseClicked(props.title, props.location)}
|
<Button clicked={()=>props.browseClicked(props.title, props.State.MountLocation)}
|
||||||
col={inputColumnSpan - 7}
|
col={inputColumnSpan - 7}
|
||||||
colSpan={7}
|
colSpan={7}
|
||||||
disabled={props.mounted || !props.allowMount}
|
disabled={props.mounted || !props.allowMount}
|
||||||
@@ -82,7 +108,7 @@ export default connect(mapStateToProps)(props => {
|
|||||||
width='19px'/>;
|
width='19px'/>;
|
||||||
|
|
||||||
const actionsDisplay = (
|
const actionsDisplay = (
|
||||||
<Button clicked={()=>props.clicked(props.title, !props.mounted, props.location)}
|
<Button clicked={()=>props.clicked(props.title, !props.mounted, props.State.MountLocation)}
|
||||||
col={inputColumnSpan + 2}
|
col={inputColumnSpan + 2}
|
||||||
colSpan={21}
|
colSpan={21}
|
||||||
disabled={!props.allowMount}
|
disabled={!props.allowMount}
|
||||||
@@ -96,8 +122,8 @@ export default connect(mapStateToProps)(props => {
|
|||||||
colSpan={28}
|
colSpan={28}
|
||||||
row={secondRow}
|
row={secondRow}
|
||||||
rowSpan={7}>
|
rowSpan={7}>
|
||||||
<input checked={props.autoMount}
|
<input checked={props.State.AutoMount}
|
||||||
onChange={props.autoMountChanged}
|
onChange={handleAutoMountChanged}
|
||||||
type='checkbox'/>Auto-mount
|
type='checkbox'/>Auto-mount
|
||||||
</RootElem>
|
</RootElem>
|
||||||
);
|
);
|
||||||
@@ -107,8 +133,8 @@ export default connect(mapStateToProps)(props => {
|
|||||||
colSpan={24}
|
colSpan={24}
|
||||||
row={secondRow}
|
row={secondRow}
|
||||||
rowSpan={7}>
|
rowSpan={7}>
|
||||||
<input checked={props.autoRestart}
|
<input checked={props.State.AutoRestart}
|
||||||
onChange={props.autoRestartChanged}
|
onChange={handleAutoRestartChanged}
|
||||||
type='checkbox'/>Restart
|
type='checkbox'/>Restart
|
||||||
</RootElem>
|
</RootElem>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import Grid from '../UI/Grid/Grid';
|
|||||||
import Text from '../UI/Text/Text';
|
import Text from '../UI/Text/Text';
|
||||||
import Button from '../UI/Button/Button';
|
import Button from '../UI/Button/Button';
|
||||||
import UpgradeIcon from '../UpgradeIcon/UpgradeIcon';
|
import UpgradeIcon from '../UpgradeIcon/UpgradeIcon';
|
||||||
|
import {setActiveRelease} from "../../redux/actions/release_version_actions";
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
@@ -17,7 +18,23 @@ const mapStateToProps = state => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(props => {
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||||
|
const handleReleaseChanged = e => {
|
||||||
|
const release = parseInt(e.target.value, 10);
|
||||||
|
const releaseVersion = props.VersionLookup[Constants.RELEASE_TYPES[release]].length - 1;
|
||||||
|
props.setActiveRelease(release, releaseVersion);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVersionChanged = e => {
|
||||||
|
props.setActiveRelease(props.Release, parseInt(e.target.value, 10));
|
||||||
|
};
|
||||||
|
|
||||||
let optionsDisplay = [];
|
let optionsDisplay = [];
|
||||||
let key = 0;
|
let key = 0;
|
||||||
if (props.releaseExtracting) {
|
if (props.releaseExtracting) {
|
||||||
@@ -78,7 +95,7 @@ export default connect(mapStateToProps)(props => {
|
|||||||
text={'Release'}
|
text={'Release'}
|
||||||
textAlign={'left'}
|
textAlign={'left'}
|
||||||
type={'Heading2'}/>
|
type={'Heading2'}/>
|
||||||
<DropDown changed={props.releaseChanged}
|
<DropDown changed={handleReleaseChanged}
|
||||||
colSpan={remain=>remain / 3 - 1}
|
colSpan={remain=>remain / 3 - 1}
|
||||||
disabled={props.disabled}
|
disabled={props.disabled}
|
||||||
items={Constants.RELEASE_TYPES}
|
items={Constants.RELEASE_TYPES}
|
||||||
@@ -96,7 +113,7 @@ export default connect(mapStateToProps)(props => {
|
|||||||
colSpan={4}
|
colSpan={4}
|
||||||
release
|
release
|
||||||
rowSpan={4}/>
|
rowSpan={4}/>
|
||||||
<DropDown changed={props.versionChanged}
|
<DropDown changed={handleVersionChanged}
|
||||||
col={dimensions => dimensions.columns / 3}
|
col={dimensions => dimensions.columns / 3}
|
||||||
colSpan={remain=>remain / 2 - 1}
|
colSpan={remain=>remain / 2 - 1}
|
||||||
disabled={props.disabled}
|
disabled={props.disabled}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Configuration extends IPCContainer {
|
|||||||
this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
|
this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
|
||||||
|
|
||||||
this.sendRequest(Constants.IPC_Get_Config_Template, {
|
this.sendRequest(Constants.IPC_Get_Config_Template, {
|
||||||
StorageType: this.props.DisplayConfiguration,
|
Provider: this.props.DisplayConfiguration,
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ class Configuration extends IPCContainer {
|
|||||||
Template: arg.data.Template,
|
Template: arg.data.Template,
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
this.sendRequest(Constants.IPC_Get_Config, {
|
this.sendRequest(Constants.IPC_Get_Config, {
|
||||||
StorageType: this.props.DisplayConfiguration,
|
Provider: this.props.DisplayConfiguration,
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -192,7 +192,7 @@ class Configuration extends IPCContainer {
|
|||||||
|
|
||||||
this.sendRequest(Constants.IPC_Set_Config_Values, {
|
this.sendRequest(Constants.IPC_Set_Config_Values, {
|
||||||
Items: changedItems,
|
Items: changedItems,
|
||||||
StorageType: this.props.DisplayConfiguration,
|
Provider: this.props.DisplayConfiguration,
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import './MountItems.css';
|
|||||||
import Modal from '../../components/UI/Modal/Modal';
|
import Modal from '../../components/UI/Modal/Modal';
|
||||||
import MountItem from '../../components/MountItem/MountItem';
|
import MountItem from '../../components/MountItem/MountItem';
|
||||||
import IPCContainer from '../IPCContainer/IPCContainer';
|
import IPCContainer from '../IPCContainer/IPCContainer';
|
||||||
import {displayConfiguration, setAutoMountProcessed, setBusy} from '../../redux/actions/mount_actions';
|
import {
|
||||||
|
setAutoMountProcessed,
|
||||||
|
setBusy,
|
||||||
|
setProviderState
|
||||||
|
} from '../../redux/actions/mount_actions';
|
||||||
|
|
||||||
const Constants = require('../../constants');
|
const Constants = require('../../constants');
|
||||||
|
|
||||||
@@ -36,15 +40,15 @@ class MountItems extends IPCContainer {
|
|||||||
RetryItems: {},
|
RetryItems: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
cancelRetryMount = (storageType, stateCallback) => {
|
cancelRetryMount = (provider, stateCallback) => {
|
||||||
clearInterval(this.retryIntervals[storageType]);
|
clearInterval(this.retryIntervals[provider]);
|
||||||
delete this.retryIntervals[storageType];
|
delete this.retryIntervals[provider];
|
||||||
|
|
||||||
if (stateCallback) {
|
if (stateCallback) {
|
||||||
let retryItems = {
|
let retryItems = {
|
||||||
...this.state.RetryItems,
|
...this.state.RetryItems,
|
||||||
};
|
};
|
||||||
delete retryItems[storageType];
|
delete retryItems[provider];
|
||||||
this.setState({
|
this.setState({
|
||||||
DisplayRetry: Object.keys(retryItems).length > 0,
|
DisplayRetry: Object.keys(retryItems).length > 0,
|
||||||
RetryItems: retryItems,
|
RetryItems: retryItems,
|
||||||
@@ -58,9 +62,9 @@ class MountItems extends IPCContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
for (const storageType in this.state.RetryItems) {
|
for (const provider in this.state.RetryItems) {
|
||||||
if (this.state.RetryItems.hasOwnProperty(storageType)) {
|
if (this.state.RetryItems.hasOwnProperty(provider)) {
|
||||||
this.cancelRetryMount(storageType);
|
this.cancelRetryMount(provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,32 +80,36 @@ class MountItems extends IPCContainer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleBrowseLocation = (storageType, location) => {
|
handleBrowseLocation = (provider, location) => {
|
||||||
location = this.sendSyncRequest(Constants.IPC_Browse_Directory, {
|
location = this.sendSyncRequest(Constants.IPC_Browse_Directory, {
|
||||||
Title: storageType + ' Mount Location',
|
Title: provider + ' Mount Location',
|
||||||
Location: location,
|
Location: location,
|
||||||
});
|
});
|
||||||
if (location && (location.length > 0)) {
|
if (location && (location.length > 0)) {
|
||||||
this.handleMountLocationChanged(storageType, location);
|
this.handleMountLocationChanged(provider, location);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMountLocationChanged = (storageType, value) => {
|
handleMountLocationChanged = (provider, value) => {
|
||||||
if (this.props.Platform === 'win32') {
|
const location = (this.props.Platform === 'win32') ?
|
||||||
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
|
this.state[provider].DriveLetters[value] :
|
||||||
} else {
|
value;
|
||||||
this.props.changed(storageType, value);
|
|
||||||
}
|
const state = {
|
||||||
|
...this.props.ProviderState[provider],
|
||||||
|
MountLocation: location,
|
||||||
|
};
|
||||||
|
this.props.setProviderState(provider, state);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMountUnMount = (storageType, mount, location) => {
|
handleMountUnMount = (provider, mount, location) => {
|
||||||
if (!location || (location.trim().length === 0)) {
|
if (!location || (location.trim().length === 0)) {
|
||||||
this.props.errorHandler('Mount location is not set');
|
this.props.errorHandler('Mount location is not set');
|
||||||
} else {
|
} else {
|
||||||
let allowAction = true;
|
let allowAction = true;
|
||||||
if (mount) {
|
if (mount) {
|
||||||
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
||||||
StorageType: storageType,
|
Provider: provider,
|
||||||
Version: this.props.version
|
Version: this.props.version
|
||||||
}).data;
|
}).data;
|
||||||
if (result.Success) {
|
if (result.Success) {
|
||||||
@@ -117,7 +125,7 @@ class MountItems extends IPCContainer {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
allowAction = false;
|
allowAction = false;
|
||||||
this.props.errorHandler("Incompatible " + storageType + " daemon. Please upgrade " + storageType);
|
this.props.errorHandler("Incompatible " + provider + " daemon. Please upgrade " + provider);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
allowAction = false;
|
allowAction = false;
|
||||||
@@ -127,26 +135,26 @@ class MountItems extends IPCContainer {
|
|||||||
|
|
||||||
if (allowAction) {
|
if (allowAction) {
|
||||||
const storageState = {
|
const storageState = {
|
||||||
...this.state[storageType],
|
...this.state[provider],
|
||||||
AllowMount: false,
|
AllowMount: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.props.setMountsBusy(true);
|
this.props.setMountsBusy(true);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
[storageType]: storageState,
|
[provider]: storageState,
|
||||||
}, () => {
|
}, () => {
|
||||||
if (mount) {
|
if (mount) {
|
||||||
this.sendRequest(Constants.IPC_Mount_Drive, {
|
this.sendRequest(Constants.IPC_Mount_Drive, {
|
||||||
Location: location,
|
Location: location,
|
||||||
NoConsoleSupported: this.props.noConsoleSupported,
|
NoConsoleSupported: this.props.noConsoleSupported,
|
||||||
StorageType: storageType,
|
Provider: provider,
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.sendRequest(Constants.IPC_Unmount_Drive, {
|
this.sendRequest(Constants.IPC_Unmount_Drive, {
|
||||||
Location: location,
|
Location: location,
|
||||||
StorageType: storageType,
|
Provider: provider,
|
||||||
Version: this.props.version,
|
Version: this.props.version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -172,15 +180,15 @@ class MountItems extends IPCContainer {
|
|||||||
|
|
||||||
this.setState(state, () => {
|
this.setState(state, () => {
|
||||||
const updateMountLocation = (data, provider) => {
|
const updateMountLocation = (data, provider) => {
|
||||||
const providerLower = provider.toLowerCase();
|
const providerState = this.props.ProviderState[provider];
|
||||||
let location = data.Locations[provider];
|
let location = data.Locations[provider];
|
||||||
if (location.length === 0) {
|
if (location.length === 0) {
|
||||||
location = (this.props.Platform === 'win32') ?
|
location = (this.props.Platform === 'win32') ?
|
||||||
this.props[providerLower].MountLocation || data.DriveLetters[provider][0] :
|
providerState.MountLocation || data.DriveLetters[provider][0] :
|
||||||
this.props[providerLower].MountLocation;
|
providerState.MountLocation;
|
||||||
}
|
}
|
||||||
if (location !== this.props[providerLower].MountLocation) {
|
if (location !== providerState.MountLocation) {
|
||||||
this.props.changed(provider, location);
|
this.handleMountLocationChanged(provider, location);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -197,48 +205,48 @@ class MountItems extends IPCContainer {
|
|||||||
|
|
||||||
onMountDriveReply = (event, arg) => {
|
onMountDriveReply = (event, arg) => {
|
||||||
const state = {
|
const state = {
|
||||||
...this.state[arg.data.StorageType],
|
...this.state[arg.data.Provider],
|
||||||
Mounted: arg.data.Success,
|
Mounted: arg.data.Success,
|
||||||
};
|
};
|
||||||
this.setState({
|
this.setState({
|
||||||
[arg.data.StorageType]: state,
|
[arg.data.Provider]: state,
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
this.detectMounts();
|
this.detectMounts();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
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.ProviderState[arg.data.Provider].AutoRestart) {
|
||||||
const storageType = arg.data.StorageType;
|
const provider = arg.data.Provider;
|
||||||
if (!this.state.RetryItems[storageType]) {
|
if (!this.state.RetryItems[provider]) {
|
||||||
let retryItems = {
|
let retryItems = {
|
||||||
...this.state.RetryItems
|
...this.state.RetryItems
|
||||||
};
|
};
|
||||||
retryItems[storageType] = {
|
retryItems[provider] = {
|
||||||
RetrySeconds: 10,
|
RetrySeconds: 10,
|
||||||
};
|
};
|
||||||
const storageState = {
|
const storageState = {
|
||||||
...this.state[arg.data.StorageType],
|
...this.state[arg.data.Provider],
|
||||||
AllowMount: false,
|
AllowMount: false,
|
||||||
Mounted: false,
|
Mounted: false,
|
||||||
};
|
};
|
||||||
this.setState({
|
this.setState({
|
||||||
[storageType]: storageState,
|
[provider]: storageState,
|
||||||
DisplayRetry: true,
|
DisplayRetry: true,
|
||||||
RetryItems: retryItems,
|
RetryItems: retryItems,
|
||||||
}, () => {
|
}, () => {
|
||||||
this.sendRequest(Constants.IPC_Show_Window);
|
this.sendRequest(Constants.IPC_Show_Window);
|
||||||
this.retryIntervals[storageType] = setInterval(() => {
|
this.retryIntervals[provider] = setInterval(() => {
|
||||||
let retryItems = {
|
let retryItems = {
|
||||||
...this.state.RetryItems,
|
...this.state.RetryItems,
|
||||||
};
|
};
|
||||||
const retrySeconds = retryItems[storageType].RetrySeconds - 1;
|
const retrySeconds = retryItems[provider].RetrySeconds - 1;
|
||||||
if (retrySeconds === 0) {
|
if (retrySeconds === 0) {
|
||||||
this.cancelRetryMount(storageType, () => {
|
this.cancelRetryMount(provider, () => {
|
||||||
this.handleMountUnMount(storageType, true, arg.data.Location);
|
this.handleMountUnMount(provider, true, arg.data.Location);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
retryItems[storageType].RetrySeconds = retrySeconds;
|
retryItems[provider].RetrySeconds = retrySeconds;
|
||||||
this.setState({
|
this.setState({
|
||||||
RetryItems: retryItems,
|
RetryItems: retryItems,
|
||||||
});
|
});
|
||||||
@@ -256,11 +264,11 @@ class MountItems extends IPCContainer {
|
|||||||
this.props.setAutoMountProcessed(true);
|
this.props.setAutoMountProcessed(true);
|
||||||
|
|
||||||
const processAutoMount = (provider) => {
|
const processAutoMount = (provider) => {
|
||||||
const providerLower = provider.toLowerCase();
|
const providerState = this.props.ProviderState[provider];
|
||||||
if (this.props[providerLower].AutoMount &&
|
if (providerState.AutoMount &&
|
||||||
!this.state[provider].Mounted &&
|
!this.state[provider].Mounted &&
|
||||||
(this.props[providerLower].MountLocation.length > 0)) {
|
(providerState.MountLocation.length > 0)) {
|
||||||
this.handleMountUnMount(provider, true, this.props[providerLower].MountLocation);
|
this.handleMountUnMount(provider, true, providerState.MountLocation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -275,12 +283,12 @@ class MountItems extends IPCContainer {
|
|||||||
if (this.state.DisplayRetry) {
|
if (this.state.DisplayRetry) {
|
||||||
let retryList = [];
|
let retryList = [];
|
||||||
let retryListCount = 0;
|
let retryListCount = 0;
|
||||||
for (const storageType in this.state.RetryItems) {
|
for (const provider in this.state.RetryItems) {
|
||||||
if (this.state.RetryItems.hasOwnProperty(storageType)) {
|
if (this.state.RetryItems.hasOwnProperty(provider)) {
|
||||||
retryListCount++;
|
retryListCount++;
|
||||||
retryList.push(<Button
|
retryList.push(<Button
|
||||||
clicked={()=>this.cancelRetryMount(storageType, ()=> this.detectMounts())}
|
clicked={()=>this.cancelRetryMount(provider, ()=> this.detectMounts())}
|
||||||
key={'b' + retryListCount}>Cancel {storageType} Remount ({this.state.RetryItems[storageType].RetrySeconds}s)</Button>);
|
key={'b' + retryListCount}>Cancel {provider} Remount ({this.state.RetryItems[provider].RetrySeconds}s)</Button>);
|
||||||
if (retryListCount < Object.keys(this.state.RetryItems).length) {
|
if (retryListCount < Object.keys(this.state.RetryItems).length) {
|
||||||
retryList.push(<div style={{paddingTop: '8px'}} key={'d' + retryListCount}/>);
|
retryList.push(<div style={{paddingTop: '8px'}} key={'d' + retryListCount}/>);
|
||||||
}
|
}
|
||||||
@@ -299,21 +307,15 @@ class MountItems extends IPCContainer {
|
|||||||
|
|
||||||
let items = [];
|
let items = [];
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
const providerLower = provider.toLowerCase();
|
|
||||||
items.push((
|
items.push((
|
||||||
<MountItem allowConfig={this.props.allowConfig}
|
<MountItem allowConfig={this.props.allowConfig}
|
||||||
allowMount={this.state[provider].AllowMount}
|
allowMount={this.state[provider].AllowMount}
|
||||||
autoMount={this.props[providerLower].AutoMount}
|
|
||||||
autoMountChanged={(e)=>this.props.autoMountChanged(provider, e)}
|
|
||||||
autoRestart={this.props[providerLower].AutoRestart}
|
|
||||||
autoRestartChanged={(e)=>this.props.autoRestartChanged(provider, e)}
|
|
||||||
browseClicked={this.handleBrowseLocation}
|
browseClicked={this.handleBrowseLocation}
|
||||||
changed={(e) => this.handleMountLocationChanged(provider, e.target.value)}
|
changed={e => this.handleMountLocationChanged(provider, e.target.value)}
|
||||||
clicked={this.handleMountUnMount}
|
clicked={this.handleMountUnMount}
|
||||||
configClicked={()=>this.props.displayConfiguration(provider)}
|
|
||||||
items={this.state[provider].DriveLetters}
|
items={this.state[provider].DriveLetters}
|
||||||
key={'mi_' + items.length}
|
key={'mi_' + items.length}
|
||||||
location={this.props[providerLower].MountLocation}
|
provider={provider}
|
||||||
mounted={this.state[provider].Mounted}
|
mounted={this.state[provider].Mounted}
|
||||||
title={provider} />
|
title={provider} />
|
||||||
));
|
));
|
||||||
@@ -335,14 +337,15 @@ const mapStateToProps = state => {
|
|||||||
return {
|
return {
|
||||||
AutoMountProcessed: state.mounts.AutoMountProcessed,
|
AutoMountProcessed: state.mounts.AutoMountProcessed,
|
||||||
Platform: state.common.Platform,
|
Platform: state.common.Platform,
|
||||||
|
ProviderState: state.mounts.ProviderState,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
displayConfiguration: storageType => dispatch(displayConfiguration(storageType)),
|
|
||||||
setAutoMountProcessed: processed => dispatch(setAutoMountProcessed(processed)),
|
setAutoMountProcessed: processed => dispatch(setAutoMountProcessed(processed)),
|
||||||
setMountsBusy: busy => dispatch(setBusy(busy)),
|
setMountsBusy: busy => dispatch(setBusy(busy)),
|
||||||
|
setProviderState: (provider, state) => dispatch(setProviderState(provider, state)),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const tryParse = (j, def) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.checkDaemonVersion = (version, storageType) => {
|
module.exports.checkDaemonVersion = (version, provider) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -41,8 +41,8 @@ module.exports.checkDaemonVersion = (version, storageType) => {
|
|||||||
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-cv');
|
args.push('-cv');
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[provider.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[provider.toLowerCase()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const process = new spawn(command, args, processOptions);
|
const process = new spawn(command, args, processOptions);
|
||||||
@@ -254,7 +254,7 @@ module.exports.executeScript = script => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.executeMount = (version, storageType, location, noConsoleSupported, exitCallback) => {
|
module.exports.executeMount = (version, provider, location, noConsoleSupported, exitCallback) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: false,
|
detached: false,
|
||||||
@@ -264,8 +264,8 @@ module.exports.executeMount = (version, storageType, location, noConsoleSupporte
|
|||||||
|
|
||||||
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[provider.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[provider.toLowerCase()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((os.platform() === 'linux') || (os.platform() === 'darwin')) {
|
if ((os.platform() === 'linux') || (os.platform() === 'darwin')) {
|
||||||
@@ -299,7 +299,7 @@ module.exports.executeMount = (version, storageType, location, noConsoleSupporte
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getConfig = (version, storageType) => {
|
module.exports.getConfig = (version, provider) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -310,8 +310,8 @@ module.exports.getConfig = (version, storageType) => {
|
|||||||
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-dc');
|
args.push('-dc');
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[provider.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[provider.toLowerCase()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const process = new spawn(command, args, processOptions);
|
const process = new spawn(command, args, processOptions);
|
||||||
@@ -345,7 +345,7 @@ module.exports.getConfig = (version, storageType) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getConfigTemplate = (version, storageType) => {
|
module.exports.getConfigTemplate = (version, provider) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -356,8 +356,8 @@ module.exports.getConfigTemplate = (version, storageType) => {
|
|||||||
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = [];
|
const args = [];
|
||||||
args.push('-gt');
|
args.push('-gt');
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[provider.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[provider.toLowerCase()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const process = new spawn(command, args, processOptions);
|
const process = new spawn(command, args, processOptions);
|
||||||
@@ -500,7 +500,7 @@ module.exports.removeDirectoryRecursively = (p) => {
|
|||||||
|
|
||||||
module.exports.resolvePath = _resolvePath;
|
module.exports.resolvePath = _resolvePath;
|
||||||
|
|
||||||
module.exports.setConfigValue = (name, value, storageType, version) => {
|
module.exports.setConfigValue = (name, value, provider, version) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -513,8 +513,8 @@ module.exports.setConfigValue = (name, value, storageType, version) => {
|
|||||||
args.push('-set');
|
args.push('-set');
|
||||||
args.push(name);
|
args.push(name);
|
||||||
args.push(value);
|
args.push(value);
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[provider.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[provider.toLowerCase()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const process = new spawn(command, args, processOptions);
|
const process = new spawn(command, args, processOptions);
|
||||||
@@ -531,7 +531,7 @@ module.exports.setConfigValue = (name, value, storageType, version) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.stopMountProcess = (version, storageType) => {
|
module.exports.stopMountProcess = (version, provider) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: os.platform() === 'darwin',
|
detached: os.platform() === 'darwin',
|
||||||
@@ -541,8 +541,8 @@ module.exports.stopMountProcess = (version, storageType) => {
|
|||||||
|
|
||||||
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = ['-unmount'];
|
const args = ['-unmount'];
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[provider.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[provider.toLowerCase()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const process = new spawn(command, args, processOptions);
|
const process = new spawn(command, args, processOptions);
|
||||||
@@ -563,7 +563,7 @@ module.exports.stopMountProcess = (version, storageType) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.stopMountProcessSync = (version, storageType) => {
|
module.exports.stopMountProcessSync = (version, provider) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
shell: os.platform() !== 'darwin',
|
shell: os.platform() !== 'darwin',
|
||||||
@@ -572,8 +572,8 @@ module.exports.stopMountProcessSync = (version, storageType) => {
|
|||||||
|
|
||||||
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
const args = ['-unmount'];
|
const args = ['-unmount'];
|
||||||
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
if (Constants.PROVIDER_ARG[provider.toLowerCase()].length > 0) {
|
||||||
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
args.push(Constants.PROVIDER_ARG[provider.toLowerCase()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const process = new spawn(command, args, processOptions);
|
const process = new spawn(command, args, processOptions);
|
||||||
|
|||||||
@@ -2,4 +2,14 @@ import {createAction} from 'redux-starter-kit';
|
|||||||
|
|
||||||
export const displayConfiguration = createAction('mounts/displayConfiguration');
|
export const displayConfiguration = createAction('mounts/displayConfiguration');
|
||||||
export const setAutoMountProcessed = createAction('mounts/setAutoMountProcessed');
|
export const setAutoMountProcessed = createAction('mounts/setAutoMountProcessed');
|
||||||
export const setBusy = createAction('mounts/setBusy');
|
export const setBusy = createAction('mounts/setBusy');
|
||||||
|
export const SET_PROVIDER_STATE = 'mounts/setProviderState';
|
||||||
|
export const setProviderState = (provider, state) => {
|
||||||
|
return {
|
||||||
|
type: SET_PROVIDER_STATE,
|
||||||
|
payload: {
|
||||||
|
provider,
|
||||||
|
state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,10 +1,27 @@
|
|||||||
|
import * as Constants from '../../constants';
|
||||||
import {createReducer} from 'redux-starter-kit';
|
import {createReducer} from 'redux-starter-kit';
|
||||||
import {displayConfiguration, setAutoMountProcessed, setBusy} from '../actions/mount_actions';
|
import {displayConfiguration, setAutoMountProcessed, setBusy, SET_PROVIDER_STATE} from '../actions/mount_actions';
|
||||||
|
|
||||||
|
const providerState = Constants.PROVIDER_LIST.map(p=> {
|
||||||
|
return {
|
||||||
|
[p]: {
|
||||||
|
AutoMount: false,
|
||||||
|
AutoRestart: false,
|
||||||
|
MountLocation: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).reduce((map, obj) => {
|
||||||
|
return {
|
||||||
|
...map,
|
||||||
|
...obj
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export const mountReducer = createReducer({
|
export const mountReducer = createReducer({
|
||||||
AutoMountProcessed: false,
|
AutoMountProcessed: false,
|
||||||
DisplayConfiguration: null,
|
DisplayConfiguration: null,
|
||||||
MountsBusy: false,
|
MountsBusy: false,
|
||||||
|
ProviderState: providerState,
|
||||||
}, {
|
}, {
|
||||||
[displayConfiguration]: (state, action) => {
|
[displayConfiguration]: (state, action) => {
|
||||||
return {...state, DisplayConfiguration: action.payload};
|
return {...state, DisplayConfiguration: action.payload};
|
||||||
@@ -14,5 +31,14 @@ export const mountReducer = createReducer({
|
|||||||
},
|
},
|
||||||
[setBusy]: (state, action) => {
|
[setBusy]: (state, action) => {
|
||||||
return {...state, MountsBusy: action.payload};
|
return {...state, MountsBusy: action.payload};
|
||||||
|
},
|
||||||
|
[SET_PROVIDER_STATE]: (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
ProviderState: {
|
||||||
|
...state.ProviderState,
|
||||||
|
[action.payload.provider]: action.payload.state,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user