This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/frontend/scenes/Dashboard/Dashboard.js

74 lines
2.0 KiB
JavaScript
Raw Normal View History

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';
import PageTitle from 'components/PageTitle';
2016-05-07 18:52:08 +00:00
import CenteredContent from 'components/CenteredContent';
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
};
@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-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-06-26 03:32:05 +00:00
render() {
return (
<CenteredContent>
<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>}
{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} />}
</CenteredContent>
);
2016-04-29 05:25:37 +00:00
}
}
2017-06-28 05:15:29 +00:00
export default inject('documents')(Dashboard);