overview.tsx 41 KB

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