Skip to content

Commit d5f7e1e

Browse files
author
Alejandro Fernández Gómez
committed
React to changes in query bar
1 parent b8d8d56 commit d5f7e1e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

x-pack/plugins/infra/public/pages/logs/stream/page_logs_content.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const LogsPageLogsContent: React.FunctionComponent = () => {
6262
endDateExpression,
6363
updateDateRange,
6464
} = useContext(LogPositionState.Context);
65-
const { applyLogFilterQuery } = useContext(LogFilterState.Context);
65+
const { filterQuery, applyLogFilterQuery } = useContext(LogFilterState.Context);
6666

6767
const {
6868
isReloading,
@@ -80,6 +80,7 @@ export const LogsPageLogsContent: React.FunctionComponent = () => {
8080

8181
const prevStartTimestamp = usePrevious(startTimestamp);
8282
const prevEndTimestamp = usePrevious(endTimestamp);
83+
const prevFilterQuery = usePrevious(filterQuery);
8384

8485
// Refetch entries if...
8586
useEffect(() => {
@@ -96,7 +97,14 @@ export const LogsPageLogsContent: React.FunctionComponent = () => {
9697
((topCursor != null && targetPosition.time < topCursor.time) ||
9798
(bottomCursor != null && targetPosition.time > bottomCursor.time));
9899

99-
if (isFirstLoad || newDateRangeDoesNotOverlap || isCenterPointOutsideLoadedRange) {
100+
const hasQueryChanged = filterQuery !== prevFilterQuery;
101+
102+
if (
103+
isFirstLoad ||
104+
newDateRangeDoesNotOverlap ||
105+
isCenterPointOutsideLoadedRange ||
106+
hasQueryChanged
107+
) {
100108
fetchEntries();
101109
}
102110
}, [
@@ -108,6 +116,8 @@ export const LogsPageLogsContent: React.FunctionComponent = () => {
108116
targetPosition,
109117
topCursor,
110118
bottomCursor,
119+
filterQuery,
120+
prevFilterQuery,
111121
]);
112122

113123
const { logSummaryHighlights, currentHighlightKey, logEntryHighlightsById } = useContext(

x-pack/plugins/infra/public/pages/logs/stream/page_providers.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const LogEntriesStateProvider: React.FC = ({ children }) => {
5050
const { startTimestamp, endTimestamp, targetPosition, isInitialized } = useContext(
5151
LogPositionState.Context
5252
);
53-
const { filterQuery } = useContext(LogFilterState.Context);
53+
const { filterQueryAsKuery } = useContext(LogFilterState.Context);
5454

5555
// Don't render anything if the date range is incorrect.
5656
if (!startTimestamp || !endTimestamp) {
@@ -61,7 +61,7 @@ const LogEntriesStateProvider: React.FC = ({ children }) => {
6161
sourceId,
6262
startTimestamp,
6363
endTimestamp,
64-
query: filterQuery ?? undefined,
64+
query: filterQueryAsKuery?.expression ?? undefined,
6565
center: targetPosition ?? undefined,
6666
};
6767

0 commit comments

Comments
 (0)