From 522626e8087cfab6a6bfb71c39bb19d33bb9eff9 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 7 Oct 2019 16:18:03 -0500 Subject: [PATCH] [Fix VC runtime detection] [Remote mount changes] --- package.json | 20 ++--- public/electron.js | 30 ++++--- .../ConfigurationItem/ConfigurationItem.js | 8 ++ src/containers/Configuration/Configuration.js | 17 +++- src/helpers.js | 88 +++++++++++-------- 5 files changed, 101 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index dd67fa2..24b1880 100644 --- a/package.json +++ b/package.json @@ -9,27 +9,27 @@ "@fortawesome/free-solid-svg-icons": "^5.11.2", "@fortawesome/react-fontawesome": "^0.1.5", "auto-launch": "^5.0.5", - "axios": "^0.18.1", - "electron-debug": "^2.2.0", + "axios": "^0.19.0", + "electron-debug": "^3.0.1", "font-awesome": "^4.7.0", "node-schedule": "^1.3.2", "randomstring": "^1.1.5", - "react": "^16.10.1", - "react-dom": "^16.10.1", - "react-loader-spinner": "^2.3.0", + "react": "^16.10.2", + "react-dom": "^16.10.2", + "react-loader-spinner": "^3.1.4", "react-redux": "^7.1.1", "react-scripts": "2.1.8", "react-tooltip": "^3.11.1", "redux": "^4.0.4", - "redux-starter-kit": "^0.5.1", + "redux-starter-kit": "^0.7.0", "redux-thunk": "^2.3.0", - "unzipper": "^0.9.15", + "unzipper": "^0.10.5", "winreg": "^1.2.4" }, "devDependencies": { - "cross-env": "^5.2.1", - "electron": "^4.2.11", - "electron-builder": "^20.44.4", + "cross-env": "^6.0.3", + "electron": "^6.0.11", + "electron-builder": "^21.2.0", "extract-text-webpack-plugin": "^3.0.2", "typescript": "^3.6.3", "webpack-browser-plugin": "^1.0.20" diff --git a/public/electron.js b/public/electron.js index ecbd338..95013f2 100644 --- a/public/electron.js +++ b/public/electron.js @@ -34,6 +34,11 @@ const StateIPC = require('../src/renderer/ipc/StateIPC'); const SystemIPC = require('../src/renderer/ipc/SystemIPC'); const UpgradeIPC = require('../src/renderer/ipc/UpgradeIPC'); +const dimensions = { + height: ((os.platform() === 'darwin') ? 294 : 274) + ((os.platform() === 'win32') ? 30 : -20), + width: 428 + ((os.platform() === 'win32') ? 40 : (os.platform() === 'darwin') ? 150 : 160), +}; + let isShutdown = false; let isQuiting = false; let isInstalling = false; @@ -77,19 +82,20 @@ const createWindow = () => { } // Create the browser window. - const height = (process.env.ELECTRON_START_URL || (os.platform() === 'darwin') ? 294 : 274) + ((os.platform() === 'win32') ? 30 : -20); mainWindow = new BrowserWindow({ - width: 428 + ((os.platform() === 'win32') ? 40 : (os.platform() === 'darwin') ? 150 : 160), - height: height, + height: dimensions.height, + width: dimensions.width, fullscreen: false, resizable: false, show: !launchHidden, title: 'Repertory UI', ...extra, webPreferences: { + nodeIntegration: true, webSecurity: !process.env.ELECTRON_START_URL } }); + mainWindow.removeMenu(); if ((os.platform() === 'darwin') && launchHidden) { app.dock.hide(); @@ -170,15 +176,15 @@ const createWindow = () => { mainWindowTray = new Tray(image); autoLauncher - .isEnabled() - .then((enabled) => { - trayContextMenu.items[1].checked = enabled; - mainWindowTray.setToolTip('Repertory UI'); - mainWindowTray.setContextMenu(trayContextMenu) - }) - .catch(() => { - closeApplication(); - }); + .isEnabled() + .then((enabled) => { + trayContextMenu.items[1].checked = enabled; + mainWindowTray.setToolTip('Repertory UI'); + mainWindowTray.setContextMenu(trayContextMenu) + }) + .catch(() => { + closeApplication(); + }); mainWindow.loadURL(startUrl); }; diff --git a/src/components/ConfigurationItem/ConfigurationItem.js b/src/components/ConfigurationItem/ConfigurationItem.js index f143839..22e4097 100644 --- a/src/components/ConfigurationItem/ConfigurationItem.js +++ b/src/components/ConfigurationItem/ConfigurationItem.js @@ -37,12 +37,14 @@ export default connect(null, mapDispatchToProps)(props => { switch (props.template.type) { case "bool": data = handleChanged(e)} type={'checkbox'}/>; break; case "double": data = handleChanged(e)} step={"0.01"} className={'ConfigurationItemInput'} @@ -60,6 +62,7 @@ export default connect(null, mapDispatchToProps)(props => { data = ( @@ -69,6 +72,7 @@ export default connect(null, mapDispatchToProps)(props => { case "string": data = handleChanged(e)} className={'ConfigurationItemInput'} + disabled={props.readOnly} type={'text'} value={props.value}/>; break; @@ -76,6 +80,7 @@ export default connect(null, mapDispatchToProps)(props => { case "uint8": data = handleChanged(e)} className={'ConfigurationItemInput'} type={'number'} @@ -85,6 +90,7 @@ export default connect(null, mapDispatchToProps)(props => { case "uint16": data = handleChanged(e)} className={'ConfigurationItemInput'} type={'number'} @@ -94,6 +100,7 @@ export default connect(null, mapDispatchToProps)(props => { case "uint32": data = handleChanged(e)} className={'ConfigurationItemInput'} type={'number'} @@ -103,6 +110,7 @@ export default connect(null, mapDispatchToProps)(props => { case "uint64": data = handleChanged(e)} className={'ConfigurationItemInput'} type={'number'} diff --git a/src/containers/Configuration/Configuration.js b/src/containers/Configuration/Configuration.js index e231565..9b743d3 100644 --- a/src/containers/Configuration/Configuration.js +++ b/src/containers/Configuration/Configuration.js @@ -20,6 +20,7 @@ class Configuration extends IPCContainer { ObjectLookup: {}, OriginalItemList: [], OriginalObjectLookup: {}, + IsRemoteMount: false, ItemList: [], Saving: false, ShowAdvanced: false, @@ -87,6 +88,7 @@ class Configuration extends IPCContainer { .map(key => { return { advanced: template[key] ? template[key].advanced : false, + hide_remote: template[key] ? template[key].hide_remote : false, label: key, remote: template[key] ? template[key].remote : false, value: (template[key] && (template[key].type === 'object')) ? @@ -143,8 +145,20 @@ class Configuration extends IPCContainer { const list2 = this.createItemList(obj.value, this.state.Template[obj.label].template); objectLookup[obj.label] = list2.ItemList; } + + const isRemoteMount = this.props.remoteSupported && + JSON.parse(objectLookup['RemoteMount'].find(s => s.label === 'IsRemoteMount').value); + if (isRemoteMount) { + for (const obj of list.ObjectList) { + if (obj.hide_remote) { + delete objectLookup[obj.label]; + } + } + } + const objectLookupCopy = JSON.parse(JSON.stringify(objectLookup)); this.setState({ + IsRemoteMount: isRemoteMount, ItemList: list.ItemList, ObjectLookup: objectLookup, OriginalItemList: itemListCopy, @@ -250,7 +264,7 @@ class Configuration extends IPCContainer { const configurationItems = this.state.ItemList .map((k, i) => { return ( - (!k.advanced || (this.state.ShowAdvanced && k.advanced)) ? + ((!this.state.IsRemoteMount || !k.hide_remote) && (!k.advanced || (this.state.ShowAdvanced && k.advanced))) ? this.handleItemChanged(e, i)} grouping={'Settings'} @@ -278,6 +292,7 @@ class Configuration extends IPCContainer { items={this.state.Template[key].template[k.label].items} key={i} label={k.label} + readOnly={this.state.IsRemoteMount && ((k.label === 'RemoteHostNameOrIp') || (k.label === 'RemotePort'))} template={this.state.Template[key].template[k.label]} value={k.value}/> : null) diff --git a/src/helpers.js b/src/helpers.js index c84907c..e895fcc 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -488,46 +488,56 @@ module.exports.getMissingDependencies = dependencies => { }; const Registry = require('winreg'); - for (const dep of dependencies) { - let hive = null; - const hiveName = dep.registry[0].split('\\')[0]; - switch (hiveName) { - case 'HKEY_CLASSES_ROOT': - hive = Registry.HKCR; - break; - case 'HKEY_CURRENT_CONFIG': - hive = Registry.HKCC; - break; - case 'HKEY_CURRENT_USER': - hive = Registry.HKCU; - break; - case 'HKEY_LOCAL_MACHINE': - hive = Registry.HKLM; - break; - case 'HKEY_USERS': - hive = Registry.HKU; - break; - default: - throw Error('Invalid registry hive: ' + hiveName); - } - - const key = dep.registry[0].substr(hiveName.length); - const regKey = new Registry({ - hive: hive, - key: key - }); - regKey.valueExists('DisplayName', (err, exists) => { - if (err || !exists) { - regKey.valueExists('ProductName', (err, exists) => { - if (err || !exists) { - missing.push(dep); - } - resolveIfComplete(); - }); - } else { - resolveIfComplete(); + const checkRegistry = (dep, index) => { + if (index >= dep.registry.length) { + missing.push(dep); + resolveIfComplete(); + } else { + let hive = null; + const hiveName = dep.registry[index].split('\\')[0]; + switch (hiveName) { + case 'HKEY_CLASSES_ROOT': + hive = Registry.HKCR; + break; + case 'HKEY_CURRENT_CONFIG': + hive = Registry.HKCC; + break; + case 'HKEY_CURRENT_USER': + hive = Registry.HKCU; + break; + case 'HKEY_LOCAL_MACHINE': + hive = Registry.HKLM; + break; + case 'HKEY_USERS': + hive = Registry.HKU; + break; + default: + throw Error('Invalid registry hive: ' + hiveName); } - }); + + const key = dep.registry[index].substr(hiveName.length); + const regKey = new Registry({ + hive: hive, + key: key + }); + regKey.valueExists('DisplayName', (err, exists) => { + if (err || !exists) { + regKey.valueExists('ProductName', (err, exists) => { + if (err || !exists) { + checkRegistry(dep, ++index); + } else { + resolveIfComplete(); + } + }); + } else { + resolveIfComplete(); + } + }); + } + }; + + for (const dependency of dependencies) { + checkRegistry(dependency,0); } } else { for (const dep of dependencies) {