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
This commit is contained in:
Tom Moor
2018-02-27 22:41:12 -08:00
committed by GitHub
parent 79a0272230
commit 9142d975df
30 changed files with 519 additions and 194 deletions

View File

@@ -71,10 +71,18 @@ class DocumentsStore extends BaseStore {
}
@computed
get starred(): Array<Document> {
get starred(): Document[] {
return _.filter(this.data.values(), 'starred');
}
@computed
get drafts(): Document[] {
return _.filter(
_.orderBy(this.data.values(), 'updatedAt', 'desc'),
doc => !doc.publishedAt
);
}
@computed
get active(): ?Document {
return this.ui.activeDocumentId
@@ -130,14 +138,19 @@ class DocumentsStore extends BaseStore {
};
@action
fetchStarred = async (): Promise<*> => {
await this.fetchPage('starred');
fetchStarred = async (options: ?PaginationParams): Promise<*> => {
await this.fetchPage('starred', options);
};
@action
fetchDrafts = async (options: ?PaginationParams): Promise<*> => {
await this.fetchPage('drafts', options);
};
@action
search = async (
query: string,
options?: PaginationParams
options: ?PaginationParams
): Promise<string[]> => {
const res = await client.get('/documents.search', {
...options,

View File

@@ -28,7 +28,10 @@ class UiStore {
@action
setActiveDocument = (document: Document): void => {
this.activeDocumentId = document.id;
this.activeCollectionId = document.collection.id;
if (document.publishedAt) {
this.activeCollectionId = document.collection.id;
}
};
@action