diff --git a/changelog/unreleased/issue-18388.toml b/changelog/unreleased/issue-18388.toml new file mode 100644 index 000000000000..607b6428312b --- /dev/null +++ b/changelog/unreleased/issue-18388.toml @@ -0,0 +1,5 @@ +type = "fixed" +message = "Fix custom highlighting of field values in the message details of the message table widget" + +issues = ["18388"] +pulls = ["20921"] diff --git a/graylog2-web-interface/src/views/components/Value.tsx b/graylog2-web-interface/src/views/components/Value.tsx index c9fdc74bc01f..a479b1f018bc 100644 --- a/graylog2-web-interface/src/views/components/Value.tsx +++ b/graylog2-web-interface/src/views/components/Value.tsx @@ -22,6 +22,7 @@ import FieldType from 'views/logic/fieldtypes/FieldType'; import type { ValueRenderer, ValueRendererProps } from 'views/components/messagelist/decoration/ValueRenderer'; import useActiveQueryId from 'views/hooks/useActiveQueryId'; import type FieldUnit from 'views/logic/aggregationbuilder/FieldUnit'; +import CustomHighlighting from 'views/components/highlighting/CustomHighlighting'; import ValueActions from './actions/ValueActions'; import TypeSpecificValue from './TypeSpecificValue'; @@ -39,13 +40,27 @@ const ValueActionTitle = styled.span` white-space: nowrap; `; +type TypeSpecificValueWithHighlightProps = { + field: string, + value?: any, + type?: FieldType + render?: React.ComponentType, + unit?: FieldUnit, +} +const TypeSpecificValueWithHighlight = ({ field, value, type, render, unit }: TypeSpecificValueWithHighlightProps) => ( + + + +); + const defaultRenderer: ValueRenderer = ({ value }: ValueRendererProps) => value; const InteractiveValue = ({ field, value, render = defaultRenderer, type, unit }: Props) => { const queryId = useActiveQueryId(); const RenderComponent: ValueRenderer = useMemo(() => render ?? ((props: ValueRendererProps) => props.value), [render]); const Component = useCallback(({ value: componentValue }) => , [RenderComponent, field]); - const element = ; + const element = ; return ( @@ -58,9 +73,9 @@ const InteractiveValue = ({ field, value, render = defaultRenderer, type, unit } const Value = ({ field, value, render = defaultRenderer, type = FieldType.Unknown, unit }: Props) => ( - {(interactive) => ((interactive) + {(interactive) => (interactive ? - : )} + : )} ); diff --git a/graylog2-web-interface/src/views/components/messagelist/MessageFields.tsx b/graylog2-web-interface/src/views/components/messagelist/MessageFields.tsx index 561b92dda95f..0fb8a5e8516c 100644 --- a/graylog2-web-interface/src/views/components/messagelist/MessageFields.tsx +++ b/graylog2-web-interface/src/views/components/messagelist/MessageFields.tsx @@ -25,8 +25,6 @@ import FieldTypeMapping from 'views/logic/fieldtypes/FieldTypeMapping'; import type { Message } from './Types'; -import CustomHighlighting from '../highlighting/CustomHighlighting'; - type Props = { message: Message, fields: FieldTypeMappingsList, @@ -50,14 +48,10 @@ const MessageFields = ({ message, fields }: Props) => { const { type } = fields.find((t) => t.name === key, undefined, FieldTypeMapping.create(key, FieldType.Unknown)); return ( - - - + ); });