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(