diff --git a/frontend/components/DropToImport/DropToImport.js b/frontend/components/DropToImport/DropToImport.js index 84b4cb16..39924d48 100644 --- a/frontend/components/DropToImport/DropToImport.js +++ b/frontend/components/DropToImport/DropToImport.js @@ -8,20 +8,23 @@ import Document from 'models/Document'; import DocumentsStore from 'stores/DocumentsStore'; import LoadingIndicator from 'components/LoadingIndicator'; +type Props = { + children?: React$Element, + collectionId: string, + documentId?: string, + activeClassName?: string, + rejectClassName?: string, + documents: DocumentsStore, + disabled: boolean, + dropzoneRef: Function, + history: Object, +}; + class DropToImport extends Component { state: { isImporting: boolean, }; - props: { - children?: React$Element, - collectionId: string, - documentId?: string, - activeClassName?: string, - rejectClassName?: string, - documents: DocumentsStore, - disabled: boolean, - history: Object, - }; + props: Props; state = { isImporting: false, }; @@ -98,6 +101,7 @@ class DropToImport extends Component { disableClick disablePreview multiple + ref={this.props.dropzoneRef} {...props} > {this.state.isImporting && } diff --git a/frontend/components/Layout/components/SidebarCollections.js b/frontend/components/Layout/components/SidebarCollections.js index bed25cff..965237ff 100644 --- a/frontend/components/Layout/components/SidebarCollections.js +++ b/frontend/components/Layout/components/SidebarCollections.js @@ -53,8 +53,14 @@ type Props = { } @observer class CollectionLink extends React.Component { + dropzoneRef; + @observable menuOpen = false; + handleImport = () => { + this.dropzoneRef.open(); + }; + render() { const { history, collection, activeDocument, ui } = this.props; @@ -65,6 +71,7 @@ type Props = { collectionId={collection.id} activeClassName="activeDropZone" menuOpen={this.menuOpen} + dropzoneRef={ref => (this.dropzoneRef = ref)} > @@ -76,6 +83,7 @@ type Props = { collection={collection} onShow={() => (this.menuOpen = true)} onClose={() => (this.menuOpen = false)} + onImport={this.handleImport} open={this.menuOpen} /> diff --git a/frontend/menus/CollectionMenu.js b/frontend/menus/CollectionMenu.js index 1c9598c7..7f2de8c0 100644 --- a/frontend/menus/CollectionMenu.js +++ b/frontend/menus/CollectionMenu.js @@ -6,6 +6,7 @@ import styled from 'styled-components'; import Collection from 'models/Collection'; import UiStore from 'stores/UiStore'; import Icon from 'components/Icon'; +import Flex from 'components/Flex'; import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; @observer class CollectionMenu extends Component { @@ -13,6 +14,7 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; label?: React$Element, onShow?: () => void, onClose?: () => void, + onImport?: () => void, history: Object, ui: UiStore, collection: Collection, @@ -34,7 +36,7 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; }; render() { - const { collection, label, onShow, onClose } = this.props; + const { collection, label, onShow, onClose, onImport } = this.props; const { allowDelete } = collection; return ( @@ -44,11 +46,16 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; onClose={onClose} > {collection && - - New document - } - {collection && - Edit} + + + New document + + + Import document + + Edit + } + } {allowDelete && Delete}