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';
|
2018-08-07 05:49:41 +00:00
|
|
|
|
|
2018-08-07 06:22:20 +00:00
|
|
|
|
import Heading from 'components/Heading';
|
2018-02-28 06:41:12 +00:00
|
|
|
|
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';
|
2019-04-06 23:20:27 +00:00
|
|
|
|
import Subheading from 'components/Subheading';
|
2020-01-10 03:14:34 +00:00
|
|
|
|
import InputSearch from 'components/InputSearch';
|
2018-08-07 05:49:41 +00:00
|
|
|
|
import NewDocumentMenu from 'menus/NewDocumentMenu';
|
|
|
|
|
import Actions, { Action } from 'components/Actions';
|
2018-02-28 06:41:12 +00:00
|
|
|
|
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" />
|
2018-08-07 06:22:20 +00:00
|
|
|
|
<Heading>Drafts</Heading>
|
2019-04-06 23:20:27 +00:00
|
|
|
|
{showEmpty ? (
|
|
|
|
|
<Empty>You’ve not got any drafts at the moment.</Empty>
|
|
|
|
|
) : (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<Subheading>Documents</Subheading>
|
2019-10-06 01:42:03 +00:00
|
|
|
|
<DocumentList documents={drafts} showDraft={false} showCollection />
|
2019-08-07 06:46:27 +00:00
|
|
|
|
{showLoading && <ListPlaceholder />}
|
2019-04-06 23:20:27 +00:00
|
|
|
|
</React.Fragment>
|
|
|
|
|
)}
|
2018-08-07 05:49:41 +00:00
|
|
|
|
<Actions align="center" justify="flex-end">
|
2020-01-10 03:14:34 +00:00
|
|
|
|
<Action>
|
|
|
|
|
<InputSearch />
|
|
|
|
|
</Action>
|
2018-08-07 05:49:41 +00:00
|
|
|
|
<Action>
|
2019-07-13 17:15:38 +00:00
|
|
|
|
<NewDocumentMenu />
|
2018-08-07 05:49:41 +00:00
|
|
|
|
</Action>
|
|
|
|
|
</Actions>
|
2018-02-28 06:41:12 +00:00
|
|
|
|
</CenteredContent>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default inject('documents')(Drafts);
|