fix: Documents in deleted collection should appear in trash (#1362)

* fix: Documents from deleted collection should show in trash

* improve messaging

* test: Add documents.move tests
feat: Add ability to restore trashed documents from deleted collection

* update store

* fix

* ui

* lint

* fix: Improve breadcrumb
This commit is contained in:
Tom Moor
2020-09-07 11:51:09 -07:00
committed by GitHub
parent c5de2da115
commit 4de3f69474
12 changed files with 258 additions and 50 deletions

View File

@@ -12,11 +12,9 @@ import {
} from "lodash";
import { observable, action, computed, runInAction } from "mobx";
import naturalSort from "shared/utils/naturalSort";
import BaseStore from "stores/BaseStore";
import RootStore from "stores/RootStore";
import Document from "models/Document";
import Revision from "models/Revision";
import type { FetchOptions, PaginationParams, SearchResult } from "types";
import { client } from "utils/ApiClient";
@@ -435,6 +433,7 @@ export default class DocumentsStore extends BaseStore<Document> {
res.data.documents.forEach(this.add);
res.data.collections.forEach(this.rootStore.collections.add);
this.addPolicies(res.policies);
};
@action
@@ -527,10 +526,10 @@ export default class DocumentsStore extends BaseStore<Document> {
};
@action
restore = async (document: Document, revision?: Revision) => {
restore = async (document: Document, options = {}) => {
const res = await client.post("/documents.restore", {
id: document.id,
revisionId: revision ? revision.id : undefined,
...options,
});
runInAction("Document#restore", () => {
invariant(res && res.data, "Data should be available");