import {Fragment} from 'react'; import styled from '@emotion/styled'; import {updateDateTime} from 'sentry/actionCreators/pageFilters'; import Datetime from 'sentry/components/dateTime'; import {DatePageFilter as NewDatePageFilter} from 'sentry/components/organizations/datePageFilter'; import PageFilterDropdownButton from 'sentry/components/organizations/pageFilters/pageFilterDropdownButton'; import PageFilterPinIndicator from 'sentry/components/organizations/pageFilters/pageFilterPinIndicator'; import TimeRangeSelector, { ChangeData, } from 'sentry/components/organizations/timeRangeSelector'; import {IconCalendar} from 'sentry/icons'; import { DEFAULT_DAY_END_TIME, DEFAULT_DAY_START_TIME, getFormattedDate, } from 'sentry/utils/dates'; import useOrganization from 'sentry/utils/useOrganization'; import usePageFilters from 'sentry/utils/usePageFilters'; import useRouter from 'sentry/utils/useRouter'; type Props = Omit< React.ComponentProps, 'organization' | 'start' | 'end' | 'utc' | 'relative' | 'onUpdate' > & { menuFooterMessage?: string; /** * Reset these URL params when we fire actions (custom routing only) */ resetParamsOnChange?: string[]; }; function OldDatePageFilter({ resetParamsOnChange, disabled, storageNamespace, ...props }: Props) { const router = useRouter(); const {selection, desyncedFilters} = usePageFilters(); const organization = useOrganization(); const {start, end, period, utc} = selection.datetime; const handleUpdate = (timePeriodUpdate: ChangeData) => { const {relative, ...startEndUtc} = timePeriodUpdate; const newTimePeriod = { period: relative, ...startEndUtc, }; updateDateTime(newTimePeriod, router, { save: true, resetParams: resetParamsOnChange, storageNamespace, }); }; const customDropdownButton = ({getActorProps, isOpen}) => { let label; if (start && end) { const startTimeFormatted = getFormattedDate(start, 'HH:mm:ss', {local: true}); const endTimeFormatted = getFormattedDate(end, 'HH:mm:ss', {local: true}); const showDateOnly = startTimeFormatted === DEFAULT_DAY_START_TIME && endTimeFormatted === DEFAULT_DAY_END_TIME; label = ( {' – '} ); } else { label = period?.toUpperCase(); } return ( } {...getActorProps()} > {label} ); }; return ( ); } const TitleContainer = styled('div')` text-align: left; ${p => p.theme.overflowEllipsis} `; function DatePageFilter(props: Props) { const organization = useOrganization(); if (organization.features.includes('new-page-filter')) { return ; } return ; } export default DatePageFilter;