diff --git a/client_v2/src/components/Settings/LogsConfig/Form.tsx b/client_v2/src/components/Settings/LogsConfig/Form.tsx index e86f7eec..519a0b7f 100644 --- a/client_v2/src/components/Settings/LogsConfig/Form.tsx +++ b/client_v2/src/components/Settings/LogsConfig/Form.tsx @@ -4,12 +4,12 @@ import { Controller, useForm } from 'react-hook-form'; import intl from 'panel/common/intl'; import { Button } from 'panel/common/ui/Button'; import theme from 'panel/lib/theme'; -import { QUERY_LOG_INTERVALS_DAYS, DAY, RETENTION_CUSTOM } from 'panel/helpers/constants'; +import { QUERY_LOG_INTERVALS_DAYS, RETENTION_CUSTOM } from 'panel/helpers/constants'; import { RadioGroup } from '../SettingsGroup/RadioGroup'; import { SwitchGroup } from '../SettingsGroup'; import { IgnoredDomains } from '../IgnoredDomains'; -import { getIntervalTitle } from '../helpers'; +import { getIntervalTitle, getDefaultInterval } from '../helpers'; import { RetentionCustomInput } from '../RetentionCustomInput'; export type FormValues = { @@ -41,7 +41,7 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR defaultValues: { enabled: initialValues.enabled || false, anonymize_client_ip: initialValues.anonymize_client_ip || false, - interval: initialValues.interval || DAY, + interval: getDefaultInterval(initialValues.customInterval, initialValues.interval), customInterval: initialValues.customInterval ?? undefined, ignored: initialValues.ignored || '', ignore_enabled: initialValues.ignore_enabled || true, diff --git a/client_v2/src/components/Settings/StatsConfig/Form.tsx b/client_v2/src/components/Settings/StatsConfig/Form.tsx index ff356d61..83afe9a1 100644 --- a/client_v2/src/components/Settings/StatsConfig/Form.tsx +++ b/client_v2/src/components/Settings/StatsConfig/Form.tsx @@ -4,9 +4,9 @@ import { Controller, useForm } from 'react-hook-form'; import { Button } from 'panel/common/ui/Button'; import intl from 'panel/common/intl'; import theme from 'panel/lib/theme'; -import { getIntervalTitle } from '../helpers'; +import { getIntervalTitle, getDefaultInterval } from '../helpers'; -import { STATS_INTERVALS_DAYS, DAY, RETENTION_CUSTOM } from '../../../helpers/constants'; +import { STATS_INTERVALS_DAYS, RETENTION_CUSTOM } from '../../../helpers/constants'; import { RadioGroup, SwitchGroup } from '../SettingsGroup'; import { IgnoredDomains } from '../IgnoredDomains'; import { RetentionCustomInput } from '../RetentionCustomInput'; @@ -38,7 +38,7 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR mode: 'onBlur', defaultValues: { enabled: initialValues.enabled || false, - interval: initialValues.interval || DAY, + interval: getDefaultInterval(initialValues.customInterval, initialValues.interval), customInterval: initialValues.customInterval ?? undefined, ignored: initialValues.ignored || '', ignore_enabled: initialValues.ignore_enabled || true, diff --git a/client_v2/src/components/Settings/helpers.ts b/client_v2/src/components/Settings/helpers.ts index c9b05433..751e9b75 100644 --- a/client_v2/src/components/Settings/helpers.ts +++ b/client_v2/src/components/Settings/helpers.ts @@ -22,6 +22,13 @@ export const getIntervalTitle = (intervalMs: number) => { return formatIntervalText(intervalMs); }; +export const getDefaultInterval = (customInterval?: number, interval?: number) => { + if (customInterval && customInterval > 0) { + return RETENTION_CUSTOM; + } + return interval || DAY; +}; + const SAFESEARCH_TITLES: Record = { bing: 'Bing', duckduckgo: 'DuckDuckGo', diff --git a/client_v2/tests/e2e/control-panel.spec.ts b/client_v2/tests/e2e/control-panel.spec.ts index b68cdd75..81dede95 100644 --- a/client_v2/tests/e2e/control-panel.spec.ts +++ b/client_v2/tests/e2e/control-panel.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '@playwright/test'; +import { test } from '@playwright/test'; import { ADMIN_USERNAME, ADMIN_PASSWORD } from '../constants'; test.describe('Control Panel', () => {