Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
/ Orion Public archive

Allow to add directories #138

Merged
merged 2 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
6 changes: 2 additions & 4 deletions app/windows/Storage/fileIntegration.js
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remote is undefined when is called from the main process (which is happening now since I used this in the menu), but importing { app, dialog, shell } directly seems to work.


/**
* Returns `true` if the user wants to wrap all files under a single dir,
* `false` otherwise
Expand Down Expand Up @@ -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))
Expand Down