mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[8.6] [ML] Fix Data Visualizer time picker showing even if data view has been configured not to use a time filter (#146080) (#146210)
# Backport This will backport the following commits from `main` to `8.6`: - [[ML] Fix Data Visualizer time picker showing even if data view has been configured not to use a time filter (#146080)](https://github.com/elastic/kibana/pull/146080) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Quynh Nguyen (Quinn)","email":"43350163+qn895@users.noreply.github.com"},"sourceCommit":{"committedDate":"2022-11-23T18:55:42Z","message":"[ML] Fix Data Visualizer time picker showing even if data view has been configured not to use a time filter (#146080)\n\nfixes https://github.com/elastic/kibana/issues/139480","sha":"14437dffcc110a8665444e6dd0e32ac6bc8fefe5","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Feature:File Data Viz","v8.6.0","v8.7.0"],"number":146080,"url":"https://github.com/elastic/kibana/pull/146080","mergeCommit":{"message":"[ML] Fix Data Visualizer time picker showing even if data view has been configured not to use a time filter (#146080)\n\nfixes https://github.com/elastic/kibana/issues/139480","sha":"14437dffcc110a8665444e6dd0e32ac6bc8fefe5"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146080","number":146080,"mergeCommit":{"message":"[ML] Fix Data Visualizer time picker showing even if data view has been configured not to use a time filter (#146080)\n\nfixes https://github.com/elastic/kibana/issues/139480","sha":"14437dffcc110a8665444e6dd0e32ac6bc8fefe5"}}]}] BACKPORT--> Co-authored-by: Quynh Nguyen (Quinn) <43350163+qn895@users.noreply.github.com>
This commit is contained in:
parent
60108b3bb2
commit
22e9eacbc8
3 changed files with 24 additions and 9 deletions
|
@ -69,7 +69,10 @@ function updateLastRefresh(timeRange?: OnRefreshProps) {
|
|||
}
|
||||
|
||||
// FIXME: Consolidate this component with ML and AIOps's component
|
||||
export const DatePickerWrapper: FC = () => {
|
||||
export const DatePickerWrapper: FC<{ isAutoRefreshOnly?: boolean; showRefresh?: boolean }> = ({
|
||||
isAutoRefreshOnly,
|
||||
showRefresh,
|
||||
}) => {
|
||||
const {
|
||||
services,
|
||||
notifications: { toasts },
|
||||
|
@ -246,7 +249,7 @@ export const DatePickerWrapper: FC = () => {
|
|||
start={time.from}
|
||||
end={time.to}
|
||||
isPaused={refreshInterval.pause}
|
||||
isAutoRefreshOnly={!isTimeRangeSelectorEnabled}
|
||||
isAutoRefreshOnly={!isTimeRangeSelectorEnabled || isAutoRefreshOnly}
|
||||
refreshInterval={refreshInterval.value || DEFAULT_REFRESH_INTERVAL_MS}
|
||||
onTimeChange={updateTimeFilter}
|
||||
onRefresh={updateLastRefresh}
|
||||
|
@ -257,7 +260,7 @@ export const DatePickerWrapper: FC = () => {
|
|||
/>
|
||||
</EuiFlexItem>
|
||||
|
||||
{isTimeRangeSelectorEnabled ? null : (
|
||||
{showRefresh === true || !isTimeRangeSelectorEnabled ? (
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton
|
||||
fill
|
||||
|
@ -272,7 +275,7 @@ export const DatePickerWrapper: FC = () => {
|
|||
/>
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
)}
|
||||
) : null}
|
||||
</EuiFlexGroup>
|
||||
) : null;
|
||||
};
|
||||
|
|
|
@ -449,6 +449,11 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
|
|||
language: searchQueryLanguage,
|
||||
});
|
||||
}, [data, searchQueryLanguage, searchString]);
|
||||
|
||||
const hasValidTimeField = useMemo(
|
||||
() => currentDataView.timeFieldName !== undefined && currentDataView.timeFieldName !== '',
|
||||
[currentDataView.timeFieldName]
|
||||
);
|
||||
const helpLink = docLinks.links.ml.guide;
|
||||
|
||||
return (
|
||||
|
@ -475,7 +480,7 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
|
|||
gutterSize="s"
|
||||
data-test-subj="dataVisualizerTimeRangeSelectorSection"
|
||||
>
|
||||
{currentDataView.timeFieldName !== undefined && (
|
||||
{hasValidTimeField ? (
|
||||
<EuiFlexItem grow={false}>
|
||||
<FullTimeRangeSelector
|
||||
dataView={currentDataView}
|
||||
|
@ -484,9 +489,12 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
|
|||
timefilter={timefilter}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
)}
|
||||
) : null}
|
||||
<EuiFlexItem grow={false}>
|
||||
<DatePickerWrapper />
|
||||
<DatePickerWrapper
|
||||
isAutoRefreshOnly={!hasValidTimeField}
|
||||
showRefresh={!hasValidTimeField}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiPageContentHeader>
|
||||
|
|
|
@ -124,7 +124,11 @@ export const getDocumentCountStats = async (
|
|||
},
|
||||
});
|
||||
|
||||
const hasTimeField = timeFieldName !== undefined && intervalMs !== undefined && intervalMs > 0;
|
||||
const hasTimeField =
|
||||
timeFieldName !== undefined &&
|
||||
timeFieldName !== '' &&
|
||||
intervalMs !== undefined &&
|
||||
intervalMs > 0;
|
||||
|
||||
const getSearchParams = (aggregations: unknown, trackTotalHits = false) => ({
|
||||
index,
|
||||
|
@ -159,7 +163,7 @@ export const getDocumentCountStats = async (
|
|||
|
||||
// If time field is not defined, no need to show the document count chart
|
||||
// Just need to return the tracked total hits
|
||||
if (timeFieldName === undefined) {
|
||||
if (!hasTimeField) {
|
||||
const trackedTotalHits =
|
||||
typeof firstResp.rawResponse.hits.total === 'number'
|
||||
? firstResp.rawResponse.hits.total
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue