import React, { useMemo } from 'react'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; import { Button, Tooltip } from 'antd'; import AiSessionSearchField from 'Shared/SessionFilters/AiSessionSearchField'; import { useTranslation } from 'react-i18next'; import SavedSearch from '../SavedSearch/SavedSearch'; function SearchActions() { const { t, i18n } = useTranslation(); const { aiFiltersStore, searchStore, customFieldStore, userStore } = useStore(); const appliedFilter = searchStore.instance; const { activeTab } = searchStore; const { isEnterprise } = userStore; const metaLoading = customFieldStore.isLoading; const hasEvents = appliedFilter.filters.filter((i: any) => i.isEvent).length > 0; const hasFilters = appliedFilter.filters.filter((i: any) => !i.isEvent).length > 0; const { savedSearch } = searchStore; const hasSavedSearch = savedSearch && savedSearch.exists(); const hasSearch = hasEvents || hasFilters || hasSavedSearch; const title = useMemo(() => { if (activeTab && activeTab.type === 'bookmarks') { return isEnterprise ? t('Vault') : t('Bookmarks'); } return t('Sessions'); }, [activeTab?.type, isEnterprise, i18n.language]); // @ts-ignore const originStr = window.env.ORIGIN || window.location.origin; const isSaas = /app\.openreplay\.com/.test(originStr); const showAiField = isSaas && activeTab.type === 'sessions'; const showPanel = hasEvents || hasFilters || aiFiltersStore.isLoading; return !metaLoading ? (