feat: document visibility (#1262)

Adds the ability to set a visibility scope for documents within teams.
This commit is contained in:
Catalin Pit
2024-09-16 17:14:16 +03:00
committed by GitHub
parent f7a20113e5
commit fa6453e811
32 changed files with 1995 additions and 1233 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Document" ADD COLUMN "visibility" TEXT;
@@ -0,0 +1,12 @@
/*
Warnings:
- The `visibility` column on the `Document` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- CreateEnum
CREATE TYPE "DocumentVisibility" AS ENUM ('EVERYONE', 'MANAGER_AND_ABOVE', 'ADMIN');
-- AlterTable
ALTER TABLE "Document" DROP COLUMN "visibility",
ADD COLUMN "visibility" "DocumentVisibility" NOT NULL DEFAULT 'EVERYONE';
+7
View File
@@ -282,6 +282,12 @@ enum DocumentSource {
TEMPLATE_DIRECT_LINK
}
enum DocumentVisibility {
EVERYONE
MANAGER_AND_ABOVE
ADMIN
}
model Document {
id Int @id @default(autoincrement())
externalId String?
@@ -289,6 +295,7 @@ model Document {
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
authOptions Json?
formValues Json?
visibility DocumentVisibility @default(EVERYONE)
title String
status DocumentStatus @default(DRAFT)
Recipient Recipient[]
+38
View File
@@ -102,6 +102,44 @@ export const unseedTeam = async (teamUrl: string) => {
});
};
type SeedTeamMemberOptions = {
teamId: number;
role?: TeamMemberRole;
};
export const seedTeamMember = async ({
teamId,
role = TeamMemberRole.ADMIN,
}: SeedTeamMemberOptions) => {
const user = await seedUser();
await prisma.teamMember.create({
data: {
teamId,
role,
userId: user.id,
},
});
return user;
};
type UnseedTeamMemberOptions = {
teamId: number;
userId: number;
};
export const unseedTeamMember = async ({ teamId, userId }: UnseedTeamMemberOptions) => {
await prisma.teamMember.delete({
where: {
userId_teamId: {
userId,
teamId,
},
},
});
};
export const seedTeamTransfer = async (options: { newOwnerUserId: number; teamId: number }) => {
return await prisma.teamTransferVerification.create({
data: {