overview.tsx 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  1. import {Component} from 'react';
  2. import type {RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import * as Sentry from '@sentry/react';
  5. import type {Location} from 'history';
  6. import Cookies from 'js-cookie';
  7. import isEqual from 'lodash/isEqual';
  8. import mapValues from 'lodash/mapValues';
  9. import omit from 'lodash/omit';
  10. import pickBy from 'lodash/pickBy';
  11. import moment from 'moment-timezone';
  12. import * as qs from 'query-string';
  13. import {addMessage} from 'sentry/actionCreators/indicator';
  14. import {fetchOrgMembers, indexMembersByProject} from 'sentry/actionCreators/members';
  15. import {fetchTagValues, loadOrganizationTags} from 'sentry/actionCreators/tags';
  16. import type {Client} from 'sentry/api';
  17. import ErrorBoundary from 'sentry/components/errorBoundary';
  18. import HookOrDefault from 'sentry/components/hookOrDefault';
  19. import * as Layout from 'sentry/components/layouts/thirds';
  20. import LoadingIndicator from 'sentry/components/loadingIndicator';
  21. import {extractSelectionParameters} from 'sentry/components/organizations/pageFilters/utils';
  22. import type {CursorHandler} from 'sentry/components/pagination';
  23. import Pagination from 'sentry/components/pagination';
  24. import Panel from 'sentry/components/panels/panel';
  25. import PanelBody from 'sentry/components/panels/panelBody';
  26. import QueryCount from 'sentry/components/queryCount';
  27. import {DEFAULT_QUERY, DEFAULT_STATS_PERIOD} from 'sentry/constants';
  28. import {t, tct} from 'sentry/locale';
  29. import GroupStore from 'sentry/stores/groupStore';
  30. import IssueListCacheStore from 'sentry/stores/IssueListCacheStore';
  31. import SelectedGroupStore from 'sentry/stores/selectedGroupStore';
  32. import {space} from 'sentry/styles/space';
  33. import type {PageFilters} from 'sentry/types/core';
  34. import type {
  35. BaseGroup,
  36. Group,
  37. PriorityLevel,
  38. SavedSearch,
  39. TagCollection,
  40. } from 'sentry/types/group';
  41. import {GroupStatus, IssueCategory} from 'sentry/types/group';
  42. import type {Organization} from 'sentry/types/organization';
  43. import {defined} from 'sentry/utils';
  44. import {trackAnalytics} from 'sentry/utils/analytics';
  45. import {browserHistory} from 'sentry/utils/browserHistory';
  46. import CursorPoller from 'sentry/utils/cursorPoller';
  47. import {getUtcDateString} from 'sentry/utils/dates';
  48. import getCurrentSentryReactRootSpan from 'sentry/utils/getCurrentSentryReactRootSpan';
  49. import parseApiError from 'sentry/utils/parseApiError';
  50. import parseLinkHeader from 'sentry/utils/parseLinkHeader';
  51. import {
  52. makeIssuesINPObserver,
  53. VisuallyCompleteWithData,
  54. } from 'sentry/utils/performanceForSentry';
  55. import {decodeScalar} from 'sentry/utils/queryString';
  56. import type {WithRouteAnalyticsProps} from 'sentry/utils/routeAnalytics/withRouteAnalytics';
  57. import withRouteAnalytics from 'sentry/utils/routeAnalytics/withRouteAnalytics';
  58. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  59. import withApi from 'sentry/utils/withApi';
  60. import withIssueTags from 'sentry/utils/withIssueTags';
  61. import withOrganization from 'sentry/utils/withOrganization';
  62. import withPageFilters from 'sentry/utils/withPageFilters';
  63. import withSavedSearches from 'sentry/utils/withSavedSearches';
  64. import CustomViewsIssueListHeader from 'sentry/views/issueList/customViewsHeader';
  65. import SavedIssueSearches from 'sentry/views/issueList/savedIssueSearches';
  66. import type {IssueUpdateData} from 'sentry/views/issueList/types';
  67. import {parseIssuePrioritySearch} from 'sentry/views/issueList/utils/parseIssuePrioritySearch';
  68. import IssueListActions from './actions';
  69. import IssueListFilters from './filters';
  70. import GroupListBody from './groupListBody';
  71. import IssueListHeader from './header';
  72. import type {QueryCounts} from './utils';
  73. import {
  74. DEFAULT_ISSUE_STREAM_SORT,
  75. FOR_REVIEW_QUERIES,
  76. getTabs,
  77. getTabsWithCounts,
  78. isForReviewQuery,
  79. IssueSortOptions,
  80. Query,
  81. TAB_MAX_COUNT,
  82. } from './utils';
  83. const MAX_ITEMS = 25;
  84. // the default period for the graph in each issue row
  85. const DEFAULT_GRAPH_STATS_PERIOD = '24h';
  86. // the allowed period choices for graph in each issue row
  87. const DYNAMIC_COUNTS_STATS_PERIODS = new Set(['14d', '24h', 'auto']);
  88. const MAX_ISSUES_COUNT = 100;
  89. type Params = {
  90. orgId: string;
  91. };
  92. type Props = {
  93. api: Client;
  94. location: Location;
  95. organization: Organization;
  96. params: Params;
  97. savedSearch: SavedSearch;
  98. savedSearchLoading: boolean;
  99. savedSearches: SavedSearch[];
  100. selectedSearchId: string;
  101. selection: PageFilters;
  102. tags: TagCollection;
  103. } & RouteComponentProps<{}, {searchId?: string}> &
  104. WithRouteAnalyticsProps;
  105. type State = {
  106. error: string | null;
  107. groupIds: string[];
  108. issuesLoading: boolean;
  109. memberList: ReturnType<typeof indexMembersByProject>;
  110. pageLinks: string;
  111. /**
  112. * Current query total
  113. */
  114. queryCount: number;
  115. /**
  116. * Counts for each inbox tab
  117. */
  118. queryCounts: QueryCounts;
  119. queryMaxCount: number;
  120. realtimeActive: boolean;
  121. selectAllActive: boolean;
  122. // Will be set to true if there is valid session data from issue-stats api call
  123. query?: string;
  124. };
  125. interface EndpointParams extends Partial<PageFilters['datetime']> {
  126. environment: string[];
  127. project: number[];
  128. cursor?: string;
  129. groupStatsPeriod?: string | null;
  130. page?: number | string;
  131. query?: string;
  132. sort?: string;
  133. statsPeriod?: string | null;
  134. useGroupSnubaDataset?: boolean;
  135. }
  136. type CountsEndpointParams = Omit<EndpointParams, 'cursor' | 'page' | 'query'> & {
  137. query: string[];
  138. };
  139. type StatEndpointParams = Omit<EndpointParams, 'cursor' | 'page'> & {
  140. groups: string[];
  141. expand?: string | string[];
  142. };
  143. const DataConsentBanner = HookOrDefault({
  144. hookName: 'component:data-consent-banner',
  145. defaultComponent: null,
  146. });
  147. class IssueListOverview extends Component<Props, State> {
  148. state: State = this.getInitialState();
  149. getInitialState() {
  150. const realtimeActiveCookie = Cookies.get('realtimeActive');
  151. const realtimeActive =
  152. typeof realtimeActiveCookie === 'undefined'
  153. ? false
  154. : realtimeActiveCookie === 'true';
  155. return {
  156. groupIds: [],
  157. actionTaken: false,
  158. selectAllActive: false,
  159. realtimeActive,
  160. pageLinks: '',
  161. queryCount: 0,
  162. queryCounts: {},
  163. queryMaxCount: 0,
  164. error: null,
  165. issuesLoading: true,
  166. memberList: {},
  167. };
  168. }
  169. componentDidMount() {
  170. this._performanceObserver = makeIssuesINPObserver();
  171. this._poller = new CursorPoller({
  172. linkPreviousHref: parseLinkHeader(this.state.pageLinks)?.previous?.href,
  173. success: this.onRealtimePoll,
  174. });
  175. // Wait for saved searches to load so if the user is on a saved search
  176. // or they have a pinned search we load the correct data the first time.
  177. // But if searches are already there, we can go right to fetching issues
  178. if (
  179. !this.props.savedSearchLoading ||
  180. this.props.organization.features.includes('issue-stream-performance')
  181. ) {
  182. const loadedFromCache = this.loadFromCache();
  183. if (!loadedFromCache) {
  184. // It's possible the projects query parameter is not yet ready and this
  185. // request will be repeated in componentDidUpdate
  186. this.fetchData();
  187. }
  188. }
  189. this.fetchTags();
  190. this.fetchMemberList();
  191. // let custom analytics take control
  192. this.props.setDisableRouteAnalytics?.();
  193. }
  194. componentDidUpdate(prevProps: Props, prevState: State) {
  195. if (prevState.realtimeActive !== this.state.realtimeActive) {
  196. // User toggled realtime button
  197. if (this.state.realtimeActive) {
  198. this.resumePolling();
  199. } else {
  200. this._poller.disable();
  201. }
  202. }
  203. // If the project selection has changed reload the member list and tag keys
  204. // allowing autocomplete and tag sidebar to be more accurate.
  205. if (!isEqual(prevProps.selection.projects, this.props.selection.projects)) {
  206. this.loadFromCache();
  207. this.fetchMemberList();
  208. this.fetchTags();
  209. }
  210. const selectionChanged = !isEqual(prevProps.selection, this.props.selection);
  211. // Wait for saved searches to load before we attempt to fetch stream data
  212. // Selection changing could indicate that the projects query parameter has populated
  213. // and we should refetch data.
  214. if (this.props.savedSearchLoading && !selectionChanged) {
  215. return;
  216. }
  217. if (
  218. prevProps.savedSearchLoading &&
  219. !this.props.savedSearchLoading &&
  220. this.props.organization.features.includes('issue-stream-performance')
  221. ) {
  222. return;
  223. }
  224. if (
  225. prevProps.savedSearchLoading &&
  226. !this.props.organization.features.includes('issue-stream-performance')
  227. ) {
  228. const loadedFromCache = this.loadFromCache();
  229. if (!loadedFromCache) {
  230. this.fetchData();
  231. }
  232. return;
  233. }
  234. const prevUrlQuery = prevProps.location.query;
  235. const newUrlQuery = this.props.location.query;
  236. const prevQuery = this.getQueryFromSavedSearchOrLocation({
  237. savedSearch: prevProps.savedSearch,
  238. location: prevProps.location,
  239. });
  240. const newQuery = this.getQuery();
  241. const prevSort = this.getSortFromSavedSearchOrLocation({
  242. savedSearch: prevProps.savedSearch,
  243. location: prevProps.location,
  244. });
  245. const newSort = this.getSort();
  246. // If any important url parameter changed or saved search changed
  247. // reload data.
  248. if (
  249. selectionChanged ||
  250. prevUrlQuery.cursor !== newUrlQuery.cursor ||
  251. prevUrlQuery.statsPeriod !== newUrlQuery.statsPeriod ||
  252. prevUrlQuery.groupStatsPeriod !== newUrlQuery.groupStatsPeriod ||
  253. prevQuery !== newQuery ||
  254. prevSort !== newSort
  255. ) {
  256. this.fetchData(selectionChanged);
  257. } else if (
  258. !this._lastRequest &&
  259. prevState.issuesLoading === false &&
  260. this.state.issuesLoading
  261. ) {
  262. // Reload if we issues are loading or their loading state changed.
  263. // This can happen when transitionTo is called
  264. this.fetchData();
  265. }
  266. }
  267. componentWillUnmount() {
  268. const groups = GroupStore.getState() as Group[];
  269. if (groups.length > 0 && !this.state.issuesLoading && !this.state.realtimeActive) {
  270. IssueListCacheStore.save(this.getCacheEndpointParams(), {
  271. groups,
  272. queryCount: this.state.queryCount,
  273. queryMaxCount: this.state.queryMaxCount,
  274. pageLinks: this.state.pageLinks,
  275. });
  276. }
  277. if (this._performanceObserver) {
  278. this._performanceObserver.disconnect();
  279. }
  280. this._poller.disable();
  281. SelectedGroupStore.reset();
  282. GroupStore.reset();
  283. this.props.api.clear();
  284. this.listener?.();
  285. }
  286. private _performanceObserver: PerformanceObserver | undefined;
  287. private _poller: any;
  288. private _lastRequest: any;
  289. private _lastStatsRequest: any;
  290. private _lastFetchCountsRequest: any;
  291. private actionTaken = false;
  292. private undo = false;
  293. getQueryFromSavedSearchOrLocation({
  294. savedSearch,
  295. location,
  296. }: Pick<Props, 'savedSearch' | 'location'>): string {
  297. if (
  298. !this.props.organization.features.includes('issue-stream-custom-views') &&
  299. savedSearch
  300. ) {
  301. return savedSearch.query;
  302. }
  303. const {query} = location.query;
  304. if (query !== undefined) {
  305. return decodeScalar(query, '');
  306. }
  307. return DEFAULT_QUERY;
  308. }
  309. getSortFromSavedSearchOrLocation({
  310. savedSearch,
  311. location,
  312. }: Pick<Props, 'savedSearch' | 'location'>): string {
  313. if (!location.query.sort && savedSearch?.id) {
  314. return savedSearch.sort;
  315. }
  316. if (location.query.sort) {
  317. return location.query.sort as string;
  318. }
  319. return DEFAULT_ISSUE_STREAM_SORT;
  320. }
  321. /**
  322. * Load the previous
  323. * @returns Returns true if the data was loaded from cache
  324. */
  325. loadFromCache(): boolean {
  326. const cache = IssueListCacheStore.getFromCache(this.getCacheEndpointParams());
  327. if (!cache) {
  328. return false;
  329. }
  330. this.setState(
  331. {
  332. issuesLoading: false,
  333. queryCount: cache.queryCount,
  334. queryMaxCount: cache.queryMaxCount,
  335. pageLinks: cache.pageLinks,
  336. },
  337. () => {
  338. // Handle this in the next tick to avoid being overwritten by GroupStore.reset
  339. // Group details clears the GroupStore at the same time this component mounts
  340. GroupStore.add(cache.groups);
  341. // Clear cache after loading
  342. IssueListCacheStore.reset();
  343. }
  344. );
  345. return true;
  346. }
  347. getQuery(): string {
  348. return this.getQueryFromSavedSearchOrLocation({
  349. savedSearch: this.props.savedSearch,
  350. location: this.props.location,
  351. });
  352. }
  353. getSort(): string {
  354. return this.getSortFromSavedSearchOrLocation({
  355. savedSearch: this.props.savedSearch,
  356. location: this.props.location,
  357. });
  358. }
  359. getGroupStatsPeriod(): string {
  360. let currentPeriod: string;
  361. if (typeof this.props.location.query?.groupStatsPeriod === 'string') {
  362. currentPeriod = this.props.location.query.groupStatsPeriod;
  363. } else {
  364. currentPeriod = DEFAULT_GRAPH_STATS_PERIOD;
  365. }
  366. return DYNAMIC_COUNTS_STATS_PERIODS.has(currentPeriod)
  367. ? currentPeriod
  368. : DEFAULT_GRAPH_STATS_PERIOD;
  369. }
  370. getEndpointParams = (): EndpointParams => {
  371. const {selection} = this.props;
  372. const params: EndpointParams = {
  373. project: selection.projects,
  374. environment: selection.environments,
  375. query: this.getQuery(),
  376. ...selection.datetime,
  377. };
  378. if (selection.datetime.period) {
  379. delete params.period;
  380. params.statsPeriod = selection.datetime.period;
  381. }
  382. if (params.end) {
  383. params.end = getUtcDateString(params.end);
  384. }
  385. if (params.start) {
  386. params.start = getUtcDateString(params.start);
  387. }
  388. const sort = this.getSort();
  389. if (sort !== DEFAULT_ISSUE_STREAM_SORT) {
  390. params.sort = sort;
  391. }
  392. const groupStatsPeriod = this.getGroupStatsPeriod();
  393. if (groupStatsPeriod !== DEFAULT_GRAPH_STATS_PERIOD) {
  394. params.groupStatsPeriod = groupStatsPeriod;
  395. }
  396. if (this.props.location.query.useGroupSnubaDataset) {
  397. params.useGroupSnubaDataset = true;
  398. }
  399. // only include defined values.
  400. return pickBy(params, v => defined(v)) as EndpointParams;
  401. };
  402. getCacheEndpointParams = (): EndpointParams => {
  403. const cursor = this.props.location.query.cursor;
  404. return {
  405. ...this.getEndpointParams(),
  406. cursor,
  407. };
  408. };
  409. getSelectedProjectIds = (): string[] => {
  410. return this.props.selection.projects.map(projectId => String(projectId));
  411. };
  412. fetchMemberList() {
  413. const projectIds = this.getSelectedProjectIds();
  414. fetchOrgMembers(this.props.api, this.props.organization.slug, projectIds).then(
  415. members => {
  416. this.setState({memberList: indexMembersByProject(members)});
  417. }
  418. );
  419. }
  420. fetchTags() {
  421. if (!this.props.organization.features.includes('issue-stream-search-query-builder')) {
  422. const {api, organization, selection} = this.props;
  423. loadOrganizationTags(api, organization.slug, selection);
  424. }
  425. }
  426. fetchStats = (groups: string[]) => {
  427. // If we have no groups to fetch, just skip stats
  428. if (!groups.length) {
  429. return;
  430. }
  431. const requestParams: StatEndpointParams = {
  432. ...this.getEndpointParams(),
  433. groups,
  434. };
  435. // If no stats period values are set, use default
  436. if (!requestParams.statsPeriod && !requestParams.start) {
  437. requestParams.statsPeriod = DEFAULT_STATS_PERIOD;
  438. }
  439. this._lastStatsRequest = this.props.api.request(this.groupStatsEndpoint, {
  440. method: 'GET',
  441. data: qs.stringify(requestParams),
  442. success: data => {
  443. if (!data) {
  444. return;
  445. }
  446. GroupStore.onPopulateStats(groups, data);
  447. this.trackTabViewed(groups, data, this.state.queryCount);
  448. },
  449. error: err => {
  450. this.setState({
  451. error: parseApiError(err),
  452. });
  453. },
  454. complete: () => {
  455. this._lastStatsRequest = null;
  456. // End navigation transaction to prevent additional page requests from impacting page metrics.
  457. // Other transactions include stacktrace preview request
  458. const currentSpan = Sentry.getActiveSpan();
  459. const rootSpan = currentSpan ? Sentry.getRootSpan(currentSpan) : undefined;
  460. if (rootSpan && Sentry.spanToJSON(rootSpan).op === 'navigation') {
  461. rootSpan.end();
  462. }
  463. },
  464. });
  465. };
  466. fetchCounts = (currentQueryCount: number, fetchAllCounts: boolean) => {
  467. const {queryCounts: _queryCounts} = this.state;
  468. let queryCounts: QueryCounts = {..._queryCounts};
  469. const endpointParams = this.getEndpointParams();
  470. const tabQueriesWithCounts = getTabsWithCounts();
  471. const currentTabQuery = tabQueriesWithCounts.includes(endpointParams.query as Query)
  472. ? endpointParams.query
  473. : null;
  474. // Update the count based on the exact number of issues, these shown as is
  475. if (currentTabQuery) {
  476. queryCounts[currentTabQuery] = {
  477. count: currentQueryCount,
  478. hasMore: false,
  479. };
  480. }
  481. this.setState({queryCounts});
  482. // If all tabs' counts are fetched, skip and only set
  483. if (
  484. fetchAllCounts ||
  485. !tabQueriesWithCounts.every(tabQuery => queryCounts[tabQuery] !== undefined)
  486. ) {
  487. const requestParams: CountsEndpointParams = {
  488. ...omit(endpointParams, 'query'),
  489. // fetch the counts for the tabs whose counts haven't been fetched yet
  490. query: tabQueriesWithCounts.filter(_query => _query !== currentTabQuery),
  491. };
  492. // If no stats period values are set, use default
  493. if (!requestParams.statsPeriod && !requestParams.start) {
  494. requestParams.statsPeriod = DEFAULT_STATS_PERIOD;
  495. }
  496. this._lastFetchCountsRequest = this.props.api.request(this.groupCountsEndpoint, {
  497. method: 'GET',
  498. data: qs.stringify(requestParams),
  499. success: data => {
  500. if (!data) {
  501. return;
  502. }
  503. // Counts coming from the counts endpoint is limited to 100, for >= 100 we display 99+
  504. queryCounts = {
  505. ...queryCounts,
  506. ...mapValues(data, (count: number) => ({
  507. count,
  508. hasMore: count > TAB_MAX_COUNT,
  509. })),
  510. };
  511. },
  512. error: () => {
  513. this.setState({queryCounts: {}});
  514. },
  515. complete: () => {
  516. this._lastFetchCountsRequest = null;
  517. this.setState({queryCounts});
  518. },
  519. });
  520. }
  521. };
  522. fetchData = (fetchAllCounts = false) => {
  523. const {organization} = this.props;
  524. const query = this.getQuery();
  525. if (this.state.realtimeActive || (!this.actionTaken && !this.undo)) {
  526. GroupStore.loadInitialData([]);
  527. this.setState({
  528. issuesLoading: true,
  529. queryCount: 0,
  530. error: null,
  531. });
  532. }
  533. const span = getCurrentSentryReactRootSpan();
  534. span?.setAttribute('query.sort', this.getSort());
  535. this.setState({
  536. error: null,
  537. });
  538. // Used for Issue Stream Performance project, enabled means we are doing saved search look up in the backend
  539. const savedSearchLookupEnabled = 0;
  540. const savedSearchLookupDisabled = 1;
  541. const requestParams: any = {
  542. ...this.getEndpointParams(),
  543. limit: MAX_ITEMS,
  544. shortIdLookup: 1,
  545. savedSearch: this.props.organization.features.includes('issue-stream-performance')
  546. ? this.props.savedSearchLoading
  547. ? savedSearchLookupEnabled
  548. : savedSearchLookupDisabled
  549. : savedSearchLookupDisabled,
  550. };
  551. if (
  552. this.props.organization.features.includes('issue-stream-performance') &&
  553. this.props.selectedSearchId
  554. ) {
  555. requestParams.searchId = this.props.selectedSearchId;
  556. }
  557. if (
  558. this.props.organization.features.includes('issue-stream-performance') &&
  559. this.props.savedSearchLoading &&
  560. !defined(this.props.location.query.query)
  561. ) {
  562. delete requestParams.query;
  563. }
  564. const currentQuery = this.props.location.query || {};
  565. if ('cursor' in currentQuery) {
  566. requestParams.cursor = currentQuery.cursor;
  567. }
  568. // If no stats period values are set, use default
  569. if (!requestParams.statsPeriod && !requestParams.start) {
  570. requestParams.statsPeriod = DEFAULT_STATS_PERIOD;
  571. }
  572. requestParams.expand = ['owners', 'inbox'];
  573. requestParams.collapse = ['stats', 'unhandled'];
  574. if (this._lastRequest) {
  575. this._lastRequest.cancel();
  576. }
  577. if (this._lastStatsRequest) {
  578. this._lastStatsRequest.cancel();
  579. }
  580. if (this._lastFetchCountsRequest) {
  581. this._lastFetchCountsRequest.cancel();
  582. }
  583. this._poller.disable();
  584. this._lastRequest = this.props.api.request(this.groupListEndpoint, {
  585. method: 'GET',
  586. data: qs.stringify(requestParams),
  587. success: (data, _, resp) => {
  588. if (!resp) {
  589. return;
  590. }
  591. // If this is a direct hit, we redirect to the intended result directly.
  592. if (resp.getResponseHeader('X-Sentry-Direct-Hit') === '1') {
  593. let redirect: string;
  594. if (data[0]?.matchingEventId) {
  595. const {id, matchingEventId} = data[0];
  596. redirect = `/organizations/${organization.slug}/issues/${id}/events/${matchingEventId}/`;
  597. } else {
  598. const {id} = data[0];
  599. redirect = `/organizations/${organization.slug}/issues/${id}/`;
  600. }
  601. browserHistory.replace(
  602. normalizeUrl({
  603. pathname: redirect,
  604. query: {
  605. referrer: 'issue-list',
  606. ...extractSelectionParameters(this.props.location.query),
  607. },
  608. })
  609. );
  610. return;
  611. }
  612. if (this.undo) {
  613. GroupStore.loadInitialData(data);
  614. }
  615. GroupStore.add(data);
  616. this.fetchStats(data.map((group: BaseGroup) => group.id));
  617. const hits = resp.getResponseHeader('X-Hits');
  618. const queryCount =
  619. typeof hits !== 'undefined' && hits ? parseInt(hits, 10) || 0 : 0;
  620. const maxHits = resp.getResponseHeader('X-Max-Hits');
  621. const queryMaxCount =
  622. typeof maxHits !== 'undefined' && maxHits ? parseInt(maxHits, 10) || 0 : 0;
  623. const pageLinks = resp.getResponseHeader('Link');
  624. this.fetchCounts(queryCount, fetchAllCounts);
  625. this.setState({
  626. error: null,
  627. issuesLoading: false,
  628. queryCount,
  629. queryMaxCount,
  630. pageLinks: pageLinks !== null ? pageLinks : '',
  631. });
  632. if (data.length === 0) {
  633. trackAnalytics('issue_search.empty', {
  634. organization: this.props.organization,
  635. search_type: 'issues',
  636. search_source: 'main_search',
  637. query,
  638. });
  639. }
  640. },
  641. error: err => {
  642. trackAnalytics('issue_search.failed', {
  643. organization: this.props.organization,
  644. search_type: 'issues',
  645. search_source: 'main_search',
  646. error: parseApiError(err),
  647. });
  648. this.setState({
  649. error: parseApiError(err),
  650. issuesLoading: false,
  651. });
  652. },
  653. complete: () => {
  654. this._lastRequest = null;
  655. this.resumePolling();
  656. if (!this.state.realtimeActive) {
  657. this.actionTaken = false;
  658. this.undo = false;
  659. }
  660. },
  661. });
  662. };
  663. resumePolling = () => {
  664. if (!this.state.pageLinks) {
  665. return;
  666. }
  667. // Only resume polling if we're on the first page of results
  668. const links = parseLinkHeader(this.state.pageLinks);
  669. if (links && !links.previous.results && this.state.realtimeActive) {
  670. this._poller.setEndpoint(links?.previous?.href);
  671. this._poller.enable();
  672. }
  673. };
  674. get groupListEndpoint(): string {
  675. const {organization} = this.props;
  676. return `/organizations/${organization.slug}/issues/`;
  677. }
  678. get groupCountsEndpoint(): string {
  679. const {organization} = this.props;
  680. return `/organizations/${organization.slug}/issues-count/`;
  681. }
  682. get groupStatsEndpoint(): string {
  683. const {organization} = this.props;
  684. return `/organizations/${organization.slug}/issues-stats/`;
  685. }
  686. onRealtimeChange = (realtime: boolean) => {
  687. Cookies.set('realtimeActive', realtime.toString());
  688. this.setState({realtimeActive: realtime});
  689. trackAnalytics('issues_stream.realtime_clicked', {
  690. organization: this.props.organization,
  691. enabled: realtime,
  692. });
  693. };
  694. onSelectStatsPeriod = (period: string) => {
  695. const {location} = this.props;
  696. if (period !== this.getGroupStatsPeriod()) {
  697. const cursor = location.query.cursor;
  698. const queryPageInt = parseInt(location.query.page, 10);
  699. const page = isNaN(queryPageInt) || !location.query.cursor ? 0 : queryPageInt;
  700. this.transitionTo({cursor, page, groupStatsPeriod: period});
  701. }
  702. };
  703. onRealtimePoll = (data: any, {queryCount}: {queryCount: number}) => {
  704. // Note: We do not update state with cursors from polling,
  705. // `CursorPoller` updates itself with new cursors
  706. GroupStore.addToFront(data);
  707. this.setState({queryCount});
  708. };
  709. listener = GroupStore.listen(() => this.onGroupChange(), undefined);
  710. onGroupChange() {
  711. const groupIds = GroupStore.getAllItems()
  712. .map(item => item.id)
  713. .slice(0, MAX_ISSUES_COUNT);
  714. if (!isEqual(groupIds, this.state.groupIds)) {
  715. this.setState({groupIds});
  716. }
  717. }
  718. trackTabViewed(groups: string[], data: Group[], numHits: number | null) {
  719. const {organization, location} = this.props;
  720. const page = location.query.page;
  721. const endpointParams = this.getEndpointParams();
  722. const tabQueriesWithCounts = getTabsWithCounts();
  723. const currentTabQuery = tabQueriesWithCounts.includes(endpointParams.query as Query)
  724. ? endpointParams.query
  725. : null;
  726. const tab = getTabs().find(([tabQuery]) => currentTabQuery === tabQuery)?.[1];
  727. const numPerfIssues = groups.filter(
  728. group => GroupStore.get(group)?.issueCategory === IssueCategory.PERFORMANCE
  729. ).length;
  730. // First and last seen are only available after the group has fetched stats
  731. // Number of issues shown whose first seen is more than 30 days ago
  732. const numOldIssues = data.filter((group: BaseGroup) =>
  733. moment(new Date(group.firstSeen)).isBefore(moment().subtract(30, 'd'))
  734. ).length;
  735. // number of issues shown whose first seen is less than 7 days
  736. const numNewIssues = data.filter((group: BaseGroup) =>
  737. moment(new Date(group.firstSeen)).isAfter(moment().subtract(7, 'd'))
  738. ).length;
  739. trackAnalytics('issues_tab.viewed', {
  740. organization,
  741. tab: tab?.analyticsName,
  742. page: page ? parseInt(page, 10) : 0,
  743. query: this.getQuery(),
  744. num_perf_issues: numPerfIssues,
  745. num_old_issues: numOldIssues,
  746. num_new_issues: numNewIssues,
  747. num_issues: data.length,
  748. total_issues_count: numHits,
  749. sort: this.getSort(),
  750. });
  751. }
  752. onSearch = (query: string) => {
  753. if (query === this.state.query) {
  754. // if query is the same, just re-fetch data
  755. this.fetchData();
  756. } else {
  757. // Clear the saved search as the user wants something else.
  758. this.transitionTo({query}, null);
  759. }
  760. };
  761. onSortChange = (sort: string) => {
  762. trackAnalytics('issues_stream.sort_changed', {
  763. organization: this.props.organization,
  764. sort,
  765. });
  766. this.transitionTo({sort});
  767. };
  768. onCursorChange: CursorHandler = (nextCursor, _path, _query, delta) => {
  769. const queryPageInt = parseInt(this.props.location.query.page, 10);
  770. let nextPage: number | undefined = isNaN(queryPageInt) ? delta : queryPageInt + delta;
  771. let cursor: undefined | string = nextCursor;
  772. // unset cursor and page when we navigate back to the first page
  773. // also reset cursor if somehow the previous button is enabled on
  774. // first page and user attempts to go backwards
  775. if (nextPage <= 0) {
  776. cursor = undefined;
  777. nextPage = undefined;
  778. }
  779. this.transitionTo({cursor, page: nextPage});
  780. };
  781. paginationAnalyticsEvent = (direction: string) => {
  782. trackAnalytics('issues_stream.paginate', {
  783. organization: this.props.organization,
  784. direction,
  785. });
  786. };
  787. /**
  788. * Returns true if all results in the current query are visible/on this page
  789. */
  790. allResultsVisible(): boolean {
  791. if (!this.state.pageLinks) {
  792. return false;
  793. }
  794. const links = parseLinkHeader(this.state.pageLinks);
  795. return links && !links.previous.results && !links.next.results;
  796. }
  797. transitionTo = (
  798. newParams: Partial<EndpointParams> = {},
  799. savedSearch: (SavedSearch & {projectId?: number}) | null = this.props.savedSearch
  800. ) => {
  801. const query = {
  802. ...omit(this.props.location.query, ['page', 'cursor']),
  803. referrer: 'issue-list',
  804. ...this.getEndpointParams(),
  805. ...newParams,
  806. };
  807. const {organization} = this.props;
  808. let path: string;
  809. if (savedSearch?.id) {
  810. path = `/organizations/${organization.slug}/issues/searches/${savedSearch.id}/`;
  811. // Remove the query as saved searches bring their own query string.
  812. delete query.query;
  813. // If we aren't going to another page in the same search
  814. // drop the query and replace the current project, with the saved search search project
  815. // if available.
  816. if (!query.cursor && savedSearch.projectId) {
  817. query.project = [savedSearch.projectId];
  818. }
  819. if (!query.cursor && !newParams.sort && savedSearch.sort) {
  820. query.sort = savedSearch.sort;
  821. }
  822. } else {
  823. path = `/organizations/${organization.slug}/issues/`;
  824. }
  825. if (
  826. query.sort === IssueSortOptions.INBOX &&
  827. !FOR_REVIEW_QUERIES.includes(query.query || '')
  828. ) {
  829. delete query.sort;
  830. }
  831. if (
  832. path !== this.props.location.pathname ||
  833. !isEqual(query, this.props.location.query)
  834. ) {
  835. browserHistory.push({
  836. pathname: normalizeUrl(path),
  837. query,
  838. });
  839. this.setState({issuesLoading: true});
  840. }
  841. };
  842. displayReprocessingTab() {
  843. return !!this.state.queryCounts?.[Query.REPROCESSING]?.count;
  844. }
  845. displayReprocessingLayout(showReprocessingTab: boolean, query: string) {
  846. return showReprocessingTab && query === Query.REPROCESSING;
  847. }
  848. renderLoading(): React.ReactNode {
  849. return (
  850. <Layout.Page withPadding>
  851. <LoadingIndicator />
  852. </Layout.Page>
  853. );
  854. }
  855. onSavedSearchSelect = (savedSearch: SavedSearch) => {
  856. trackAnalytics('organization_saved_search.selected', {
  857. organization: this.props.organization,
  858. search_type: 'issues',
  859. id: savedSearch.id ? parseInt(savedSearch.id, 10) : -1,
  860. is_global: savedSearch.isGlobal,
  861. query: savedSearch.query,
  862. visibility: savedSearch.visibility,
  863. });
  864. this.setState({issuesLoading: true}, () => this.transitionTo(undefined, savedSearch));
  865. };
  866. onDelete = () => {
  867. this.actionTaken = true;
  868. this.fetchData(true);
  869. };
  870. undoAction = ({data, groups}: {data: IssueUpdateData; groups: BaseGroup[]}) => {
  871. const {organization, selection} = this.props;
  872. const query = this.getQuery();
  873. const projectIds = selection?.projects?.map(p => p.toString());
  874. const endpoint = `/organizations/${organization.slug}/issues/`;
  875. if (this._lastRequest) {
  876. this._lastRequest.cancel();
  877. }
  878. if (this._lastStatsRequest) {
  879. this._lastStatsRequest.cancel();
  880. }
  881. if (this._lastFetchCountsRequest) {
  882. this._lastFetchCountsRequest.cancel();
  883. }
  884. this.props.api.request(endpoint, {
  885. method: 'PUT',
  886. data,
  887. query: {
  888. project: projectIds,
  889. id: groups.map(group => group.id),
  890. },
  891. success: response => {
  892. if (!response) {
  893. return;
  894. }
  895. // If on the Ignore or For Review tab, adding back to the GroupStore will make the issue show up
  896. // on this page for a second and then be removed (will show up on All Unresolved). This is to
  897. // stop this from happening and avoid confusion.
  898. if (!query.includes('is:ignored') && !isForReviewQuery(query)) {
  899. GroupStore.add(groups);
  900. }
  901. this.undo = true;
  902. },
  903. error: err => {
  904. this.setState({
  905. error: parseApiError(err),
  906. issuesLoading: false,
  907. });
  908. },
  909. complete: () => {
  910. this.fetchData();
  911. },
  912. });
  913. };
  914. onActionTaken = (itemIds: string[], data: IssueUpdateData) => {
  915. if (this.state.realtimeActive) {
  916. return;
  917. }
  918. const query = this.getQuery();
  919. const groups = itemIds.map(id => GroupStore.get(id)).filter(defined);
  920. if ('status' in data) {
  921. if (data.status === 'resolved') {
  922. this.onIssueAction({
  923. itemIds,
  924. actionType: 'Resolved',
  925. shouldRemove:
  926. query.includes('is:unresolved') ||
  927. query.includes('is:ignored') ||
  928. isForReviewQuery(query),
  929. undo: () =>
  930. this.undoAction({
  931. data: {status: GroupStatus.UNRESOLVED, statusDetails: {}},
  932. groups,
  933. }),
  934. });
  935. return;
  936. }
  937. if (data.status === 'ignored') {
  938. this.onIssueAction({
  939. itemIds,
  940. actionType: 'Archived',
  941. shouldRemove: query.includes('is:unresolved') || isForReviewQuery(query),
  942. undo: () =>
  943. this.undoAction({
  944. data: {status: GroupStatus.UNRESOLVED, statusDetails: {}},
  945. groups,
  946. }),
  947. });
  948. return;
  949. }
  950. }
  951. if ('inbox' in data && data.inbox === false) {
  952. this.onIssueAction({
  953. itemIds,
  954. actionType: 'Reviewed',
  955. shouldRemove: isForReviewQuery(query),
  956. });
  957. return;
  958. }
  959. if ('priority' in data && typeof data.priority === 'string') {
  960. const priorityValues = parseIssuePrioritySearch(query);
  961. const priority = data.priority.toLowerCase() as PriorityLevel;
  962. this.onIssueAction({
  963. itemIds,
  964. actionType: 'Reprioritized',
  965. shouldRemove: !priorityValues.has(priority),
  966. });
  967. return;
  968. }
  969. };
  970. onIssueAction = ({
  971. itemIds,
  972. actionType,
  973. shouldRemove,
  974. undo,
  975. }: {
  976. actionType: 'Reviewed' | 'Resolved' | 'Ignored' | 'Archived' | 'Reprioritized';
  977. itemIds: string[];
  978. shouldRemove: boolean;
  979. undo?: () => void;
  980. }) => {
  981. if (itemIds.length > 1) {
  982. addMessage(`${actionType} ${itemIds.length} ${t('Issues')}`, 'success', {
  983. duration: 4000,
  984. undo,
  985. });
  986. } else {
  987. const shortId = itemIds.map(item => GroupStore.get(item)?.shortId).toString();
  988. addMessage(`${actionType} ${shortId}`, 'success', {
  989. duration: 4000,
  990. undo,
  991. });
  992. }
  993. if (!shouldRemove) {
  994. return;
  995. }
  996. const links = parseLinkHeader(this.state.pageLinks);
  997. GroupStore.remove(itemIds);
  998. const queryCount = this.state.queryCount - itemIds.length;
  999. this.actionTaken = true;
  1000. this.setState({queryCount});
  1001. if (GroupStore.getAllItemIds().length === 0) {
  1002. // If we run out of issues on the last page, navigate back a page to
  1003. // avoid showing an empty state - if not on the last page, just show a spinner
  1004. const shouldGoBackAPage = links?.previous?.results && !links?.next?.results;
  1005. this.transitionTo({cursor: shouldGoBackAPage ? links.previous.cursor : undefined});
  1006. this.fetchCounts(queryCount, true);
  1007. } else {
  1008. this.fetchData(true);
  1009. }
  1010. };
  1011. tagValueLoader = (key: string, search: string) => {
  1012. const {organization} = this.props;
  1013. const projectIds = this.getSelectedProjectIds();
  1014. const endpointParams = this.getEndpointParams();
  1015. return fetchTagValues({
  1016. api: this.props.api,
  1017. orgSlug: organization.slug,
  1018. tagKey: key,
  1019. search,
  1020. projectIds,
  1021. endpointParams: endpointParams as any,
  1022. });
  1023. };
  1024. getPageCounts = () => {
  1025. const {location} = this.props;
  1026. const {pageLinks, queryCount, groupIds} = this.state;
  1027. const links = parseLinkHeader(pageLinks);
  1028. const queryPageInt = parseInt(location.query.page, 10);
  1029. // Cursor must be present for the page number to be used
  1030. const page = isNaN(queryPageInt) || !location.query.cursor ? 0 : queryPageInt;
  1031. let numPreviousIssues = Math.min(page * MAX_ITEMS, queryCount);
  1032. // Because the query param `page` is not tied to the request, we need to
  1033. // validate that it's correct at the first and last page
  1034. if (!links?.next?.results || this.allResultsVisible()) {
  1035. // On last available page
  1036. numPreviousIssues = Math.max(queryCount - groupIds.length, 0);
  1037. } else if (!links?.previous?.results) {
  1038. // On first available page
  1039. numPreviousIssues = 0;
  1040. }
  1041. return {
  1042. numPreviousIssues,
  1043. numIssuesOnPage: groupIds.length,
  1044. };
  1045. };
  1046. render() {
  1047. if (
  1048. this.props.savedSearchLoading &&
  1049. !this.props.organization.features.includes('issue-stream-performance')
  1050. ) {
  1051. return this.renderLoading();
  1052. }
  1053. const {
  1054. pageLinks,
  1055. queryCount,
  1056. queryCounts,
  1057. realtimeActive,
  1058. groupIds,
  1059. queryMaxCount,
  1060. issuesLoading,
  1061. error,
  1062. } = this.state;
  1063. const {organization, selection, router} = this.props;
  1064. const query = this.getQuery();
  1065. const modifiedQueryCount = Math.max(queryCount, 0);
  1066. // TODO: these two might still be in use for reprocessing2
  1067. const showReprocessingTab = this.displayReprocessingTab();
  1068. const displayReprocessingActions = this.displayReprocessingLayout(
  1069. showReprocessingTab,
  1070. query
  1071. );
  1072. const {numPreviousIssues, numIssuesOnPage} = this.getPageCounts();
  1073. return (
  1074. <Layout.Page>
  1075. {organization.features.includes('issue-stream-custom-views') ? (
  1076. <ErrorBoundary message={'Failed to load custom tabs'}>
  1077. <CustomViewsIssueListHeader
  1078. organization={organization}
  1079. queryCounts={queryCounts}
  1080. router={router}
  1081. selectedProjectIds={selection.projects}
  1082. />
  1083. </ErrorBoundary>
  1084. ) : (
  1085. <IssueListHeader
  1086. organization={organization}
  1087. query={query}
  1088. sort={this.getSort()}
  1089. queryCount={queryCount}
  1090. queryCounts={queryCounts}
  1091. realtimeActive={realtimeActive}
  1092. onRealtimeChange={this.onRealtimeChange}
  1093. router={router}
  1094. displayReprocessingTab={showReprocessingTab}
  1095. selectedProjectIds={selection.projects}
  1096. />
  1097. )}
  1098. <StyledBody>
  1099. <StyledMain>
  1100. <DataConsentBanner source="issues" />
  1101. <IssueListFilters query={query} onSearch={this.onSearch} />
  1102. <Panel>
  1103. {groupIds.length !== 0 && (
  1104. <IssueListActions
  1105. selection={selection}
  1106. query={query}
  1107. queryCount={modifiedQueryCount}
  1108. onSelectStatsPeriod={this.onSelectStatsPeriod}
  1109. onActionTaken={this.onActionTaken}
  1110. onDelete={this.onDelete}
  1111. statsPeriod={this.getGroupStatsPeriod()}
  1112. groupIds={groupIds}
  1113. allResultsVisible={this.allResultsVisible()}
  1114. displayReprocessingActions={displayReprocessingActions}
  1115. sort={this.getSort()}
  1116. onSortChange={this.onSortChange}
  1117. />
  1118. )}
  1119. <PanelBody>
  1120. <VisuallyCompleteWithData
  1121. hasData={this.state.groupIds.length > 0}
  1122. id="IssueList-Body"
  1123. isLoading={this.state.issuesLoading}
  1124. >
  1125. <GroupListBody
  1126. memberList={this.state.memberList}
  1127. groupStatsPeriod={this.getGroupStatsPeriod()}
  1128. groupIds={groupIds}
  1129. displayReprocessingLayout={displayReprocessingActions}
  1130. query={query}
  1131. selectedProjectIds={selection.projects}
  1132. loading={issuesLoading}
  1133. error={error}
  1134. refetchGroups={this.fetchData}
  1135. onActionTaken={this.onActionTaken}
  1136. />
  1137. </VisuallyCompleteWithData>
  1138. </PanelBody>
  1139. </Panel>
  1140. <StyledPagination
  1141. caption={
  1142. !issuesLoading && modifiedQueryCount > 0
  1143. ? tct('[start]-[end] of [total]', {
  1144. start: numPreviousIssues + 1,
  1145. end: numPreviousIssues + numIssuesOnPage,
  1146. total: (
  1147. <StyledQueryCount
  1148. hideParens
  1149. hideIfEmpty={false}
  1150. count={modifiedQueryCount}
  1151. max={queryMaxCount || 100}
  1152. />
  1153. ),
  1154. })
  1155. : null
  1156. }
  1157. pageLinks={pageLinks}
  1158. onCursor={this.onCursorChange}
  1159. paginationAnalyticsEvent={this.paginationAnalyticsEvent}
  1160. />
  1161. </StyledMain>
  1162. <SavedIssueSearches
  1163. {...{organization, query}}
  1164. onSavedSearchSelect={this.onSavedSearchSelect}
  1165. sort={this.getSort()}
  1166. />
  1167. </StyledBody>
  1168. </Layout.Page>
  1169. );
  1170. }
  1171. }
  1172. export default withRouteAnalytics(
  1173. withApi(
  1174. withPageFilters(
  1175. withSavedSearches(
  1176. withOrganization(withIssueTags(Sentry.withProfiler(IssueListOverview)))
  1177. )
  1178. )
  1179. )
  1180. );
  1181. export {IssueListOverview};
  1182. const StyledBody = styled('div')`
  1183. background-color: ${p => p.theme.background};
  1184. flex: 1;
  1185. display: grid;
  1186. gap: 0;
  1187. padding: 0;
  1188. grid-template-rows: 1fr;
  1189. grid-template-columns: minmax(0, 1fr) auto;
  1190. grid-template-areas: 'content saved-searches';
  1191. `;
  1192. const StyledMain = styled('section')`
  1193. grid-area: content;
  1194. padding: ${space(2)};
  1195. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  1196. padding: ${space(3)} ${space(4)};
  1197. }
  1198. `;
  1199. const StyledPagination = styled(Pagination)`
  1200. margin-top: 0;
  1201. `;
  1202. const StyledQueryCount = styled(QueryCount)`
  1203. margin-left: 0;
  1204. `;