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