import {InjectedRouter} from 'react-router'; import styled from '@emotion/styled'; import Badge from 'sentry/components/badge'; import Button from 'sentry/components/button'; import GlobalEventProcessingAlert from 'sentry/components/globalEventProcessingAlert'; import * as Layout from 'sentry/components/layouts/thirds'; import Link from 'sentry/components/links/link'; import QueryCount from 'sentry/components/queryCount'; import Tooltip from 'sentry/components/tooltip'; import {SLOW_TOOLTIP_DELAY} from 'sentry/constants'; import {IconPause, IconPlay} from 'sentry/icons'; import {t} from 'sentry/locale'; import space from 'sentry/styles/space'; import {Organization} from 'sentry/types'; import {trackAnalyticsEvent} from 'sentry/utils/analytics'; import useProjects from 'sentry/utils/useProjects'; import SavedSearchTab from './savedSearchTab'; import {getTabs, IssueSortOptions, Query, QueryCounts, TAB_MAX_COUNT} from './utils'; type Props = { displayReprocessingTab: boolean; onRealtimeChange: (realtime: boolean) => void; organization: Organization; query: string; queryCounts: QueryCounts; realtimeActive: boolean; router: InjectedRouter; selectedProjectIds: number[]; sort: string; queryCount?: number; } & React.ComponentProps; function IssueListHeader({ organization, query, sort, queryCount, queryCounts, realtimeActive, onRealtimeChange, onSavedSearchSelect, onSavedSearchDelete, savedSearchList, router, displayReprocessingTab, selectedProjectIds, }: Props) { const {projects} = useProjects(); const tabs = getTabs(organization); const visibleTabs = displayReprocessingTab ? tabs : tabs.filter(([tab]) => tab !== Query.REPROCESSING); const savedSearchTabActive = !visibleTabs.some(([tabQuery]) => tabQuery === query); // Remove cursor and page when switching tabs const {cursor: _, page: __, ...queryParms} = router?.location?.query ?? {}; const sortParam = queryParms.sort === IssueSortOptions.INBOX ? undefined : queryParms.sort; function trackTabClick(tabQuery: string) { // Clicking on inbox tab and currently another tab is active if (tabQuery === Query.FOR_REVIEW && query !== Query.FOR_REVIEW) { trackAnalyticsEvent({ eventKey: 'inbox_tab.clicked', eventName: 'Clicked Inbox Tab', organization_id: organization.id, }); } } const selectedProjects = projects.filter(({id}) => selectedProjectIds.includes(Number(id)) ); const realtimeTitle = realtimeActive ? t('Pause real-time updates') : t('Enable real-time updates'); return ( {t('Issues')}