From 8618bf99650adfd6864e06322c880233fd6c91bf Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 13 Dec 2018 15:00:07 -0600 Subject: [PATCH] [Partial browse mount location] [Layout changes] --- electron.js | 16 +++++++++- src/components/MountItem/MountItem.css | 3 +- src/components/MountItem/MountItem.js | 41 +++++++++++++++++-------- src/constants.js | 2 ++ src/containers/MountItems/MountItems.js | 12 ++++++++ 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/electron.js b/electron.js index 5175b7c..defc41c 100644 --- a/electron.js +++ b/electron.js @@ -1,6 +1,6 @@ // Modules to control application life and create native browser window -const {app, BrowserWindow, Tray, nativeImage, Menu} = require('electron'); +const {app, BrowserWindow, Tray, nativeImage, Menu, dialog} = require('electron'); const {ipcMain} = require('electron'); const Constants = require('./src/constants'); const path = require('path'); @@ -249,6 +249,20 @@ const standardIPCReply = (event, channel, data, error) => { } }; +ipcMain.on(Constants.IPC_Browse_Directory, (event, data) => { + dialog.showOpenDialog(mainWindow, { + defaultPath: data.Location, + properties: ['openDirectory'], + title: data.Title, + }, (filePaths) => { + if (filePaths && (filePaths.length > 0)) { + event.returnValue = filePaths[0]; + } else { + event.returnValue = ''; + } + }); +}); + ipcMain.on(Constants.IPC_Check_Dependency_Installed, (event, data) => { try { const exists = fs.lstatSync(data.File).isFile(); diff --git a/src/components/MountItem/MountItem.css b/src/components/MountItem/MountItem.css index 81d91fc..5deeed2 100644 --- a/src/components/MountItem/MountItem.css +++ b/src/components/MountItem/MountItem.css @@ -1,7 +1,6 @@ input.Input { - display: block; margin: 0; - padding: 2px; + padding: 5px; border-radius: var(--border_radius); background: rgba(160, 160, 160, 0.1); border: none; diff --git a/src/components/MountItem/MountItem.js b/src/components/MountItem/MountItem.js index 3f2742f..a67039c 100644 --- a/src/components/MountItem/MountItem.js +++ b/src/components/MountItem/MountItem.js @@ -27,29 +27,44 @@ export default CSSModules((props) => { } let inputColumnSpan; - let inputControl = null; + let inputControls = null; if (props.platform === 'win32') { inputColumnSpan = 20; - inputControl = ; + inputControls = ; } else { - inputColumnSpan = 50; - inputControl = ( - - ); + + )); + inputControls.push(( + + )); } const buttonDisplay = props.allowMount || props.disabled ? @@ -101,7 +116,7 @@ export default CSSModules((props) => { rowSpan={5} text={props.title} type={'Heading1'}/> - {inputControl} + {inputControls} {actionsDisplay} {autoMountControl} {autoRestartControl} diff --git a/src/constants.js b/src/constants.js index 4d0a498..2485d99 100644 --- a/src/constants.js +++ b/src/constants.js @@ -21,6 +21,8 @@ exports.PROVIDER_ARG = { siaprime: '-sp' }; +exports.IPC_Browse_Directory = 'browse_directory'; + exports.IPC_Check_Dependency_Installed = 'check_dependency_installed'; exports.IPC_Check_Dependency_Installed_Reply = 'check_dependency_installed'; diff --git a/src/containers/MountItems/MountItems.js b/src/containers/MountItems/MountItems.js index 96a4e2e..2480e4a 100644 --- a/src/containers/MountItems/MountItems.js +++ b/src/containers/MountItems/MountItems.js @@ -82,6 +82,17 @@ class MountItems extends Component { } }; + handleBrowseLocation = (storageType, location) => { + location = ipcRenderer.sendSync(Constants.IPC_Browse_Directory, { + Title: storageType + ' Mount Location', + Location: location, + }); + if (location && (location.length > 0)) { + console.log(location); + //this.handleMountLocationChanged(storageType, location); + } + }; + handleMountLocationChanged = (storageType, value) => { if (this.props.platform === 'win32') { this.props.changed(storageType, this.state[storageType].DriveLetters[value]); @@ -287,6 +298,7 @@ class MountItems extends Component { 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)} clicked={this.handleMountUnMount} configClicked={()=>this.props.configClicked(provider)}