Skip to content

Commit

Permalink
Handle ignore_null on lookup cache form (#17218)
Browse files Browse the repository at this point in the history
Co-authored-by: Laura <[email protected]>
  • Loading branch information
ousmaneo and grotlue authored Nov 9, 2023
1 parent 838ed35 commit 73128d7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/pr-17218.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type = "fixed"
message = "Show ignore_null configuration on lookup cache form."

issues = ["15200"]
pulls = ["17218"]

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 };
Expand Down Expand Up @@ -85,6 +95,14 @@ const CaffeineCacheFieldSet = ({ config }: Props, ref: any) => {
defaultEnabled={config.expire_after_write > 0}
labelClassName="col-sm-3"
wrapperClassName="col-sm-9" />
<Input type="checkbox"
id="ignore_null"
name="ignore_null"
label="Ignore null"
checked={stateConfig.ignore_null}
onChange={handleIgnoreNullChange}
help="When enabled, null lookup result will be ignored and not cached."
wrapperClassName="col-md-offset-3 col-md-9" />
</fieldset>
);
};
Expand Down
1 change: 1 addition & 0 deletions graylog2-web-interface/src/logic/lookup-tables/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 & {
Expand Down

0 comments on commit 73128d7

Please sign in to comment.