Files
outline/app/components/DocumentPreview/components/PublishingInfo.js
T
Tom Moor 9142d975df Draft Documents (#518)
* Mostly there

* Fix up specs

* Working scope, updated tests

* Don't record view on draft

* PR feedback

* Highlight drafts nav item

* Bugaboos

* Styling

* Refactoring, gradually addressing Jori feedback

* Show collection in drafts list
Flow fixes

* Ensure menu actions are hidden when draft
2018-02-27 22:41:12 -08:00

69 lines
1.6 KiB
JavaScript

// @flow
import React, { Component } from 'react';
import moment from 'moment';
import styled from 'styled-components';
import { color } from 'shared/styles/constants';
import Collection from 'models/Collection';
import Document from 'models/Document';
import Flex from 'shared/components/Flex';
const Container = styled(Flex)`
color: ${color.slate};
font-size: 13px;
`;
const Modified = styled.span`
color: ${props => (props.highlight ? color.slateDark : color.slate)};
font-weight: ${props => (props.highlight ? '600' : '400')};
`;
class PublishingInfo extends Component {
props: {
collection?: Collection,
document: Document,
views?: number,
};
render() {
const { collection, document } = this.props;
const {
modifiedSinceViewed,
createdAt,
updatedAt,
createdBy,
updatedBy,
publishedAt,
} = document;
const timeAgo = moment(createdAt).fromNow();
return (
<Container align="center">
{publishedAt === updatedAt ? (
<span>
{createdBy.name} published {timeAgo}
</span>
) : (
<React.Fragment>
{updatedBy.name}
{publishedAt ? (
<Modified highlight={modifiedSinceViewed}>
&nbsp;modified {timeAgo}
</Modified>
) : (
<span>&nbsp;saved {timeAgo}</span>
)}
</React.Fragment>
)}
{collection && (
<span>
&nbsp;in <strong>{collection.name}</strong>
</span>
)}
</Container>
);
}
}
export default PublishingInfo;