Skip to content

Commit 8206f3f

Browse files
committed
fix custom radio
1 parent 0920a51 commit 8206f3f

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

client_v2/src/components/Settings/LogsConfig/Form.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { Controller, useForm } from 'react-hook-form';
44
import intl from 'panel/common/intl';
55
import { Button } from 'panel/common/ui/Button';
66
import theme from 'panel/lib/theme';
7-
import { QUERY_LOG_INTERVALS_DAYS, DAY, RETENTION_CUSTOM } from 'panel/helpers/constants';
7+
import { QUERY_LOG_INTERVALS_DAYS, RETENTION_CUSTOM } from 'panel/helpers/constants';
88

99
import { RadioGroup } from '../SettingsGroup/RadioGroup';
1010
import { SwitchGroup } from '../SettingsGroup';
1111
import { IgnoredDomains } from '../IgnoredDomains';
12-
import { getIntervalTitle } from '../helpers';
12+
import { getIntervalTitle, getDefaultInterval } from '../helpers';
1313
import { RetentionCustomInput } from '../RetentionCustomInput';
1414

1515
export type FormValues = {
@@ -41,7 +41,7 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
4141
defaultValues: {
4242
enabled: initialValues.enabled || false,
4343
anonymize_client_ip: initialValues.anonymize_client_ip || false,
44-
interval: initialValues.interval || DAY,
44+
interval: getDefaultInterval(initialValues.customInterval, initialValues.interval),
4545
customInterval: initialValues.customInterval ?? undefined,
4646
ignored: initialValues.ignored || '',
4747
ignore_enabled: initialValues.ignore_enabled || true,

client_v2/src/components/Settings/StatsConfig/Form.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Controller, useForm } from 'react-hook-form';
44
import { Button } from 'panel/common/ui/Button';
55
import intl from 'panel/common/intl';
66
import theme from 'panel/lib/theme';
7-
import { getIntervalTitle } from '../helpers';
7+
import { getIntervalTitle, getDefaultInterval } from '../helpers';
88

9-
import { STATS_INTERVALS_DAYS, DAY, RETENTION_CUSTOM } from '../../../helpers/constants';
9+
import { STATS_INTERVALS_DAYS, RETENTION_CUSTOM } from '../../../helpers/constants';
1010
import { RadioGroup, SwitchGroup } from '../SettingsGroup';
1111
import { IgnoredDomains } from '../IgnoredDomains';
1212
import { RetentionCustomInput } from '../RetentionCustomInput';
@@ -38,7 +38,7 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
3838
mode: 'onBlur',
3939
defaultValues: {
4040
enabled: initialValues.enabled || false,
41-
interval: initialValues.interval || DAY,
41+
interval: getDefaultInterval(initialValues.customInterval, initialValues.interval),
4242
customInterval: initialValues.customInterval ?? undefined,
4343
ignored: initialValues.ignored || '',
4444
ignore_enabled: initialValues.ignore_enabled || true,

client_v2/src/components/Settings/helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export const getIntervalTitle = (intervalMs: number) => {
2222
return formatIntervalText(intervalMs);
2323
};
2424

25+
export const getDefaultInterval = (customInterval?: number, interval?: number) => {
26+
if (customInterval && customInterval > 0) {
27+
return RETENTION_CUSTOM;
28+
}
29+
return interval || DAY;
30+
};
31+
2532
const SAFESEARCH_TITLES: Record<string, string> = {
2633
bing: 'Bing',
2734
duckduckgo: 'DuckDuckGo',

client_v2/tests/e2e/control-panel.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test } from '@playwright/test';
22
import { ADMIN_USERNAME, ADMIN_PASSWORD } from '../constants';
33

44
test.describe('Control Panel', () => {

0 commit comments

Comments
 (0)