2017-05-04 05:49:50 +00:00
|
|
|
// @flow
|
2016-04-29 05:25:37 +00:00
|
|
|
import React from 'react';
|
2017-09-11 05:59:14 +00:00
|
|
|
import { observable } from 'mobx';
|
2017-04-27 05:18:36 +00:00
|
|
|
import { observer, inject } from 'mobx-react';
|
2017-06-26 03:32:05 +00:00
|
|
|
import styled from 'styled-components';
|
2016-06-05 01:28:14 +00:00
|
|
|
|
2017-06-28 05:15:29 +00:00
|
|
|
import DocumentsStore from 'stores/DocumentsStore';
|
2017-09-11 05:59:14 +00:00
|
|
|
import Flex from 'components/Flex';
|
2017-06-26 03:32:05 +00:00
|
|
|
import DocumentList from 'components/DocumentList';
|
2017-06-26 02:21:08 +00:00
|
|
|
import PageTitle from 'components/PageTitle';
|
2016-05-07 18:52:08 +00:00
|
|
|
import CenteredContent from 'components/CenteredContent';
|
2017-07-18 04:46:32 +00:00
|
|
|
import { ListPlaceholder } from 'components/LoadingPlaceholder';
|
2016-04-29 05:25:37 +00:00
|
|
|
|
2017-06-26 03:32:05 +00:00
|
|
|
const Subheading = styled.h3`
|
|
|
|
font-size: 11px;
|
|
|
|
font-weight: 500;
|
|
|
|
text-transform: uppercase;
|
|
|
|
color: #9FA6AB;
|
|
|
|
letter-spacing: 0.04em;
|
|
|
|
border-bottom: 1px solid #ddd;
|
|
|
|
padding-bottom: 10px;
|
2017-06-26 03:42:04 +00:00
|
|
|
margin-top: 30px;
|
2017-06-26 03:32:05 +00:00
|
|
|
`;
|
|
|
|
|
2017-05-04 05:49:50 +00:00
|
|
|
type Props = {
|
2017-06-28 05:15:29 +00:00
|
|
|
documents: DocumentsStore,
|
2017-05-04 05:49:50 +00:00
|
|
|
};
|
|
|
|
|
2017-05-26 19:56:10 +00:00
|
|
|
@observer class Dashboard extends React.Component {
|
2017-05-04 05:49:50 +00:00
|
|
|
props: Props;
|
2017-09-11 05:59:14 +00:00
|
|
|
@observable isLoaded = false;
|
2017-05-26 19:56:10 +00:00
|
|
|
|
2017-06-26 03:32:05 +00:00
|
|
|
componentDidMount() {
|
2017-09-11 05:59:14 +00:00
|
|
|
this.loadContent();
|
2017-06-26 03:32:05 +00:00
|
|
|
}
|
|
|
|
|
2017-09-11 05:59:14 +00:00
|
|
|
loadContent = async () => {
|
|
|
|
await Promise.all([
|
|
|
|
this.props.documents.fetchRecentlyModified({ limit: 5 }),
|
|
|
|
this.props.documents.fetchRecentlyViewed({ limit: 5 }),
|
|
|
|
]);
|
|
|
|
this.isLoaded = true;
|
|
|
|
};
|
2017-07-18 04:46:32 +00:00
|
|
|
|
2017-06-26 03:32:05 +00:00
|
|
|
render() {
|
2016-06-27 06:15:32 +00:00
|
|
|
return (
|
2017-06-25 00:14:36 +00:00
|
|
|
<CenteredContent>
|
2017-06-26 02:21:08 +00:00
|
|
|
<PageTitle title="Home" />
|
|
|
|
<h1>Home</h1>
|
2017-09-11 05:59:14 +00:00
|
|
|
{this.isLoaded
|
|
|
|
? <Flex column>
|
2017-10-04 08:12:57 +00:00
|
|
|
{this.props.documents.recentlyViewed.length > 0 &&
|
|
|
|
<Flex column>
|
|
|
|
<Subheading>Recently viewed</Subheading>
|
|
|
|
<DocumentList
|
|
|
|
documents={this.props.documents.recentlyViewed}
|
|
|
|
/>
|
|
|
|
</Flex>}
|
2017-10-07 22:54:29 +00:00
|
|
|
{this.props.documents.recentlyEdited.length > 0 &&
|
|
|
|
<Flex column>
|
|
|
|
<Subheading>Recently edited</Subheading>
|
|
|
|
<DocumentList
|
|
|
|
documents={this.props.documents.recentlyEdited}
|
|
|
|
/>
|
|
|
|
</Flex>}
|
2017-09-11 05:59:14 +00:00
|
|
|
</Flex>
|
|
|
|
: <ListPlaceholder count={5} />}
|
2017-06-25 00:14:36 +00:00
|
|
|
</CenteredContent>
|
2016-06-27 06:15:32 +00:00
|
|
|
);
|
2016-04-29 05:25:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-28 05:15:29 +00:00
|
|
|
export default inject('documents')(Dashboard);
|