Added collection menu link to import documents

This commit is contained in:
Jori Lallo
2017-10-02 00:24:38 -07:00
parent 12a95725f9
commit 18d774c1cc
3 changed files with 35 additions and 16 deletions

View File

@@ -8,20 +8,23 @@ import Document from 'models/Document';
import DocumentsStore from 'stores/DocumentsStore';
import LoadingIndicator from 'components/LoadingIndicator';
type Props = {
children?: React$Element<any>,
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<any>,
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 && <LoadingIndicator />}

View File

@@ -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)}
>
<SidebarLink key={collection.id} to={collection.url}>
<Flex justify="space-between">
@@ -76,6 +83,7 @@ type Props = {
collection={collection}
onShow={() => (this.menuOpen = true)}
onClose={() => (this.menuOpen = false)}
onImport={this.handleImport}
open={this.menuOpen}
/>
</CollectionAction>