feat(settings): ⚡️ Can disable query params auto hide
This commit is contained in:
@ -47,6 +47,12 @@ export const GeneralSettingsForm = ({
|
||||
isInputPrefillEnabled,
|
||||
})
|
||||
|
||||
const handleHideQueryParamsChange = (isHideQueryParamsEnabled: boolean) =>
|
||||
onGeneralSettingsChange({
|
||||
...generalSettings,
|
||||
isHideQueryParamsEnabled,
|
||||
})
|
||||
|
||||
return (
|
||||
<Stack spacing={6}>
|
||||
<UpgradeModal isOpen={isOpen} onClose={onClose} />
|
||||
@ -78,6 +84,13 @@ export const GeneralSettingsForm = ({
|
||||
initialValue={generalSettings.isNewResultOnRefreshEnabled ?? false}
|
||||
onCheckChange={handleNewResultOnRefreshChange}
|
||||
/>
|
||||
<SwitchWithLabel
|
||||
id="query-params"
|
||||
label="Hide query params on bot start"
|
||||
initialValue={generalSettings.isHideQueryParamsEnabled ?? true}
|
||||
onCheckChange={handleHideQueryParamsChange}
|
||||
moreInfoContent="If your URL contains query params, they will be automatically hidden when the bot starts."
|
||||
/>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
|
@ -53,7 +53,11 @@ export const TypebotPage = ({
|
||||
|
||||
const clearQueryParams = () => {
|
||||
const hasQueryParams = asPath.includes('?')
|
||||
if (hasQueryParams) push(asPath.split('?')[0], undefined, { shallow: true })
|
||||
if (
|
||||
hasQueryParams &&
|
||||
typebot.settings.general.isHideQueryParamsEnabled !== false
|
||||
)
|
||||
push(asPath.split('?')[0], undefined, { shallow: true })
|
||||
}
|
||||
|
||||
const initializeResult = async () => {
|
||||
|
@ -74,6 +74,19 @@ export const createTypebots = async (partialTypebots: Partial<Typebot>[]) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const updateTypebot = async (
|
||||
partialTypebot: Partial<Typebot> & { id: string }
|
||||
) => {
|
||||
await prisma.typebot.updateMany({
|
||||
where: { id: partialTypebot.id },
|
||||
data: partialTypebot,
|
||||
})
|
||||
return prisma.publicTypebot.updateMany({
|
||||
where: { typebotId: partialTypebot.id },
|
||||
data: partialTypebot,
|
||||
})
|
||||
}
|
||||
|
||||
const parseTypebotToPublicTypebot = (
|
||||
id: string,
|
||||
typebot: Typebot
|
||||
|
@ -1,5 +1,9 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import { createTypebots, parseDefaultBlockWithStep } from '../services/database'
|
||||
import {
|
||||
createTypebots,
|
||||
parseDefaultBlockWithStep,
|
||||
updateTypebot,
|
||||
} from '../services/database'
|
||||
import cuid from 'cuid'
|
||||
import { defaultSettings, defaultTextInputOptions, InputStepType } from 'models'
|
||||
|
||||
@ -71,3 +75,31 @@ test.describe('Create result on page refresh enabled', () => {
|
||||
expect(resultId).toBe(null)
|
||||
})
|
||||
})
|
||||
|
||||
test('Hide query params', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
...parseDefaultBlockWithStep({
|
||||
type: InputStepType.TEXT,
|
||||
options: defaultTextInputOptions,
|
||||
}),
|
||||
},
|
||||
])
|
||||
await page.goto(`/${typebotId}-public?Name=John`)
|
||||
await page.waitForTimeout(1000)
|
||||
expect(page.url()).toEqual(`http://localhost:3001/${typebotId}-public`)
|
||||
await updateTypebot({
|
||||
id: typebotId,
|
||||
settings: {
|
||||
...defaultSettings,
|
||||
general: { ...defaultSettings.general, isHideQueryParamsEnabled: false },
|
||||
},
|
||||
})
|
||||
await page.goto(`/${typebotId}-public?Name=John`)
|
||||
await page.waitForTimeout(1000)
|
||||
expect(page.url()).toEqual(
|
||||
`http://localhost:3001/${typebotId}-public?Name=John`
|
||||
)
|
||||
})
|
||||
|
@ -8,6 +8,7 @@ export type GeneralSettings = {
|
||||
isBrandingEnabled: boolean
|
||||
isNewResultOnRefreshEnabled?: boolean
|
||||
isInputPrefillEnabled?: boolean
|
||||
isHideQueryParamsEnabled?: boolean
|
||||
}
|
||||
|
||||
export type TypingEmulation = {
|
||||
@ -29,6 +30,7 @@ export const defaultSettings: Settings = {
|
||||
isBrandingEnabled: true,
|
||||
isNewResultOnRefreshEnabled: false,
|
||||
isInputPrefillEnabled: true,
|
||||
isHideQueryParamsEnabled: true,
|
||||
},
|
||||
typingEmulation: { enabled: true, speed: 300, maxDelay: 1.5 },
|
||||
metadata: {
|
||||
|
Reference in New Issue
Block a user