diff --git a/app/menu.js b/app/menu.js index 302cc78..297d344 100644 --- a/app/menu.js +++ b/app/menu.js @@ -2,16 +2,41 @@ * Import/require this file to set up the Menu of the windows */ -import electron, { BrowserWindow, Menu, app } from 'electron' +import electron, { BrowserWindow, Menu, app, dialog } from 'electron' import ImportWindow from './windows/Import/window' import SettingsWindow from './windows/Settings/window' import ResolveIPNS from './windows/ResolveIPNS/window' import PublishToIPNS from './windows/PublishToIPNS/window' +import { addFilesPaths } from './windows/Storage/fileIntegration' + const template = [{ label: 'File', submenu: [{ + label: 'Add File', + click () { + const selectOptions = { + title: 'Add File', + properties: ['openFile', 'multiSelections'] + } + + const paths = dialog.showOpenDialog(app.mainWindow, selectOptions) + addFilesPaths(paths) + } + }, { + label: 'Add Directory', + click () { + const selectOptions = { + title: 'Add Directory', + properties: ['openDirectory', 'multiSelections'] + } + + const paths = dialog.showOpenDialog(app.mainWindow, selectOptions) + addFilesPaths(paths) + } + }, + { label: 'Import from hash', accelerator: 'CmdOrCtrl+D', click () { diff --git a/app/windows/Storage/fileIntegration.js b/app/windows/Storage/fileIntegration.js index e7928b5..814c4bf 100644 --- a/app/windows/Storage/fileIntegration.js +++ b/app/windows/Storage/fileIntegration.js @@ -1,10 +1,8 @@ -import { remote } from 'electron' +import { dialog, app, shell } from 'electron' import Settings from 'electron-settings' import { addFilesFromFSPath, unpinObject } from '../../api' import DetailsWindow from '../Details/window' -const { app, dialog, shell } = remote - /** * Returns `true` if the user wants to wrap all files under a single dir, * `false` otherwise @@ -126,7 +124,7 @@ export function proptAndRemoveObjects (hashes) { cancelId: 0 } - const btnClicked = remote.dialog.showMessageBox(remote.app.mainWindow, opts) + const btnClicked = dialog.showMessageBox(app.mainWindow, opts) // Check the electron dialog documentation, cancel button is always 0 if (btnClicked !== 0) { const promises = hashes.map(hash => unpinObject(hash))