fix(collab): 🛂 Hide folders for guests
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { withSentry } from '@sentry/nextjs'
|
||||
import { DashboardFolder } from 'db'
|
||||
import { DashboardFolder, WorkspaceRole } from 'db'
|
||||
import prisma from 'libs/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from 'services/api/utils'
|
||||
@ -18,8 +18,37 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (!workspaceId) return badRequest(res)
|
||||
const folders = await prisma.dashboardFolder.findMany({
|
||||
where: {
|
||||
parentFolderId,
|
||||
workspace: { members: { some: { userId: user.id, workspaceId } } },
|
||||
AND: [
|
||||
{
|
||||
parentFolderId,
|
||||
workspaceId: workspaceId,
|
||||
},
|
||||
{
|
||||
OR: [
|
||||
{
|
||||
workspace: {
|
||||
members: {
|
||||
some: {
|
||||
userId: user.id,
|
||||
role: { not: WorkspaceRole.GUEST },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
typebots: {
|
||||
some: {
|
||||
collaborators: {
|
||||
some: {
|
||||
userId: user.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
|
@ -255,6 +255,14 @@ const createAnswers = () => {
|
||||
})
|
||||
}
|
||||
|
||||
export const createFolder = (workspaceId: string, name: string) =>
|
||||
prisma.dashboardFolder.create({
|
||||
data: {
|
||||
workspaceId,
|
||||
name,
|
||||
},
|
||||
})
|
||||
|
||||
const parseTypebotToPublicTypebot = (
|
||||
id: string,
|
||||
typebot: Typebot
|
||||
|
@ -4,6 +4,7 @@ import { CollaborationType, Plan, WorkspaceRole } from 'db'
|
||||
import prisma from 'libs/prisma'
|
||||
import { InputBlockType, defaultTextInputOptions } from 'models'
|
||||
import {
|
||||
createFolder,
|
||||
createResults,
|
||||
createTypebots,
|
||||
parseDefaultGroupWithBlock,
|
||||
@ -96,10 +97,13 @@ test.describe('Collaborator', () => {
|
||||
type: CollaborationType.READ,
|
||||
},
|
||||
})
|
||||
await createFolder(guestWorkspaceId, 'Guest folder')
|
||||
await createResults({ typebotId })
|
||||
await page.goto(`/typebots`)
|
||||
await page.click("text=Pro user's workspace")
|
||||
await page.click('text=Guest workspace #2')
|
||||
await expect(page.locator('text=Guest typebot')).toBeVisible()
|
||||
await expect(page.locator('text=Guest folder')).toBeHidden()
|
||||
await page.click('text=Guest typebot')
|
||||
await page.click('button[aria-label="Show collaboration menu"]')
|
||||
await page.click('text=Everyone at Guest workspace')
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CollaborationType, PrismaClient } from 'db'
|
||||
import { PrismaClient } from 'db'
|
||||
import path from 'path'
|
||||
const prisma = new PrismaClient({
|
||||
log: [
|
||||
@ -34,9 +34,6 @@ const main = async () => {
|
||||
console.log('Params: ' + e.params)
|
||||
console.log('Duration: ' + e.duration + 'ms')
|
||||
})
|
||||
const results =
|
||||
await prisma.$queryRaw`DELETE FROM "public"."Result" WHERE "public"."Result"."typebotId"='ckzqqer3j002509l3np5x3v2y'`
|
||||
console.log(results)
|
||||
}
|
||||
|
||||
main().then()
|
||||
|
Reference in New Issue
Block a user