Skip to content

Commit 3874f40

Browse files
[Metrics][Discover] use lastReloadRequestTime from fetchParam (#244761)
part of [239158](#239158) ## Summary This PR is a follow-up from the changes made for [239158](#239158). `lastReloadRequestTime` was receiving `Date.now()` and this was causing the chart to reload whenever it returned to the viewport. `fetchParams` provides a `lastReloadRequestTime` attribute, which is safer to use ### How to test - Start a local Kibana instance and point it to an oblt cluster ```yml feature_flags.overrides: metricsExperienceEnabled: true ``` - Navigate to Discover and Switch to ESQL mode - After the grid loads, scroll up or down. The charts should not try to load data. --------- Co-authored-by: kibanamachine <[email protected]>
1 parent a90083c commit 3874f40

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/platform/packages/shared/kbn-unified-metrics-grid/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependsOn:
4444
- '@kbn/field-utils'
4545
- '@kbn/react-query'
4646
- '@kbn/restorable-state'
47+
- '@kbn/esql-types'
4748
tags:
4849
- shared-browser
4950
- package

src/platform/packages/shared/kbn-unified-metrics-grid/src/components/chart/hooks/use_lens_props.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
1414
import type { EmbeddableComponentProps } from '@kbn/lens-plugin/public';
1515
import useLatest from 'react-use/lib/useLatest';
1616
import { useStableCallback } from '@kbn/unified-histogram';
17+
import type { ESQLControlVariable } from '@kbn/esql-types';
1718
import {
1819
filter,
1920
Observable,
@@ -38,6 +39,7 @@ export type LensProps = Pick<
3839
| 'viewMode'
3940
| 'timeRange'
4041
| 'attributes'
42+
| 'esqlVariables'
4143
| 'noPadding'
4244
| 'searchSessionId'
4345
| 'executionContext'
@@ -87,11 +89,17 @@ export const useLensProps = ({
8789
return getLensProps({
8890
searchSessionId: fetchParams.searchSessionId,
8991
timeRange: fetchParams.relativeTimeRange, // same as in the time picker
92+
esqlVariables: fetchParams.esqlVariables,
9093
attributes,
91-
lastReloadRequestTime: Date.now(),
94+
lastReloadRequestTime: fetchParams.lastReloadRequestTime,
9295
});
9396
},
94-
[fetchParams.searchSessionId, fetchParams.relativeTimeRange]
97+
[
98+
fetchParams.searchSessionId,
99+
fetchParams.relativeTimeRange,
100+
fetchParams.lastReloadRequestTime,
101+
fetchParams.esqlVariables,
102+
]
95103
);
96104

97105
const [lensPropsContext, setLensPropsContext] = useState<ReturnType<typeof buildLensProps>>();
@@ -186,9 +194,11 @@ const getLensProps = ({
186194
timeRange,
187195
attributes,
188196
lastReloadRequestTime,
197+
esqlVariables,
189198
}: {
190199
searchSessionId?: string;
191200
attributes: LensAttributes;
201+
esqlVariables: ESQLControlVariable[] | undefined;
192202
timeRange: TimeRange;
193203
lastReloadRequestTime?: number;
194204
}): LensProps => ({
@@ -197,6 +207,7 @@ const getLensProps = ({
197207
timeRange,
198208
attributes,
199209
noPadding: true,
210+
esqlVariables,
200211
searchSessionId,
201212
executionContext: {
202213
description: 'metrics experience chart data',

src/platform/packages/shared/kbn-unified-metrics-grid/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@kbn/esql-utils",
3232
"@kbn/field-utils",
3333
"@kbn/react-query",
34-
"@kbn/restorable-state"
34+
"@kbn/restorable-state",
35+
"@kbn/esql-types"
3536
]
3637
}

0 commit comments

Comments
 (0)