diff --git a/frontend/components/DocumentPreview/DocumentPreview.js b/frontend/components/DocumentPreview/DocumentPreview.js index 2acea89a..364f10fb 100644 --- a/frontend/components/DocumentPreview/DocumentPreview.js +++ b/frontend/components/DocumentPreview/DocumentPreview.js @@ -9,6 +9,7 @@ import PublishingInfo from 'components/PublishingInfo'; type Props = { document: Document, highlight?: ?string, + showCollection?: boolean, innerRef?: Function, }; @@ -43,7 +44,7 @@ class DocumentPreview extends Component { props: Props; render() { - const { document, innerRef, ...rest } = this.props; + const { document, showCollection, innerRef, ...rest } = this.props; return ( @@ -53,6 +54,7 @@ class DocumentPreview extends Component { createdBy={document.createdBy} updatedAt={document.updatedAt} updatedBy={document.updatedBy} + collection={showCollection ? document.collection : undefined} /> ); diff --git a/frontend/components/PublishingInfo/PublishingInfo.js b/frontend/components/PublishingInfo/PublishingInfo.js index 8e7a0f1d..66465b0e 100644 --- a/frontend/components/PublishingInfo/PublishingInfo.js +++ b/frontend/components/PublishingInfo/PublishingInfo.js @@ -2,11 +2,11 @@ import React, { Component } from 'react'; import moment from 'moment'; import styled from 'styled-components'; +import Collection from 'models/Collection'; import type { User } from 'types'; import Flex from 'components/Flex'; const Container = styled(Flex)` - justify-content: space-between; color: #bbb; font-size: 13px; `; @@ -32,6 +32,7 @@ const Avatar = styled.img` class PublishingInfo extends Component { props: { collaborators?: Array, + collection?: Collection, createdAt: string, createdBy: User, updatedAt: string, @@ -42,6 +43,7 @@ class PublishingInfo extends Component { render() { const { collaborators, + collection, createdAt, updatedAt, createdBy, @@ -71,6 +73,7 @@ class PublishingInfo extends Component { {' '} {moment(updatedAt).fromNow()} } + {collection &&  in {collection.name}} ); } diff --git a/frontend/scenes/Document/Document.js b/frontend/scenes/Document/Document.js index 7f6d9510..ec550219 100644 --- a/frontend/scenes/Document/Document.js +++ b/frontend/scenes/Document/Document.js @@ -151,6 +151,8 @@ type Props = { renderHeading(isEditing: boolean) { invariant(this.document, 'document not available'); + if (this.props.newDocument) return; + return ( ))} diff --git a/server/api/documents.js b/server/api/documents.js index 0ad1ee5b..28236840 100644 --- a/server/api/documents.js +++ b/server/api/documents.js @@ -193,12 +193,15 @@ router.post('documents.create', auth(), async ctx => { text, }); + // reload to get all of the data needed to present (user, collection etc) + const document = await Document.findById(newDocument.id); + if (ownerCollection.type === 'atlas') { - await ownerCollection.addDocumentToStructure(newDocument, index); + await ownerCollection.addDocumentToStructure(document, index); } ctx.body = { - data: await presentDocument(ctx, newDocument), + data: await presentDocument(ctx, document), }; });