Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom highlighting of field values in the message details of the message table widget. 6.1 #21005

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/issue-18388.toml
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 18 additions & 3 deletions graylog2-web-interface/src/views/components/Value.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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';
Expand All @@ -39,13 +40,27 @@
white-space: nowrap;
`;

type TypeSpecificValueWithHighlightProps = {
field: string,
value?: any,

Check warning on line 45 in graylog2-web-interface/src/views/components/Value.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "value" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
type?: FieldType

Check warning on line 46 in graylog2-web-interface/src/views/components/Value.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "type" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
render?: React.ComponentType<ValueRendererProps>,

Check warning on line 47 in graylog2-web-interface/src/views/components/Value.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "render" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
unit?: FieldUnit,

Check warning on line 48 in graylog2-web-interface/src/views/components/Value.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "unit" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
}
const TypeSpecificValueWithHighlight = ({ field, value, type, render, unit }: TypeSpecificValueWithHighlightProps) => (
<CustomHighlighting field={field}
value={value}>
<TypeSpecificValue field={field} value={value} type={type} render={render} unit={unit} />
</CustomHighlighting>
);

const defaultRenderer: ValueRenderer = ({ value }: ValueRendererProps) => value;

const InteractiveValue = ({ field, value, render, type, unit }: Props) => {
const queryId = useActiveQueryId();
const RenderComponent: ValueRenderer = useMemo(() => render ?? ((props: ValueRendererProps) => props.value), [render]);
const Component = useCallback(({ value: componentValue }) => <RenderComponent field={field} value={componentValue} />, [RenderComponent, field]);
const element = <TypeSpecificValue field={field} value={value} type={type} render={Component} unit={unit} />;
const element = <TypeSpecificValueWithHighlight field={field} value={value} type={type} render={Component} unit={unit} />;

return (
<ValueActions element={element} field={field} queryId={queryId} type={type} value={value}>
Expand All @@ -63,9 +78,9 @@

const Value = ({ field, value, render = defaultRenderer, type = FieldType.Unknown, unit }: Props) => (
<InteractiveContext.Consumer>
{(interactive) => ((interactive)
{(interactive) => (interactive
? <InteractiveValue field={field} value={value} render={render} type={type} unit={unit} />
: <span><TypeSpecificValue field={field} value={value} render={render} type={type} unit={unit} /></span>)}
: <span><TypeSpecificValueWithHighlight field={field} value={value} render={render} type={type} unit={unit} /></span>)}
</InteractiveContext.Consumer>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -50,14 +48,10 @@ const MessageFields = ({ message, fields }: Props) => {
const { type } = fields.find((t) => t.name === key, undefined, FieldTypeMapping.create(key, FieldType.Unknown));

return (
<CustomHighlighting key={key}
field={key}
value={formattedFields[key]}>
<MessageField fieldName={key}
fieldType={type}
message={message}
value={formattedFields[key]} />
</CustomHighlighting>
<MessageField fieldName={key}
fieldType={type}
message={message}
value={formattedFields[key]} />
);
});

Expand Down
Loading