import {useState} from 'react'; import type {InjectedRouter} from 'react-router'; import styled from '@emotion/styled'; import * as qs from 'query-string'; import FeatureBadge from 'sentry/components/badge/featureBadge'; import * as Layout from 'sentry/components/layouts/thirds'; import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip'; import {TabList, Tabs} from 'sentry/components/tabs'; import {Tooltip} from 'sentry/components/tooltip'; import {SLOW_TOOLTIP_DELAY} from 'sentry/constants'; import {t} from 'sentry/locale'; import type {Organization} from 'sentry/types/organization'; import {normalizeUrl} from 'sentry/utils/withDomainRequired'; type Props = { organization: Organization; router: InjectedRouter; hasV2ReleaseUIEnabled?: boolean; }; const enum ReleaseTab { RELEASES = 'releases', RELEASE_THRESHOLDS = 'release-thresholds', } function Header({router, hasV2ReleaseUIEnabled = false, organization}: Props) { const [selected, setSelected] = useState( router.location.pathname.includes('release-thresholds') ? ReleaseTab.RELEASE_THRESHOLDS : ReleaseTab.RELEASES ); const location = router.location; const { cursor: _cursor, page: _page, view: _view, ...queryParams } = location?.query ?? {}; const tabs = hasV2ReleaseUIEnabled ? [ { key: ReleaseTab.RELEASES, label: t('Monitor'), description: '', to: normalizeUrl( `/organizations/${organization.slug}/releases/?${qs.stringify(queryParams)}` ), }, { key: ReleaseTab.RELEASE_THRESHOLDS, label: t('Thresholds'), description: 'thresholds represent action alerts that will trigger once a threshold has been breached', to: normalizeUrl( `/organizations/${organization.slug}/release-thresholds/?${qs.stringify(queryParams)}` ), badge: , }, ] : []; const onTabSelect = (key: ReleaseTab) => { setSelected(key); }; return ( {t('Releases')} {hasV2ReleaseUIEnabled && ( {tabs.map(({label, description, key, to, badge}) => { return ( {label} {badge} ); })} )} ); } export default Header; const StyledTabs = styled(Tabs)` grid-column: 1/-1; `;