diff --git a/src/bundles/ipfs-desktop.js b/src/bundles/ipfs-desktop.js
index 815022c90..578c4dc02 100644
--- a/src/bundles/ipfs-desktop.js
+++ b/src/bundles/ipfs-desktop.js
@@ -34,6 +34,10 @@ if (window.ipfsDesktop) {
window.ipfsDesktop.toggleSetting(setting)
},
+ doDesktopSelectDirectory: () => () => {
+ return window.ipfsDesktop.selectDirectory()
+ },
+
init: store => {
store.doDesktopStartListening()
}
diff --git a/src/files/file-input/FileInput.js b/src/files/file-input/FileInput.js
index 78c40162a..517780a27 100644
--- a/src/files/file-input/FileInput.js
+++ b/src/files/file-input/FileInput.js
@@ -1,5 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
+import { connect } from 'redux-bundler-react'
import { translate } from 'react-i18next'
import { filesToStreams } from '../../lib/files'
// Icons
@@ -56,6 +57,18 @@ class FileInput extends React.Component {
})
}
+ handleAddFolder = async () => {
+ if (!this.props.isIpfsDesktop) {
+ return this.folderInput.click()
+ }
+
+ this.toggleDropdown()
+ const files = await this.props.doDesktopSelectDirectory()
+ if (files) {
+ this.props.onAddFiles(files)
+ }
+ }
+
componentDidUpdate (prev) {
if (this.props.addProgress === 100 && prev.addProgress !== 100) {
this.setState({ force100: true })
@@ -94,7 +107,7 @@ class FileInput extends React.Component {
{t('addFile')}
-
@@ -131,4 +144,8 @@ class FileInput extends React.Component {
}
}
-export default translate('files')(FileInput)
+export default connect(
+ 'selectIsIpfsDesktop',
+ 'doDesktopSelectDirectory',
+ translate('files')(FileInput)
+)