Allow user to share a flow publicly and make it duplicatable

Closes #360
This commit is contained in:
Baptiste Arnaud
2023-11-23 12:05:31 +01:00
parent 8a07392821
commit bb41226a04
130 changed files with 1150 additions and 2012 deletions

View File

@@ -9,7 +9,7 @@ export const getCollaborators = authenticatedProcedure
.meta({
openapi: {
method: 'GET',
path: '/typebots/{typebotId}/collaborators',
path: '/v1/typebots/{typebotId}/collaborators',
protect: true,
summary: 'Get collaborators',
tags: ['Collaborators'],

View File

@@ -38,7 +38,7 @@ test.describe('Typebot owner', () => {
},
])
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('button[aria-label="Show collaboration menu"]')
await page.click('button[aria-label="Open share popover"]')
await expect(page.locator('text=Free user')).toBeHidden()
await page.fill(
'input[placeholder="colleague@company.com"]',
@@ -109,7 +109,7 @@ test.describe('Guest with read access', () => {
await expect(page.locator('text=Another typebot')).toBeHidden()
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('button[aria-label="Open share popover"]')
await page.click('text=Everyone at Guest workspace')
await expect(page.locator('text="Remove"')).toBeHidden()
await expect(page.locator('text=John Doe')).toBeVisible()
@@ -165,11 +165,42 @@ test.describe('Guest with write access', () => {
await expect(page.locator('text=Another typebot')).toBeHidden()
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('button[aria-label="Open share popover"]')
await page.click('text=Everyone at Guest workspace')
await expect(page.locator('text="Remove"')).toBeHidden()
await expect(page.locator('text=John Doe')).toBeVisible()
await page.click('text=Group #1', { force: true })
await expect(page.locator('input[value="Group #1"]')).toBeVisible()
await expect(page.getByText('Group #1')).toBeVisible()
})
})
test.describe('Guest on public typebot', () => {
test('should have shared typebots displayed', async ({ page }) => {
const typebotId = createId()
const guestWorkspaceId = createId()
await prisma.workspace.create({
data: {
id: guestWorkspaceId,
name: 'Guest Workspace #4',
plan: Plan.FREE,
},
})
await createTypebots([
{
id: typebotId,
name: 'Guest typebot',
workspaceId: guestWorkspaceId,
...parseDefaultGroupWithBlock({
type: InputBlockType.TEXT,
}),
settings: {
publicShare: { isEnabled: true },
},
},
])
await page.goto(`/typebots/${typebotId}/edit`)
await expect(page.getByText('Guest typebot')).toBeVisible()
await expect(page.getByText('Duplicate')).toBeVisible()
await expect(page.getByText('Group #1')).toBeVisible()
})
})

View File

@@ -137,7 +137,7 @@ export const CollaborationList = () => {
}
return (
<Stack spacing={1} pt="4" pb="2">
<Stack spacing={1} pt="4">
<HStack as="form" onSubmit={handleInvitationSubmit} px="4" pb="2">
<Input
size="sm"

View File

@@ -1,40 +0,0 @@
import {
Popover,
PopoverTrigger,
PopoverContent,
IconButton,
Tooltip,
} from '@chakra-ui/react'
import { UsersIcon } from '@/components/icons'
import React from 'react'
import { CollaborationList } from './CollaborationList'
export const CollaborationMenuButton = ({
isLoading,
}: {
isLoading: boolean
}) => {
return (
<Popover isLazy placement="bottom-end">
<PopoverTrigger>
<span>
<Tooltip label="Invite users to collaborate">
<IconButton
isLoading={isLoading}
icon={<UsersIcon />}
aria-label="Show collaboration menu"
size="sm"
/>
</Tooltip>
</span>
</PopoverTrigger>
<PopoverContent
shadow="lg"
width="430px"
rootProps={{ style: { transform: 'scale(0)' } }}
>
<CollaborationList />
</PopoverContent>
</Popover>
)
}