overview.tsx 41 KB

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