// @flow import * as React from "react"; import { inject, observer } from "mobx-react"; import styled from "styled-components"; import Document from "models/Document"; import Flex from "shared/components/Flex"; import Time from "shared/components/Time"; import Breadcrumb from "shared/components/Breadcrumb"; import CollectionsStore from "stores/CollectionsStore"; import AuthStore from "stores/AuthStore"; const Container = styled(Flex)` color: ${props => props.theme.textTertiary}; font-size: 13px; white-space: nowrap; overflow: hidden; `; const Modified = styled.span` color: ${props => props.highlight ? props.theme.text : props.theme.textTertiary}; font-weight: ${props => (props.highlight ? "600" : "400")}; `; type Props = { collections: CollectionsStore, auth: AuthStore, showCollection?: boolean, showPublished?: boolean, document: Document, children: React.Node, }; function PublishingInfo({ auth, collections, showPublished, showCollection, document, children, ...rest }: Props) { const { modifiedSinceViewed, updatedAt, updatedBy, createdAt, publishedAt, archivedAt, deletedAt, isDraft, } = document; // Prevent meta information from displaying if updatedBy is not available. // Currently the situation where this is true is rendering share links. if (!updatedBy) { return null; } let content; if (deletedAt) { content = ( deleted ); } else if (archivedAt) { content = ( archived ); } else if (createdAt === updatedAt) { content = ( created ); } else if (publishedAt && (publishedAt === updatedAt || showPublished)) { content = ( published ); } else if (isDraft) { content = ( saved ); } else { content = ( updated ); } const collection = collections.get(document.collectionId); const updatedByMe = auth.user && auth.user.id === updatedBy.id; return ( {updatedByMe ? "You" : updatedBy.name}  {content} {showCollection && collection && (  in  )} {children} ); } export default inject("collections", "auth")(observer(PublishingInfo));