feat(bot): ️ Add custom file upload size limit

This commit is contained in:
Baptiste Arnaud
2022-06-21 16:53:45 +02:00
parent 1931a5c9c0
commit ea765640cf
17 changed files with 141 additions and 44 deletions

View File

@@ -1,5 +1,6 @@
import { FormLabel, Stack } from '@chakra-ui/react'
import { CodeEditor } from 'components/shared/CodeEditor'
import { SmartNumberInput } from 'components/shared/SmartNumberInput'
import { SwitchWithLabel } from 'components/shared/SwitchWithLabel'
import { Input } from 'components/shared/Textbox'
import { VariableSearchInput } from 'components/shared/VariableSearchInput'
@@ -20,7 +21,8 @@ export const FileInputSettings = ({ options, onOptionsChange }: Props) => {
onOptionsChange({ ...options, isMultipleAllowed })
const handleVariableChange = (variable?: Variable) =>
onOptionsChange({ ...options, variableId: variable?.id })
const handleSizeLimitChange = (sizeLimit?: number) =>
onOptionsChange({ ...options, sizeLimit })
return (
<Stack spacing={4}>
<SwitchWithLabel
@@ -29,6 +31,16 @@ export const FileInputSettings = ({ options, onOptionsChange }: Props) => {
initialValue={options.isMultipleAllowed}
onCheckChange={handleLongChange}
/>
<Stack>
<FormLabel mb="0" htmlFor="limit">
Size limit (MB):
</FormLabel>
<SmartNumberInput
id="limit"
value={options.sizeLimit ?? 10}
onValueChange={handleSizeLimitChange}
/>
</Stack>
<Stack>
<FormLabel mb="0">Placeholder:</FormLabel>
<CodeEditor

View File

@@ -37,6 +37,7 @@ test('options should work', async ({ page }) => {
await page.click('text="Allow multiple files?"')
await page.fill('div[contenteditable=true]', '<strong>Upload now!!</strong>')
await page.fill('[value="Upload"]', 'Go')
await page.fill('input[value="10"]', '20')
await page.click('text="Restart"')
await expect(typebotViewer(page).locator(`text="Upload now!!"`)).toBeVisible()
await typebotViewer(page)