Individual document sharing with permissions (#5814)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
This commit is contained in:
Apoorv Mishra
2024-01-31 07:18:22 +05:30
committed by GitHub
parent 717c9b5d64
commit 1490c3a14b
91 changed files with 4004 additions and 1166 deletions

View File

@@ -12,6 +12,8 @@ import {
} from "@shared/types";
import type { NotificationSettings } from "@shared/types";
import { client } from "~/utils/ApiClient";
import Document from "./Document";
import UserMembership from "./UserMembership";
import ParanoidModel from "./base/ParanoidModel";
import Field from "./decorators/Field";
@@ -109,6 +111,18 @@ class User extends ParanoidModel {
);
}
@computed
get memberships(): UserMembership[] {
return this.store.rootStore.userMemberships.orderedData
.filter(
(m) => m.userId === this.id && m.sourceId === null && m.documentId
)
.filter((m) => {
const document = this.store.rootStore.documents.get(m.documentId!);
return !document?.collection;
});
}
/**
* Returns the current preference for the given notification event type taking
* into account the default system value.
@@ -172,6 +186,12 @@ class User extends ParanoidModel {
[key]: value,
};
}
getMembership(document: Document) {
return this.store.rootStore.userMemberships.orderedData.find(
(m) => m.documentId === document.id && m.userId === this.id
);
}
}
export default User;