2
0

(logic) Add execute in parent window context for code block

This commit is contained in:
Baptiste Arnaud
2022-11-09 15:08:42 +01:00
parent de0158be24
commit b31b603cc7
18 changed files with 91 additions and 56 deletions

View File

@@ -24,6 +24,7 @@ export const WorkspaceSettingsForm = ({ onClose }: { onClose: () => void }) => {
const handleChangeIcon = (icon: string) => {
if (!workspace?.id) return
console.log(icon)
updateWorkspace(workspace?.id, { icon })
}

View File

@@ -1,5 +1,5 @@
import { Flex, FlexProps, useEventListener } from '@chakra-ui/react'
import React, { useRef, useMemo, useEffect, useState, useCallback } from 'react'
import React, { useRef, useMemo, useEffect, useState } from 'react'
import {
blockWidth,
Coordinates,

View File

@@ -1,5 +1,6 @@
import { FormLabel, Stack, Text } from '@chakra-ui/react'
import { CodeEditor } from 'components/shared/CodeEditor'
import { SwitchWithLabel } from 'components/shared/SwitchWithLabel'
import { Input } from 'components/shared/Textbox'
import { CodeOptions } from 'models'
import React from 'react'
@@ -14,6 +15,10 @@ export const CodeSettings = ({ options, onOptionsChange }: Props) => {
onOptionsChange({ ...options, name })
const handleCodeChange = (content: string) =>
onOptionsChange({ ...options, content })
const handleShouldExecuteInParentContextChange = (
shouldExecuteInParentContext: boolean
) => onOptionsChange({ ...options, shouldExecuteInParentContext })
return (
<Stack spacing={4}>
<Stack>
@@ -27,6 +32,13 @@ export const CodeSettings = ({ options, onOptionsChange }: Props) => {
withVariableButton={false}
/>
</Stack>
<SwitchWithLabel
id="shouldExecuteInParentContext"
label="Execute in parent window"
moreInfoContent="Execute the code in the parent window context (when the bot is embedded). If it isn't detected, the code will be executed in the current window context."
initialValue={options.shouldExecuteInParentContext ?? false}
onCheckChange={handleShouldExecuteInParentContextChange}
/>
<Stack>
<Text>Code:</Text>
<CodeEditor

View File

@@ -80,6 +80,7 @@ test('can update workspace info', async ({ page }) => {
await page.click('[data-testid="editable-icon"]')
await page.fill('input[placeholder="Search..."]', 'building')
await page.click('text="🏦"')
await page.waitForTimeout(500)
await page.fill('input[value="Pro workspace"]', 'My awesome workspace')
await page.getByTestId('typebot-logo').click({ force: true })
await expect(

View File

@@ -17,7 +17,6 @@ import React, { useEffect, useState } from 'react'
import {
chatsLimit,
computePrice,
formatPrice,
parseNumberWithCommas,
storageLimit,
} from 'utils'

View File

@@ -1,6 +1,6 @@
import Link, { LinkProps } from 'next/link'
import React from 'react'
import { Box, chakra, HStack, Stack, TextProps } from '@chakra-ui/react'
import { chakra, HStack, TextProps } from '@chakra-ui/react'
import { ExternalLinkIcon } from 'assets/icons/ExternalLinkIcon'
type TextLinkProps = LinkProps & TextProps & { isExternal?: boolean }

View File

@@ -8,13 +8,13 @@ import { typebotViewer } from 'utils/playwright/testHelpers'
const mockSmtpCredentials: SmtpCredentialsData = {
from: {
email: 'sedrick.konopelski@ethereal.email',
name: 'Kimberly Boyer',
email: 'marley.cummings@ethereal.email',
name: 'Marley Cummings',
},
host: 'smtp.ethereal.email',
port: 587,
username: 'sedrick.konopelski@ethereal.email',
password: 'yXZChpPy25Qa5yBbeH',
username: 'marley.cummings@ethereal.email',
password: 'E5W1jHbAmv5cXXcut2',
}
test.beforeAll(async () => {
@@ -42,7 +42,9 @@ test('should send an email', async ({ page }) => {
const { previewUrl } = await response.json()
await page.goto(previewUrl)
await expect(page.locator('text="Hey!"')).toBeVisible()
await expect(page.locator('text="Kimberly Boyer"')).toBeVisible()
await expect(
page.locator(`text="${mockSmtpCredentials.from.name}"`)
).toBeVisible()
await expect(page.locator('text="<test1@gmail.com>" >> nth=0')).toBeVisible()
await expect(page.locator('text="<test2@gmail.com>" >> nth=0')).toBeVisible()
await expect(