Fixes: No redirect after doc import
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
import * as React from 'react';
|
||||
import { observable } from 'mobx';
|
||||
import { observer, inject } from 'mobx-react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { createGlobalStyle } from 'styled-components';
|
||||
import invariant from 'invariant';
|
||||
import importFile from 'utils/importFile';
|
||||
@ -10,6 +10,8 @@ import Dropzone from 'react-dropzone';
|
||||
import DocumentsStore from 'stores/DocumentsStore';
|
||||
import LoadingIndicator from 'components/LoadingIndicator';
|
||||
|
||||
const EMPTY_OBJECT = {};
|
||||
|
||||
type Props = {
|
||||
children: React.Node,
|
||||
collectionId: string,
|
||||
@ -18,6 +20,7 @@ type Props = {
|
||||
rejectClassName?: string,
|
||||
documents: DocumentsStore,
|
||||
disabled: boolean,
|
||||
history: Object,
|
||||
};
|
||||
|
||||
export const GlobalStyles = createGlobalStyle`
|
||||
@ -35,7 +38,6 @@ export const GlobalStyles = createGlobalStyle`
|
||||
@observer
|
||||
class DropToImport extends React.Component<Props> {
|
||||
@observable isImporting: boolean = false;
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
onDropAccepted = async (files = []) => {
|
||||
this.isImporting = true;
|
||||
@ -60,7 +62,7 @@ class DropToImport extends React.Component<Props> {
|
||||
});
|
||||
|
||||
if (redirect) {
|
||||
this.redirectTo = doc.url;
|
||||
this.props.history.push(doc.url);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@ -77,14 +79,13 @@ class DropToImport extends React.Component<Props> {
|
||||
...rest
|
||||
} = this.props;
|
||||
|
||||
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
|
||||
if (this.props.disabled) return this.props.children;
|
||||
|
||||
return (
|
||||
<Dropzone
|
||||
accept="text/markdown, text/plain"
|
||||
onDropAccepted={this.onDropAccepted}
|
||||
style={{}}
|
||||
style={EMPTY_OBJECT}
|
||||
disableClick
|
||||
disablePreview
|
||||
multiple
|
||||
@ -97,4 +98,4 @@ class DropToImport extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default inject('documents')(DropToImport);
|
||||
export default inject('documents')(withRouter(DropToImport));
|
||||
|
Reference in New Issue
Block a user