Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
bd2e87a
Commit to allow opening the PR
Kerry350 Jun 25, 2019
c54da94
Add start of the highlights menu
Kerry350 Jun 25, 2019
0b7420a
Add terms input
Kerry350 Jun 25, 2019
a762d02
Add a container for highlights state
Kerry350 Jun 25, 2019
494604c
Start to hook up highlights state effects, and Bridge with Redux
Kerry350 Jun 25, 2019
3f2bc2e
Move highlighted logs to a separate graphql field
weltenwort Jun 24, 2019
be180ea
Add highlights argument to unit tests
weltenwort Jun 25, 2019
abb640b
Add initial draft of a log highlights hook
weltenwort Jun 25, 2019
ad207ea
Finish hooking up hook state ready for GraphQL query
Kerry350 Jun 26, 2019
0a43161
Merge branch '22916-log-highlighting' of github.com:Kerry350/kibana i…
Kerry350 Jun 26, 2019
87347d3
Take startKey and endKey from overall collection of log entries
Kerry350 Jun 26, 2019
e4b95f6
Add sourceVersion
Kerry350 Jun 26, 2019
b778172
Fetch the data
Kerry350 Jun 26, 2019
653d468
Use columns ids instead of column indices
weltenwort Jun 27, 2019
1302ebd
merge highlights into stream WIP
weltenwort Jun 27, 2019
9565afd
Merge remote-tracking branch 'upstream/master' into 22916-log-highlig…
Kerry350 Jun 27, 2019
2a96ef4
Add highlighting for the message column type
weltenwort Jun 27, 2019
9c03ced
Use the serialized filter query
weltenwort Jun 27, 2019
1ce84a4
Merge branch '22916-log-highlighting' of github.com:Kerry350/kibana i…
Kerry350 Jun 28, 2019
4f1bc75
UX / Performance improvements
Kerry350 Jun 28, 2019
d647570
Tweaks
Kerry350 Jun 28, 2019
4ecb669
Merge remote-tracking branch 'upstream/master' into 22916-log-highlig…
Kerry350 Jun 28, 2019
32e2073
Menu changes
Kerry350 Jun 28, 2019
f1f75f2
Add highlighting for field columns
weltenwort Jun 28, 2019
7405d16
Use phrase query for highlighting
weltenwort Jun 28, 2019
556a349
Factor out commonly used visibility state
weltenwort Jun 28, 2019
534301b
Fix debounce to support changing onChange prop
weltenwort Jun 28, 2019
c478def
Move clear highlight button inline
weltenwort Jun 28, 2019
bea0187
Translate labels
weltenwort Jun 28, 2019
f816eef
Rely on popover ownfocus prop to focus the input
weltenwort Jun 28, 2019
8eb3425
Rename function to avoid i18n checker false positive
weltenwort Jun 28, 2019
aaad877
Merge branch 'master' into 22916-log-highlighting
weltenwort Jul 1, 2019
39776df
Merge remote-tracking branch 'upstream/master' into 22916-log-highlig…
Kerry350 Jul 2, 2019
56a4240
Rough and ready WIP next / previous
Kerry350 Jul 2, 2019
945a7d1
Merge remote-tracking branch 'upstream/master' into 22916-log-highlig…
Kerry350 Jul 2, 2019
5fd27bc
Add `countBefore` and `countAfter` highlight args
weltenwort Jul 2, 2019
980ffd1
Merge remote-tracking branch 'upstream/master' into 22916-log-highlig…
Kerry350 Jul 3, 2019
ee0ab64
Fix value used
Kerry350 Jul 3, 2019
7d2f70b
Merge branch '22916-log-highlighting-phase-2' of github.com:Kerry350/…
Kerry350 Jul 3, 2019
6400f48
Add a check for entry
Kerry350 Jul 3, 2019
56183ad
Rearrange icons
Kerry350 Jul 3, 2019
a8ebc1f
0 falsey blurgh
Kerry350 Jul 3, 2019
4f41b7e
Organise into separate sub-hooks for clarity
Kerry350 Jul 3, 2019
4810f54
Add comment
Kerry350 Jul 3, 2019
56ac1d8
Use filter and highlight queries also beyond interval
weltenwort Jul 3, 2019
3ddec5f
Refine behaviour of next / previous
Kerry350 Jul 4, 2019
abf61a8
Add log highlights api tests
weltenwort Jul 4, 2019
d8ed09d
Fix a few runtime and compiler errors and linter warnings
weltenwort Jul 4, 2019
dd64ad3
Refactor prev/next jumping to avoid index errors
weltenwort Jul 8, 2019
837d9cc
Use nearest index for initial jump
weltenwort Jul 8, 2019
b40b720
Include element type in translation id
weltenwort Jul 9, 2019
04c4209
Disable clear button when nothing to clear
weltenwort Jul 9, 2019
fa44967
Merge branch 'master' into 22916-log-highlighting-phase-2
weltenwort Jul 9, 2019
bc72dbb
Merge branch 'master' into 22916-log-highlighting-phase-2
weltenwort Jul 10, 2019
642790b
Merge branch 'master' into 22916-log-highlighting-phase-2
weltenwort Jul 18, 2019
3cbdb7c
Require the entry gid in the current highlight state
weltenwort Jul 18, 2019
33b97e6
Render active highlight differently in the message
weltenwort Jul 18, 2019
d03624d
Optimize bool query by using filter context
weltenwort Jul 19, 2019
3acb772
Merge branch 'master' into 22916-log-highlighting-phase-2
weltenwort Jul 19, 2019
9c9bcdf
Use ActiveHighlightMarker in field columns as well
weltenwort Jul 19, 2019
a97bf51
Merge branch 'master' into 22916-log-highlighting-phase-2
weltenwort Jul 23, 2019
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
7 changes: 6 additions & 1 deletion x-pack/legacy/plugins/infra/common/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,14 @@ export interface InfraTimeKeyInput {

tiebreaker: number;
}

/** A highlighting definition */
export interface InfraLogEntryHighlightInput {
/** The query to highlight by */
query: string;
/** The number of highlighted documents to include beyond the beginning of the interval */
countBefore: number;
/** The number of highlighted documents to include beyond the end of the interval */
countAfter: number;
}

export interface InfraTimerangeInput {
Expand Down
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/infra/common/time/time_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface TimeKey {
gid?: string;
}

export interface UniqueTimeKey extends TimeKey {
gid: string;
}

export type Comparator = (firstValue: any, secondValue: any) => number;

export const isTimeKey = (value: any): value is TimeKey =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ interface LogHighlightsMenuProps {
onChange: (highlightTerms: string[]) => void;
isLoading: boolean;
activeHighlights: boolean;
hasPreviousHighlight: boolean;
hasNextHighlight: boolean;
goToPreviousHighlight: () => void;
goToNextHighlight: () => void;
}

export const LogHighlightsMenu: React.FC<LogHighlightsMenuProps> = ({
onChange,
isLoading,
activeHighlights,
hasPreviousHighlight,
goToPreviousHighlight,
hasNextHighlight,
goToNextHighlight,
}) => {
const {
isVisible: isPopoverOpen,
Expand Down Expand Up @@ -62,7 +70,6 @@ export const LogHighlightsMenu: React.FC<LogHighlightsMenuProps> = ({
{activeHighlights ? <ActiveHighlightsIndicator /> : null}
</EuiButtonEmpty>
);

return (
<EuiPopover
id="popover"
Expand All @@ -83,10 +90,29 @@ export const LogHighlightsMenu: React.FC<LogHighlightsMenuProps> = ({
aria-label={termsFieldLabel}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
aria-label={goToPreviousHighlightLabel}
iconType="arrowUp"
onClick={goToPreviousHighlight}
title={goToPreviousHighlightLabel}
isDisabled={!hasPreviousHighlight}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
aria-label={goToNextHighlightLabel}
iconType="arrowDown"
onClick={goToNextHighlight}
title={goToNextHighlightLabel}
isDisabled={!hasNextHighlight}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
aria-label={clearTermsButtonLabel}
color="danger"
isDisabled={highlightTerm === ''}
iconType="trash"
onClick={clearHighlightTerm}
title={clearTermsButtonLabel}
Expand All @@ -109,6 +135,20 @@ const clearTermsButtonLabel = i18n.translate(
}
);

const goToPreviousHighlightLabel = i18n.translate(
'xpack.infra.logs.highlights.goToPreviousHighlightButtonLabel',
{
defaultMessage: 'Jump to previous highlight',
}
);

const goToNextHighlightLabel = i18n.translate(
'xpack.infra.logs.highlights.goToNextHighlightButtonLabel',
{
defaultMessage: 'Jump to next highlight',
}
);

const ActiveHighlightsIndicator = euiStyled(EuiIcon).attrs({
type: 'checkInCircleFilled',
size: 'm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,32 @@
import React from 'react';

import euiStyled from '../../../../../../common/eui_styled_components';
import { tintOrShade } from '../../../utils/styles';
import { chooseLightOrDarkColor, tintOrShade } from '../../../utils/styles';

export const ActiveHighlightMarker = euiStyled.mark`
color: ${props =>
chooseLightOrDarkColor(
props.theme.eui.euiColorAccent,
props.theme.eui.euiColorEmptyShade,
props.theme.eui.euiColorDarkestShade
)};
background-color: ${props => props.theme.eui.euiColorAccent};
outline: 1px solid ${props => props.theme.eui.euiColorAccent};
};
`;

export const HighlightMarker = euiStyled.mark`
color: ${props =>
chooseLightOrDarkColor(
tintOrShade(props.theme.eui.euiTextColor, props.theme.eui.euiColorAccent, 0.7, 0.5),
props.theme.eui.euiColorEmptyShade,
props.theme.eui.euiColorDarkestShade
)};
background-color: ${props =>
tintOrShade(props.theme.eui.euiTextColor, props.theme.eui.euiColorAccent, 0.7, 0.5)};
outline: 1px solid ${props =>
tintOrShade(props.theme.eui.euiTextColor, props.theme.eui.euiColorAccent, 0.7, 0.5)};
};
`;

export const highlightFieldValue = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('LogEntryFieldColumn', () => {
<LogEntryFieldColumn
columnValue={column}
highlights={[]}
isActiveHighlight={false}
isHighlighted={false}
isHovered={false}
isWrapped={false}
Expand Down Expand Up @@ -50,6 +51,7 @@ describe('LogEntryFieldColumn', () => {
<LogEntryFieldColumn
columnValue={column}
highlights={[]}
isActiveHighlight={false}
isHighlighted={false}
isHovered={false}
isWrapped={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import {
LogEntryColumn,
LogEntryHighlightColumn,
} from '../../../utils/log_entry';
import { highlightFieldValue, HighlightMarker } from './highlighting';
import { ActiveHighlightMarker, highlightFieldValue, HighlightMarker } from './highlighting';
import { LogEntryColumnContent } from './log_entry_column';

interface LogEntryFieldColumnProps {
columnValue: LogEntryColumn;
highlights: LogEntryHighlightColumn[];
isActiveHighlight: boolean;
isHighlighted: boolean;
isHovered: boolean;
isWrapped: boolean;
Expand All @@ -28,6 +29,7 @@ interface LogEntryFieldColumnProps {
export const LogEntryFieldColumn: React.FunctionComponent<LogEntryFieldColumnProps> = ({
columnValue,
highlights: [firstHighlight], // we only support one highlight for now
isActiveHighlight,
isHighlighted,
isHovered,
isWrapped,
Expand All @@ -42,7 +44,7 @@ export const LogEntryFieldColumn: React.FunctionComponent<LogEntryFieldColumnPro
{highlightFieldValue(
entry,
isHighlightFieldColumn(firstHighlight) ? firstHighlight.highlights : [],
HighlightMarker
isActiveHighlight ? ActiveHighlightMarker : HighlightMarker
)}
</CommaSeparatedLi>
))}
Expand All @@ -51,7 +53,7 @@ export const LogEntryFieldColumn: React.FunctionComponent<LogEntryFieldColumnPro
highlightFieldValue(
value,
isHighlightFieldColumn(firstHighlight) ? firstHighlight.highlights : [],
HighlightMarker
isActiveHighlight ? ActiveHighlightMarker : HighlightMarker
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@ import {
LogEntryHighlightColumn,
LogEntryMessageSegment,
} from '../../../utils/log_entry';
import { highlightFieldValue, HighlightMarker } from './highlighting';
import { ActiveHighlightMarker, highlightFieldValue, HighlightMarker } from './highlighting';
import { LogEntryColumnContent } from './log_entry_column';
import { hoveredContentStyle } from './text_styles';

interface LogEntryMessageColumnProps {
columnValue: LogEntryColumn;
highlights: LogEntryHighlightColumn[];
isActiveHighlight: boolean;
isHighlighted: boolean;
isHovered: boolean;
isWrapped: boolean;
}

export const LogEntryMessageColumn = memo<LogEntryMessageColumnProps>(
({ columnValue, highlights, isHighlighted, isHovered, isWrapped }) => {
({ columnValue, highlights, isActiveHighlight, isHighlighted, isHovered, isWrapped }) => {
const message = useMemo(
() =>
isMessageColumn(columnValue)
? formatMessageSegments(columnValue.message, highlights)
? formatMessageSegments(columnValue.message, highlights, isActiveHighlight)
: null,
[columnValue, highlights]
[columnValue, highlights, isActiveHighlight]
);

return (
Expand Down Expand Up @@ -75,23 +76,30 @@ const MessageColumnContent = LogEntryColumnContent.extend.attrs<{

const formatMessageSegments = (
messageSegments: LogEntryMessageSegment[],
highlights: LogEntryHighlightColumn[]
highlights: LogEntryHighlightColumn[],
isActiveHighlight: boolean
) =>
messageSegments.map((messageSegment, index) =>
formatMessageSegment(
messageSegment,
highlights.map(highlight =>
isHighlightMessageColumn(highlight) ? highlight.message[index].highlights : []
)
),
isActiveHighlight
)
);

const formatMessageSegment = (
messageSegment: LogEntryMessageSegment,
[firstHighlight = []]: string[][] // we only support one highlight for now
[firstHighlight = []]: string[][], // we only support one highlight for now
isActiveHighlight: boolean
): React.ReactNode => {
if (isFieldSegment(messageSegment)) {
return highlightFieldValue(messageSegment.value, firstHighlight, HighlightMarker);
return highlightFieldValue(
messageSegment.value,
firstHighlight,
isActiveHighlight ? ActiveHighlightMarker : HighlightMarker
);
} else if (isConstantSegment(messageSegment)) {
return messageSegment.constant;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface LogEntryRowProps {
columnConfigurations: LogColumnConfiguration[];
columnWidths: LogEntryColumnWidths;
highlights: LogEntryHighlight[];
isActiveHighlight: boolean;
isHighlighted: boolean;
logEntry: LogEntry;
openFlyoutWithItem: (id: string) => void;
Expand All @@ -45,6 +46,7 @@ export const LogEntryRow = ({
columnConfigurations,
columnWidths,
highlights,
isActiveHighlight,
isHighlighted,
logEntry,
openFlyoutWithItem,
Expand Down Expand Up @@ -144,6 +146,7 @@ export const LogEntryRow = ({
columnValue={column}
highlights={highlightsByColumnId[column.columnId] || []}
isHighlighted={isHighlighted}
isActiveHighlight={isActiveHighlight}
isHovered={isHovered}
isWrapped={wrap}
/>
Expand All @@ -164,6 +167,7 @@ export const LogEntryRow = ({
<LogEntryFieldColumn
columnValue={column}
highlights={highlightsByColumnId[column.columnId] || []}
isActiveHighlight={isActiveHighlight}
isHighlighted={isHighlighted}
isHovered={isHovered}
isWrapped={wrap}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useMemo } from 'react';

import euiStyled from '../../../../../../common/eui_styled_components';
import { TextScale } from '../../../../common/log_text_scale';
import { TimeKey } from '../../../../common/time';
import { TimeKey, UniqueTimeKey } from '../../../../common/time';
import { callWithoutRepeats } from '../../../utils/handlers';
import { LogColumnConfiguration } from '../../../utils/source_configuration';
import { AutoSizer } from '../../auto_sizer';
Expand Down Expand Up @@ -51,6 +51,7 @@ interface ScrollableLogTextStreamViewProps {
showColumnConfiguration: () => void;
intl: InjectedIntl;
highlightedItem: string | null;
currentHighlightKey: UniqueTimeKey | null;
}

interface ScrollableLogTextStreamViewState {
Expand Down Expand Up @@ -97,6 +98,7 @@ class ScrollableLogTextStreamViewClass extends React.PureComponent<
public render() {
const {
columnConfigurations,
currentHighlightKey,
hasMoreAfterEnd,
hasMoreBeforeStart,
highlightedItem,
Expand Down Expand Up @@ -187,6 +189,10 @@ class ScrollableLogTextStreamViewClass extends React.PureComponent<
boundingBoxRef={itemMeasureRef}
logEntry={item.logEntry}
highlights={item.highlights}
isActiveHighlight={
!!currentHighlightKey &&
currentHighlightKey.gid === item.logEntry.gid
}
scale={scale}
wrap={wrap}
isHighlighted={
Expand Down
Loading