Fixed cancel on publishing new documents
This commit is contained in:
@ -6,6 +6,7 @@ import { observer, inject } from 'mobx-react';
|
|||||||
import { withRouter, Prompt } from 'react-router';
|
import { withRouter, Prompt } from 'react-router';
|
||||||
import Flex from 'components/Flex';
|
import Flex from 'components/Flex';
|
||||||
import { color, layout } from 'styles/constants';
|
import { color, layout } from 'styles/constants';
|
||||||
|
import { collectionUrl } from 'utils/routeHelpers';
|
||||||
|
|
||||||
import Document from 'models/Document';
|
import Document from 'models/Document';
|
||||||
import UiStore from 'stores/UiStore';
|
import UiStore from 'stores/UiStore';
|
||||||
@ -152,8 +153,13 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onCancel = () => {
|
onCancel = () => {
|
||||||
if (!this.document) return;
|
let url;
|
||||||
this.props.history.push(this.document.url);
|
if (this.document && this.document.url) {
|
||||||
|
url = this.document.url;
|
||||||
|
} else {
|
||||||
|
url = collectionUrl(this.props.match.params.id);
|
||||||
|
}
|
||||||
|
this.props.history.push(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
onStartDragging = () => {
|
onStartDragging = () => {
|
||||||
|
@ -14,6 +14,10 @@ export function newCollectionUrl(): string {
|
|||||||
return '/collections/new';
|
return '/collections/new';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function collectionUrl(collectionId: string): string {
|
||||||
|
return `/collections/${collectionId}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function documentUrl(doc: Document): string {
|
export function documentUrl(doc: Document): string {
|
||||||
return doc.url;
|
return doc.url;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user