mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Unified Search] Hide 'Include time filter' checkbox when Data view has no time field (#131276)
* feat: add hide 'Include time filter' checkbox, if index pattern has no time field * feat: added checking DataView exists and has any element * fix: added a check for the absence of a timeFieldName value for each dataViews * feat: changed logic for check DataViews have value TimeFieldName * refactor: shouldRenderTimeFilterInSavedQueryForm * refact: minor * refact: minor * Update src/plugins/unified_search/public/search_bar/search_bar.tsx
This commit is contained in:
parent
12509f78c6
commit
1660bd9013
1 changed files with 13 additions and 6 deletions
|
@ -10,8 +10,8 @@ import { compact } from 'lodash';
|
|||
import { InjectedIntl, injectI18n } from '@kbn/i18n-react';
|
||||
import classNames from 'classnames';
|
||||
import React, { Component } from 'react';
|
||||
import { get, isEqual } from 'lodash';
|
||||
import { EuiIconProps, withEuiTheme, WithEuiThemeProps } from '@elastic/eui';
|
||||
import { get, isEqual } from 'lodash';
|
||||
import memoizeOne from 'memoize-one';
|
||||
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
|
@ -213,11 +213,18 @@ class SearchBarUI extends Component<SearchBarProps & WithEuiThemeProps, State> {
|
|||
* in case you the date range (from/to)
|
||||
*/
|
||||
private shouldRenderTimeFilterInSavedQueryForm() {
|
||||
const { dateRangeFrom, dateRangeTo, showDatePicker } = this.props;
|
||||
return (
|
||||
showDatePicker ||
|
||||
(!showDatePicker && dateRangeFrom !== undefined && dateRangeTo !== undefined)
|
||||
);
|
||||
const { dateRangeFrom, dateRangeTo, showDatePicker, indexPatterns } = this.props;
|
||||
|
||||
if (!showDatePicker && dateRangeFrom !== undefined && dateRangeTo !== undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (indexPatterns?.length) {
|
||||
// return true if at least one of the DateView has timeFieldName
|
||||
return indexPatterns.some((dataView) => Boolean(dataView.timeFieldName));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public onSave = async (savedQueryMeta: SavedQueryMeta, saveAsNew = false) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue