import {Component, Fragment} from 'react'; import styled from '@emotion/styled'; import type {Location} from 'history'; import pick from 'lodash/pick'; import {LinkButton} from 'sentry/components/button'; import {SectionHeading} from 'sentry/components/charts/styles'; import EmptyStateWarning from 'sentry/components/emptyStateWarning'; import GroupList from 'sentry/components/issues/groupList'; import Panel from 'sentry/components/panels/panel'; import PanelBody from 'sentry/components/panels/panelBody'; import {DEFAULT_RELATIVE_PERIODS} from 'sentry/constants'; import {URL_PARAM} from 'sentry/constants/pageFilters'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization} from 'sentry/types/organization'; import {trackAnalytics} from 'sentry/utils/analytics'; import {decodeScalar} from 'sentry/utils/queryString'; import {MutableSearch} from 'sentry/utils/tokenizeSearch'; import {removeTracingKeysFromSearch} from '../../utils'; type Props = { location: Location; organization: Organization; transaction: string; end?: string; start?: string; statsPeriod?: string | null; }; class RelatedIssues extends Component { getIssuesEndpointQueryParams() { const {transaction, start, end, statsPeriod, location} = this.props; const queryParams = { start, end, statsPeriod, limit: 5, sort: 'trends', ...pick(location.query, [...Object.values(URL_PARAM), 'cursor']), }; const currentFilter = new MutableSearch(decodeScalar(location.query.query, '')); removeTracingKeysFromSearch(currentFilter); currentFilter .addFreeText('is:unresolved') .setFilterValues('transaction', [transaction]); return { queryParams: { ...queryParams, query: currentFilter.formatString(), }, }; } handleOpenClick = () => { const {organization} = this.props; trackAnalytics('performance_views.summary.open_issues', { organization: organization.id, }); }; renderEmptyMessage = () => { const {statsPeriod} = this.props; const selectedTimePeriod = statsPeriod && DEFAULT_RELATIVE_PERIODS[statsPeriod]; const displayedPeriod = selectedTimePeriod ? selectedTimePeriod.toLowerCase() : t('given timeframe'); return (

{tct('No new issues for this transaction for the [timePeriod].', { timePeriod: displayedPeriod, })}

); }; render() { const {organization} = this.props; const {queryParams} = this.getIssuesEndpointQueryParams(); const issueSearch = { pathname: `/organizations/${organization.slug}/issues/`, query: {referrer: 'performance-related-issues', ...queryParams}, }; return ( {t('Related Issues')} {t('Open in Issues')} ); } } const ControlsWrapper = styled('div')` display: flex; align-items: center; justify-content: space-between; margin-bottom: ${space(1)}; `; const TableWrapper = styled('div')` margin-bottom: ${space(4)}; ${Panel} { /* smaller space between table and pagination */ margin-bottom: -${space(1)}; } `; export default RelatedIssues;