2018-02-28 06:41:12 +00:00
|
|
|
// @flow
|
2018-05-05 23:16:08 +00:00
|
|
|
import * as React from 'react';
|
2018-02-28 06:41:12 +00:00
|
|
|
import { observer, inject } from 'mobx-react';
|
|
|
|
import CenteredContent from 'components/CenteredContent';
|
|
|
|
import { ListPlaceholder } from 'components/LoadingPlaceholder';
|
|
|
|
import Empty from 'components/Empty';
|
|
|
|
import PageTitle from 'components/PageTitle';
|
|
|
|
import DocumentList from 'components/DocumentList';
|
|
|
|
import DocumentsStore from 'stores/DocumentsStore';
|
|
|
|
|
2018-05-05 23:16:08 +00:00
|
|
|
type Props = {
|
|
|
|
documents: DocumentsStore,
|
|
|
|
};
|
2018-02-28 06:41:12 +00:00
|
|
|
|
2018-05-05 23:16:08 +00:00
|
|
|
@observer
|
|
|
|
class Drafts extends React.Component<Props> {
|
2018-02-28 06:41:12 +00:00
|
|
|
componentDidMount() {
|
|
|
|
this.props.documents.fetchDrafts();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { isLoaded, isFetching, drafts } = this.props.documents;
|
|
|
|
const showLoading = !isLoaded && isFetching;
|
|
|
|
const showEmpty = isLoaded && !drafts.length;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CenteredContent column auto>
|
|
|
|
<PageTitle title="Drafts" />
|
|
|
|
<h1>Drafts</h1>
|
|
|
|
{showLoading && <ListPlaceholder />}
|
|
|
|
{showEmpty && <Empty>No drafts yet.</Empty>}
|
|
|
|
<DocumentList documents={drafts} showCollection />
|
|
|
|
</CenteredContent>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default inject('documents')(Drafts);
|