feat: Collection admins (#5273

* Split permissions for reading documents from updating collection

* fix: Admins should have collection read permission, tests

* tsc

* Add admin option to permission selector

* Combine publish and create permissions, update -> createDocuments where appropriate

* Plural -> singular

* wip

* Quick version of collection structure loading, will revisit

* Remove documentIds method

* stash

* fixing tests to account for admin creation

* Add self-hosted migration

* fix: Allow groups to have admin permission

* Prefetch collection documents

* fix: Document explorer (move/publish) not working with async documents

* fix: Cannot re-parent document to collection by drag and drop

* fix: Cannot drag to import into collection item without admin permission

* Remove unused isEditor getter
This commit is contained in:
Tom Moor
2023-04-30 09:38:47 -04:00
committed by GitHub
parent 2942e9c78e
commit d8b4fef554
44 changed files with 799 additions and 535 deletions

View File

@@ -34,8 +34,14 @@ export default class CollectionsStore extends BaseStore<Collection> {
super(rootStore, Collection);
}
/**
* Returns the currently active collection, or undefined if not in the context
* of a collection.
*
* @returns The active Collection or undefined
*/
@computed
get active(): Collection | null | undefined {
get active(): Collection | undefined {
return this.rootStore.ui.activeCollectionId
? this.data.get(this.rootStore.ui.activeCollectionId)
: undefined;
@@ -92,7 +98,10 @@ export default class CollectionsStore extends BaseStore<Collection> {
url,
};
results.push([node]);
travelDocuments(collection.documents, id, [node]);
if (collection.documents) {
travelDocuments(collection.documents, id, [node]);
}
});
}
@@ -132,13 +141,9 @@ export default class CollectionsStore extends BaseStore<Collection> {
// remove all locally cached policies for documents in the collection as they
// are now invalid
if (params.sharing !== undefined) {
const collection = this.get(params.id);
if (collection) {
collection.documentIds.forEach((id) => {
this.rootStore.policies.remove(id);
});
}
this.rootStore.documents.inCollection(params.id).forEach((document) => {
this.rootStore.policies.remove(document.id);
});
}
return result;

View File

@@ -139,7 +139,7 @@ export default class DocumentsStore extends BaseStore<Document> {
rootInCollection(collectionId: string): Document[] {
const collection = this.rootStore.collections.get(collectionId);
if (!collection) {
if (!collection || !collection.sortedDocuments) {
return [];
}