feat: Added ability to disable sharing at collection (#1875)

* feat: Added ability to disable sharing at collection

* fix: Disable all previous share links when disabling collection share
Language

* fix: Disable document sharing for read-only collection members

* wip

* test

* fix: Clear policies after updating sharing settings

* chore: Less ambiguous language

* feat: Allow setting sharing choice on collection creation
This commit is contained in:
Tom Moor
2021-02-09 19:04:03 -08:00
committed by GitHub
parent cc90c8de1c
commit 097359bf7c
20 changed files with 227 additions and 33 deletions

View File

@ -1,6 +1,6 @@
// @flow
import { concat, filter, last } from "lodash";
import { computed } from "mobx";
import { computed, action } from "mobx";
import naturalSort from "shared/utils/naturalSort";
import Collection from "models/Collection";
@ -88,6 +88,25 @@ export default class CollectionsStore extends BaseStore<Collection> {
});
}
@action
async update(params: Object): Promise<Collection> {
const result = await super.update(params);
// If we're changing sharing permissions on the collection then we need to
// 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);
});
}
}
return result;
}
getPathForDocument(documentId: string): ?DocumentPath {
return this.pathsToDocuments.find((path) => path.id === documentId);
}