mirror of
https://github.com/documenso/documenso.git
synced 2026-07-26 18:04:55 +10:00
feat: document visibility (#1262)
Adds the ability to set a visibility scope for documents within teams.
This commit is contained in:
+2
@@ -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';
|
||||
@@ -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[]
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user