From 73128d7f46a7ae0a8100442ba537d1809afbce01 Mon Sep 17 00:00:00 2001 From: Ousmane SAMBA Date: Thu, 9 Nov 2023 18:03:49 +0100 Subject: [PATCH] Handle ignore_null on lookup cache form (#17218) Co-authored-by: Laura --- changelog/unreleased/pr-17218.toml | 6 ++++++ .../caches/CaffeineCacheFieldSet.tsx | 18 ++++++++++++++++++ .../src/logic/lookup-tables/types.ts | 1 + 3 files changed, 25 insertions(+) create mode 100644 changelog/unreleased/pr-17218.toml diff --git a/changelog/unreleased/pr-17218.toml b/changelog/unreleased/pr-17218.toml new file mode 100644 index 000000000000..41754ff16d3c --- /dev/null +++ b/changelog/unreleased/pr-17218.toml @@ -0,0 +1,6 @@ +type = "fixed" +message = "Show ignore_null configuration on lookup cache form." + +issues = ["15200"] +pulls = ["17218"] + diff --git a/graylog2-web-interface/src/components/lookup-tables/caches/CaffeineCacheFieldSet.tsx b/graylog2-web-interface/src/components/lookup-tables/caches/CaffeineCacheFieldSet.tsx index da1c0b87eb29..affc1585ce6d 100644 --- a/graylog2-web-interface/src/components/lookup-tables/caches/CaffeineCacheFieldSet.tsx +++ b/graylog2-web-interface/src/components/lookup-tables/caches/CaffeineCacheFieldSet.tsx @@ -17,8 +17,10 @@ import * as React from 'react'; import { useFormikContext } from 'formik'; +import { Input } from 'components/bootstrap'; import { FormikFormGroup, TimeUnitInput } from 'components/common'; import type { LookupTableCache, LookupTableCacheConfig } from 'logic/lookup-tables/types'; +import { getValueFromInput } from 'util/FormsUtils'; type Props = { config: LookupTableCacheConfig, @@ -43,6 +45,14 @@ const CaffeineCacheFieldSet = ({ config }: Props, ref: any) => { validate: () => (validateConfig()), })); + const handleIgnoreNullChange = (event) => { + const ignoreValue = getValueFromInput(event.target); + + const valConfig = { ...values.config, ignore_null: ignoreValue }; + setStateConfig(valConfig); + setValues({ ...values, config: valConfig }); + }; + const handleUpdate = (name: string) => (value: number, unit: string, enabled: boolean) => { const auxConfig = { ...stateConfig }; const auxValConfig = { ...values.config }; @@ -85,6 +95,14 @@ const CaffeineCacheFieldSet = ({ config }: Props, ref: any) => { defaultEnabled={config.expire_after_write > 0} labelClassName="col-sm-3" wrapperClassName="col-sm-9" /> + ); }; diff --git a/graylog2-web-interface/src/logic/lookup-tables/types.ts b/graylog2-web-interface/src/logic/lookup-tables/types.ts index 31e87ac7ee78..db3e43799180 100644 --- a/graylog2-web-interface/src/logic/lookup-tables/types.ts +++ b/graylog2-web-interface/src/logic/lookup-tables/types.ts @@ -30,6 +30,7 @@ export type LookupTableCacheConfig = { expire_after_access_unit?: 'NANOSECONDS' | 'MICROSECONDS' | 'MILLISECONDS' | 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS' | null, expire_after_write?: number, expire_after_write_unit?: 'NANOSECONDS' | 'MICROSECONDS' | 'MILLISECONDS' | 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS' | null, + ignore_null?: boolean, }; export type LookupTableCache = GenericEntityType & {