Pinned documents (#608)

* Migrations and API for pinned documents

* Documentation

* Add pin icon

* Fin.

* v0.2.0

* Remove pin from DocumentPreview, add general menu
Add Pinned documents header

* Tidy

* Fixed: Drafts appearing on collection home
This commit is contained in:
Tom Moor
2018-02-28 23:28:36 -08:00
committed by GitHub
parent 1722b3f3d9
commit 18b0338736
16 changed files with 399 additions and 101 deletions

View File

@@ -16,7 +16,7 @@ class Document extends BaseModel {
hasPendingChanges: boolean = false;
errors: ErrorsStore;
collaborators: Array<User>;
collaborators: User[];
collection: $Shape<Collection>;
collectionId: string;
firstViewedAt: ?string;
@@ -24,18 +24,19 @@ class Document extends BaseModel {
modifiedSinceViewed: ?boolean;
createdAt: string;
createdBy: User;
updatedAt: string;
updatedBy: User;
html: string;
id: string;
team: string;
emoji: string;
private: boolean = false;
starred: boolean = false;
pinned: boolean = false;
text: string = '';
title: string = '';
parentDocument: ?string;
publishedAt: ?string;
updatedAt: string;
updatedBy: User;
url: string;
views: number;
revision: number;
@@ -98,6 +99,28 @@ class Document extends BaseModel {
/* Actions */
@action
pin = async () => {
this.pinned = true;
try {
await client.post('/documents.pin', { id: this.id });
} catch (e) {
this.pinned = false;
this.errors.add('Document failed to pin');
}
};
@action
unpin = async () => {
this.pinned = false;
try {
await client.post('/documents.unpin', { id: this.id });
} catch (e) {
this.pinned = true;
this.errors.add('Document failed to unpin');
}
};
@action
star = async () => {
this.starred = true;