Transfer changes from enterprise codebase

This commit is contained in:
Tom Moor
2023-05-13 12:30:24 -04:00
parent 7ce97f4d50
commit e2bc2f2067
7 changed files with 65 additions and 60 deletions

View File

@@ -1,5 +1,5 @@
import invariant from "invariant";
import { concat, find, last } from "lodash";
import { concat, find, last, sortBy } from "lodash";
import { computed, action } from "mobx";
import {
CollectionPermission,
@@ -50,9 +50,12 @@ export default class CollectionsStore extends BaseStore<Collection> {
@computed
get orderedData(): Collection[] {
let collections = Array.from(this.data.values());
collections = collections.filter((collection) =>
collection.deletedAt ? false : true
);
collections = collections
.filter((collection) => !collection.deletedAt)
.filter(
(collection) =>
this.rootStore.policies.abilities(collection.id).readDocument
);
return collections.sort((a, b) => {
if (a.index === b.index) {
return a.updatedAt > b.updatedAt ? -1 : 1;
@@ -62,6 +65,14 @@ export default class CollectionsStore extends BaseStore<Collection> {
});
}
@computed
get all(): Collection[] {
return sortBy(
Array.from(this.data.values()),
(collection) => collection.name
);
}
/**
* List of paths to each of the documents, where paths are composed of id and title/name pairs
*/