fix custom radio

This commit is contained in:
Ildar Kamalov
2025-08-11 14:54:58 +03:00
parent 0920a51c4a
commit 8206f3f885
4 changed files with 14 additions and 7 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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<string, string> = {
bing: 'Bing',
duckduckgo: 'DuckDuckGo',

View File

@@ -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', () => {