Restores file import on sidebar menu
This commit is contained in:
parent
ba72ecb0e3
commit
29aba6bfe6
|
@ -54,11 +54,19 @@ class DropToImport extends Component {
|
|||
}
|
||||
|
||||
for (const file of files) {
|
||||
await importFile({ file, documentId, collectionId, redirect }, doc => {
|
||||
if (redirect) {
|
||||
this.props.history.push(doc.url);
|
||||
importFile(
|
||||
{
|
||||
documents: this.props.documents,
|
||||
file,
|
||||
documentId,
|
||||
collectionId,
|
||||
},
|
||||
doc => {
|
||||
if (redirect) {
|
||||
this.props.history.push(doc.url);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
// TODO: show error alert.
|
||||
|
|
|
@ -126,17 +126,16 @@ class CollectionLink extends Component {
|
|||
>
|
||||
<CollectionName justify="space-between">
|
||||
{collection.name}
|
||||
|
||||
<CollectionAction>
|
||||
<CollectionMenu
|
||||
history={history}
|
||||
collection={collection}
|
||||
onOpen={() => (this.menuOpen = true)}
|
||||
onClose={() => (this.menuOpen = false)}
|
||||
/>
|
||||
</CollectionAction>
|
||||
</CollectionName>
|
||||
</SidebarLink>
|
||||
<CollectionAction>
|
||||
<CollectionMenu
|
||||
history={history}
|
||||
collection={collection}
|
||||
onOpen={() => (this.menuOpen = true)}
|
||||
onClose={() => (this.menuOpen = false)}
|
||||
/>
|
||||
</CollectionAction>
|
||||
</StyledDropToImport>
|
||||
);
|
||||
}
|
||||
|
@ -225,6 +224,7 @@ const CollectionName = styled(Flex)`
|
|||
const CollectionAction = styled.span`
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
color: ${color.slate};
|
||||
svg {
|
||||
opacity: 0.75;
|
||||
|
@ -238,6 +238,8 @@ const CollectionAction = styled.span`
|
|||
`;
|
||||
|
||||
const StyledDropToImport = styled(DropToImport)`
|
||||
position: relative;
|
||||
|
||||
${CollectionAction} {
|
||||
display: ${props => (props.menuOpen ? 'inline' : 'none')};
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@ class CollectionMenu extends Component {
|
|||
history.push(`${collection.url}/new`);
|
||||
};
|
||||
|
||||
onImportFile = (ev: SyntheticEvent) => {
|
||||
onImportDocument = (ev: SyntheticEvent) => {
|
||||
ev.preventDefault();
|
||||
|
||||
// simulate a click on the file upload input element
|
||||
this.file.click();
|
||||
};
|
||||
|
@ -87,7 +89,7 @@ class CollectionMenu extends Component {
|
|||
<DropdownMenuItem onClick={this.onNewDocument}>
|
||||
New document
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.onImportFile}>
|
||||
<DropdownMenuItem onClick={this.onImportDocument}>
|
||||
Import document
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.onEdit}>Edit…</DropdownMenuItem>
|
||||
|
|
Reference in New Issue