{objectItems}
{(configurationItems.length > 0) ?
Settings
: null}
@@ -276,4 +275,16 @@ class Configuration extends IPCContainer {
}
}
-export default Configuration;
\ No newline at end of file
+const mapStateToProps = state => {
+ return {
+ DisplayConfiguration: state.mounts.DisplayConfiguration,
+ }
+};
+
+const mapDispatchToProps = dispatch => {
+ return {
+ hideConfiguration: () => dispatch(displayConfiguration(null)),
+ }
+};
+
+export default connect(mapStateToProps, mapDispatchToProps)(Configuration);
\ No newline at end of file
diff --git a/src/containers/MountItems/MountItems.js b/src/containers/MountItems/MountItems.js
index e90b3e4..8239041 100644
--- a/src/containers/MountItems/MountItems.js
+++ b/src/containers/MountItems/MountItems.js
@@ -6,7 +6,7 @@ import './MountItems.css';
import Modal from '../../components/UI/Modal/Modal';
import MountItem from '../../components/MountItem/MountItem';
import IPCContainer from '../IPCContainer/IPCContainer';
-import {setBusy} from '../../redux/actions/mount_actions';
+import {displayConfiguration, setAutoMountProcessed, setBusy} from '../../redux/actions/mount_actions';
const Constants = require('../../constants');
@@ -71,7 +71,6 @@ class MountItems extends IPCContainer {
if (!this.state.DisplayRetry) {
this.props.setMountsBusy(true);
this.sendRequest(Constants.IPC_Detect_Mounts, {
- Directory: this.props.directory,
Version: this.props.version,
});
}
@@ -88,7 +87,7 @@ class MountItems extends IPCContainer {
};
handleMountLocationChanged = (storageType, value) => {
- if (this.props.platform === 'win32') {
+ if (this.props.Platform === 'win32') {
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
} else {
this.props.changed(storageType, value);
@@ -102,13 +101,12 @@ class MountItems extends IPCContainer {
let allowAction = true;
if (mount) {
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
- Directory: this.props.directory,
StorageType: storageType,
Version: this.props.version
}).data;
if (result.Success) {
if (result.Valid) {
- if (this.props.platform !== 'win32') {
+ if (this.props.Platform !== 'win32') {
result = this.sendSyncRequest(Constants.IPC_Check_Mount_Location, {
Location: location,
});
@@ -140,7 +138,6 @@ class MountItems extends IPCContainer {
}, () => {
if (mount) {
this.sendRequest(Constants.IPC_Mount_Drive, {
- Directory: this.props.directory,
Location: location,
NoConsoleSupported: this.props.noConsoleSupported,
StorageType: storageType,
@@ -148,7 +145,6 @@ class MountItems extends IPCContainer {
});
} else {
this.sendRequest(Constants.IPC_Unmount_Drive, {
- Directory: this.props.directory,
Location: location,
StorageType: storageType,
Version: this.props.version,
@@ -179,7 +175,7 @@ class MountItems extends IPCContainer {
const providerLower = provider.toLowerCase();
let location = data.Locations[provider];
if (location.length === 0) {
- location = (this.props.platform === 'win32') ?
+ location = (this.props.Platform === 'win32') ?
this.props[providerLower].MountLocation || data.DriveLetters[provider][0] :
this.props[providerLower].MountLocation;
}
@@ -256,8 +252,9 @@ class MountItems extends IPCContainer {
};
performAutoMount = ()=> {
- if (this.props.processAutoMount) {
- this.props.autoMountProcessed();
+ if (!this.props.AutoMountProcessed) {
+ this.props.setAutoMountProcessed(true);
+
const processAutoMount = (provider) => {
const providerLower = provider.toLowerCase();
if (this.props[providerLower].AutoMount &&
@@ -313,12 +310,11 @@ class MountItems extends IPCContainer {
browseClicked={this.handleBrowseLocation}
changed={(e) => this.handleMountLocationChanged(provider, e.target.value)}
clicked={this.handleMountUnMount}
- configClicked={()=>this.props.configClicked(provider)}
+ configClicked={()=>this.props.displayConfiguration(provider)}
items={this.state[provider].DriveLetters}
key={'mi_' + items.length}
location={this.props[providerLower].MountLocation}
mounted={this.state[provider].Mounted}
- platform={this.props.platform}
title={provider} />
));
if (items.length !== this.state.length) {
@@ -335,10 +331,19 @@ class MountItems extends IPCContainer {
}
}
-const mapDispatchToProps = dispatch => {
+const mapStateToProps = state => {
return {
- setMountsBusy: busy => dispatch(setBusy(busy))
+ AutoMountProcessed: state.mounts.AutoMountProcessed,
+ Platform: state.common.Platform,
}
};
-export default connect(null, mapDispatchToProps)(MountItems);
\ No newline at end of file
+const mapDispatchToProps = dispatch => {
+ return {
+ displayConfiguration: storageType => dispatch(displayConfiguration(storageType)),
+ setAutoMountProcessed: processed => dispatch(setAutoMountProcessed(processed)),
+ setMountsBusy: busy => dispatch(setBusy(busy)),
+ }
+};
+
+export default connect(mapStateToProps, mapDispatchToProps)(MountItems);
\ No newline at end of file
diff --git a/src/helpers.js b/src/helpers.js
index 5dd3538..1863ac3 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -8,6 +8,20 @@ const spawn = require('child_process').spawn;
const Constants = require('./constants');
const RandomString = require('randomstring');
+const _getDataDirectory = () => {
+ return _resolvePath(Constants.DATA_LOCATIONS[os.platform()]);
+};
+
+const _resolvePath = str => {
+ if (os.platform() === 'win32') {
+ return str.replace(/%([^%]+)%/g, (_, n) => {
+ return process.env[n];
+ });
+ } else {
+ return str.replace('~', os.homedir());
+ }
+};
+
const tryParse = (j, def) => {
try {
return JSON.parse(j);
@@ -16,7 +30,7 @@ const tryParse = (j, def) => {
}
};
-module.exports.checkDaemonVersion = (directory, version, storageType) => {
+module.exports.checkDaemonVersion = (version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
@@ -24,7 +38,7 @@ module.exports.checkDaemonVersion = (directory, version, storageType) => {
windowsHide: true,
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ 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) {
@@ -67,7 +81,7 @@ module.exports.createSignatureFiles = (signature, publicKey) => {
};
};
-module.exports.detectRepertoryMounts = (directory, version) => {
+module.exports.detectRepertoryMounts = version => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
@@ -75,7 +89,7 @@ module.exports.detectRepertoryMounts = (directory, version) => {
windowsHide: true,
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
const args = [];
args.push('-status');
@@ -240,7 +254,7 @@ module.exports.executeScript = script => {
});
};
-module.exports.executeMount = (directory, version, storageType, location, noConsoleSupported, exitCallback) => {
+module.exports.executeMount = (version, storageType, location, noConsoleSupported, exitCallback) => {
return new Promise((resolve) => {
const processOptions = {
detached: false,
@@ -248,7 +262,7 @@ module.exports.executeMount = (directory, version, storageType, location, noCons
stdio: 'ignore',
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ 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()]);
@@ -285,7 +299,7 @@ module.exports.executeMount = (directory, version, storageType, location, noCons
});
};
-module.exports.getConfig = (directory, version, storageType) => {
+module.exports.getConfig = (version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
@@ -293,7 +307,7 @@ module.exports.getConfig = (directory, version, storageType) => {
windowsHide: true,
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ 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) {
@@ -331,7 +345,7 @@ module.exports.getConfig = (directory, version, storageType) => {
});
};
-module.exports.getConfigTemplate = (directory, version, storageType) => {
+module.exports.getConfigTemplate = (version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
@@ -339,7 +353,7 @@ module.exports.getConfigTemplate = (directory, version, storageType) => {
windowsHide: true,
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ 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) {
@@ -364,6 +378,8 @@ module.exports.getConfigTemplate = (directory, version, storageType) => {
});
};
+module.exports.getDataDirectory = _getDataDirectory;
+
module.exports.getMissingDependencies = dependencies => {
return new Promise((resolve, reject) => {
if (!dependencies) {
@@ -482,17 +498,9 @@ module.exports.removeDirectoryRecursively = (p) => {
}
};
-module.exports.resolvePath = str => {
- if (os.platform() === 'win32') {
- return str.replace(/%([^%]+)%/g, (_, n) => {
- return process.env[n];
- });
- } else {
- return str.replace('~', os.homedir());
- }
-};
+module.exports.resolvePath = _resolvePath;
-module.exports.setConfigValue = (name, value, directory, storageType, version) => {
+module.exports.setConfigValue = (name, value, storageType, version) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
@@ -500,7 +508,7 @@ module.exports.setConfigValue = (name, value, directory, storageType, version) =
windowsHide: true,
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
const args = [];
args.push('-set');
args.push(name);
@@ -523,7 +531,7 @@ module.exports.setConfigValue = (name, value, directory, storageType, version) =
});
};
-module.exports.stopMountProcess = (directory, version, storageType) => {
+module.exports.stopMountProcess = (version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: os.platform() === 'darwin',
@@ -531,7 +539,7 @@ module.exports.stopMountProcess = (directory, version, storageType) => {
windowsHide: true,
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ 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()]);
@@ -555,14 +563,14 @@ module.exports.stopMountProcess = (directory, version, storageType) => {
});
};
-module.exports.stopMountProcessSync = (directory, version, storageType) => {
+module.exports.stopMountProcessSync = (version, storageType) => {
const processOptions = {
detached: true,
shell: os.platform() !== 'darwin',
windowsHide: true,
};
- const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
+ 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()]);
diff --git a/src/index.js b/src/index.js
index 5a68ab2..24b4d61 100644
--- a/src/index.js
+++ b/src/index.js
@@ -3,27 +3,27 @@ import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import createAppStore from './redux/store/createAppStore';
-import * as serviceWorker from './serviceWorker';
import packageJson from '../package.json';
import {Provider} from 'react-redux';
+import * as serviceWorker from './serviceWorker';
const Constants = require('./constants');
-const store = createAppStore({});
-
if (!process.versions.hasOwnProperty('electron')) {
const ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
if (ipcRenderer) {
ipcRenderer.on(Constants.IPC_Get_Platform_Reply, (event, arg) => {
- if (arg.OSPlatform === 'linux') {
+ if (arg.Platform === 'linux') {
const root = document.documentElement;
root.style.setProperty('--default_font_size', '15px');
}
+ const store = createAppStore(arg.Platform, arg.AppPlatform);
ReactDOM.render((
-
- ), document.getElementById('root'));
+
+
+ ), document.getElementById('root'));
serviceWorker.unregister();
});
ipcRenderer.send(Constants.IPC_Get_Platform);
diff --git a/src/redux/actions/mount_actions.js b/src/redux/actions/mount_actions.js
index 71fbbf8..ba38ed2 100644
--- a/src/redux/actions/mount_actions.js
+++ b/src/redux/actions/mount_actions.js
@@ -1,3 +1,5 @@
-import {createAction} from "redux-starter-kit";
+import {createAction} from 'redux-starter-kit';
+export const displayConfiguration = createAction('mounts/displayConfiguration');
+export const setAutoMountProcessed = createAction('mounts/setAutoMountProcessed');
export const setBusy = createAction('mounts/setBusy');
\ No newline at end of file
diff --git a/src/redux/reducers/mount_reducer.js b/src/redux/reducers/mount_reducer.js
index da15e2a..88baeb0 100644
--- a/src/redux/reducers/mount_reducer.js
+++ b/src/redux/reducers/mount_reducer.js
@@ -1,9 +1,17 @@
import {createReducer} from 'redux-starter-kit';
-import {setBusy} from '../actions/mount_actions';
+import {displayConfiguration, setAutoMountProcessed, setBusy} from '../actions/mount_actions';
export const mountReducer = createReducer({
+ AutoMountProcessed: false,
+ DisplayConfiguration: null,
MountsBusy: false,
}, {
+ [displayConfiguration]: (state, action) => {
+ return {...state, DisplayConfiguration: action.payload};
+ },
+ [setAutoMountProcessed]: (state, action) => {
+ return {...state, AutoMountProcessed: action.payload};
+ },
[setBusy]: (state, action) => {
return {...state, MountsBusy: action.payload};
}
diff --git a/src/redux/store/createAppStore.js b/src/redux/store/createAppStore.js
index 0cb8565..d663cef 100644
--- a/src/redux/store/createAppStore.js
+++ b/src/redux/store/createAppStore.js
@@ -1,8 +1,16 @@
-import { configureStore, getDefaultMiddleware } from 'redux-starter-kit';
+import {configureStore, createReducer, getDefaultMiddleware} from 'redux-starter-kit';
import {mountReducer} from '../reducers/mount_reducer';
-export default function createAppStore(preloadedState) {
+export default function createAppStore(platform, appPlatform) {
+ const createCommonReducer = () => {
+ return createReducer({
+ AppPlatform: appPlatform,
+ Platform: platform,
+ }, {});
+ };
+
const reducer = {
+ common: createCommonReducer(platform, appPlatform),
mounts: mountReducer,
};
@@ -11,7 +19,6 @@ export default function createAppStore(preloadedState) {
return configureStore({
reducer,
middleware,
- devTools: process.env.NODE_ENV !== 'production',
- preloadedState
+ devTools: process.env.NODE_ENV !== 'production'
});
}
\ No newline at end of file