/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import './search.scss';
import React, { useState } from 'react';
import { isEqual } from 'lodash';
import {
EuiFlexGroup,
EuiButton,
EuiFlexItem,
EuiPopover,
EuiButtonEmpty,
EuiPopoverFooter,
EuiBadge,
EuiContextMenuPanel,
EuiToolTip,
EuiCallOut,
} from '@elastic/eui';
import { DatePicker } from './date_picker';
import '@algolia/autocomplete-theme-classic';
import { Autocomplete } from './autocomplete';
import { SavePanel } from '../../event_analytics/explorer/save_panel';
import { PPLReferenceFlyout } from '../helpers';
import { uiSettingsService } from '../../../../common/utils';
import { APP_ANALYTICS_TAB_ID_REGEX } from '../../../../common/constants/explorer';
import { LiveTailButton, StopLiveButton } from '../live_tail/live_tail_button';
import { PPL_SPAN_REGEX } from '../../../../common/constants/shared';
export interface IQueryBarProps {
query: string;
tempQuery: string;
handleQueryChange: (query: string) => void;
handleQuerySearch: () => void;
dslService: any;
}
export interface IDatePickerProps {
startTime: string;
endTime: string;
setStartTime: () => void;
setEndTime: () => void;
setTimeRange: () => void;
setIsOutputStale: () => void;
handleTimePickerChange: (timeRange: string[]) => any;
handleTimeRangePickerRefresh: () => any;
}
export const Search = (props: any) => {
const {
query,
tempQuery,
handleQueryChange,
handleQuerySearch,
handleTimePickerChange,
dslService,
startTime,
endTime,
setStartTime,
setEndTime,
setIsOutputStale,
selectedPanelName,
selectedCustomPanelOptions,
setSelectedPanelName,
setSelectedCustomPanelOptions,
handleSavingObject,
isPanelTextFieldInvalid,
savedObjects,
showSavePanelOptionsList,
showSaveButton = true,
handleTimeRangePickerRefresh,
isLiveTailPopoverOpen,
closeLiveTailPopover,
popoverItems,
isLiveTailOn,
selectedSubTabId,
searchBarConfigs = {},
getSuggestions,
onItemSelect,
tabId = '',
baseQuery = '',
stopLive,
setIsLiveTailPopoverOpen,
liveTailName,
curVisId,
setSubType,
} = props;
const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX);
const [isSavePanelOpen, setIsSavePanelOpen] = useState(false);
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
const closeFlyout = () => {
setIsFlyoutVisible(false);
};
const showFlyout = () => {
setIsFlyoutVisible(true);
};
let flyout;
if (isFlyoutVisible) {
flyout =