overview.tsx 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  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. });
  497. // Used for Issue Stream Performance project, enabled means we are doing saved search look up in the backend
  498. const savedSearchLookupEnabled = 0;
  499. const savedSearchLookupDisabled = 1;
  500. const requestParams: any = {
  501. ...this.getEndpointParams(),
  502. limit: MAX_ITEMS,
  503. shortIdLookup: 1,
  504. savedSearch: this.props.organization.features.includes('issue-stream-performance')
  505. ? this.props.savedSearchLoading
  506. ? savedSearchLookupEnabled
  507. : savedSearchLookupDisabled
  508. : savedSearchLookupDisabled,
  509. };
  510. if (
  511. this.props.organization.features.includes('issue-stream-performance') &&
  512. this.props.selectedSearchId
  513. ) {
  514. requestParams.searchId = this.props.selectedSearchId;
  515. }
  516. if (
  517. this.props.organization.features.includes('issue-stream-performance') &&
  518. this.props.savedSearchLoading &&
  519. !this.props.location.query.query
  520. ) {
  521. delete requestParams.query;
  522. }
  523. const currentQuery = this.props.location.query || {};
  524. if ('cursor' in currentQuery) {
  525. requestParams.cursor = currentQuery.cursor;
  526. }
  527. // If no stats period values are set, use default
  528. if (!requestParams.statsPeriod && !requestParams.start) {
  529. requestParams.statsPeriod = DEFAULT_STATS_PERIOD;
  530. }
  531. requestParams.expand = ['owners', 'inbox'];
  532. requestParams.collapse = ['stats', 'unhandled'];
  533. if (this._lastRequest) {
  534. this._lastRequest.cancel();
  535. }
  536. if (this._lastFetchCountsRequest) {
  537. this._lastFetchCountsRequest.cancel();
  538. }
  539. this._poller.disable();
  540. this._lastRequest = this.props.api.request(this.groupListEndpoint, {
  541. method: 'GET',
  542. data: qs.stringify(requestParams),
  543. success: (data, _, resp) => {
  544. if (!resp) {
  545. return;
  546. }
  547. // If this is a direct hit, we redirect to the intended result directly.
  548. if (resp.getResponseHeader('X-Sentry-Direct-Hit') === '1') {
  549. let redirect: string;
  550. if (data[0] && data[0].matchingEventId) {
  551. const {id, matchingEventId} = data[0];
  552. redirect = `/organizations/${organization.slug}/issues/${id}/events/${matchingEventId}/`;
  553. } else {
  554. const {id} = data[0];
  555. redirect = `/organizations/${organization.slug}/issues/${id}/`;
  556. }
  557. browserHistory.replace(
  558. normalizeUrl({
  559. pathname: redirect,
  560. query: {
  561. referrer: 'issue-list',
  562. ...extractSelectionParameters(this.props.location.query),
  563. },
  564. })
  565. );
  566. return;
  567. }
  568. if (this.state.undo) {
  569. GroupStore.loadInitialData(data);
  570. }
  571. GroupStore.add(data);
  572. const hits = resp.getResponseHeader('X-Hits');
  573. const queryCount =
  574. typeof hits !== 'undefined' && hits ? parseInt(hits, 10) || 0 : 0;
  575. const maxHits = resp.getResponseHeader('X-Max-Hits');
  576. const queryMaxCount =
  577. typeof maxHits !== 'undefined' && maxHits ? parseInt(maxHits, 10) || 0 : 0;
  578. const pageLinks = resp.getResponseHeader('Link');
  579. this.fetchCounts(queryCount, fetchAllCounts);
  580. this.setState({
  581. error: null,
  582. issuesLoading: false,
  583. statsForGroupIds: data.map(group => group.id),
  584. queryCount,
  585. queryMaxCount,
  586. pageLinks: pageLinks !== null ? pageLinks : '',
  587. });
  588. if (data.length === 0) {
  589. trackAnalytics('issue_search.empty', {
  590. organization: this.props.organization,
  591. search_type: 'issues',
  592. search_source: 'main_search',
  593. query,
  594. });
  595. }
  596. },
  597. error: err => {
  598. trackAnalytics('issue_search.failed', {
  599. organization: this.props.organization,
  600. search_type: 'issues',
  601. search_source: 'main_search',
  602. error: parseApiError(err),
  603. });
  604. this.setState({
  605. error: parseApiError(err),
  606. issuesLoading: false,
  607. statsForGroupIds: [],
  608. });
  609. },
  610. complete: () => {
  611. this._lastRequest = null;
  612. this.resumePolling();
  613. if (!this.state.realtimeActive) {
  614. this.setState({actionTaken: false, undo: false});
  615. }
  616. },
  617. });
  618. };
  619. resumePolling = () => {
  620. if (!this.state.pageLinks) {
  621. return;
  622. }
  623. // Only resume polling if we're on the first page of results
  624. const links = parseLinkHeader(this.state.pageLinks);
  625. if (links && !links.previous.results && this.state.realtimeActive) {
  626. this._poller.setEndpoint(links?.previous?.href);
  627. this._poller.enable();
  628. }
  629. };
  630. get groupListEndpoint(): string {
  631. const {organization} = this.props;
  632. return `/organizations/${organization.slug}/issues/`;
  633. }
  634. get groupCountsEndpoint(): string {
  635. const {organization} = this.props;
  636. return `/organizations/${organization.slug}/issues-count/`;
  637. }
  638. get groupStatsEndpoint(): string {
  639. const {organization} = this.props;
  640. return `/organizations/${organization.slug}/issues-stats/`;
  641. }
  642. onRealtimeChange = (realtime: boolean) => {
  643. Cookies.set('realtimeActive', realtime.toString());
  644. this.setState({realtimeActive: realtime});
  645. trackAnalytics('issues_stream.realtime_clicked', {
  646. organization: this.props.organization,
  647. enabled: realtime,
  648. });
  649. };
  650. onSelectStatsPeriod = (period: string) => {
  651. const {location} = this.props;
  652. if (period !== this.getGroupStatsPeriod()) {
  653. const cursor = location.query.cursor;
  654. const queryPageInt = parseInt(location.query.page, 10);
  655. const page = isNaN(queryPageInt) || !location.query.cursor ? 0 : queryPageInt;
  656. this.transitionTo({cursor, page, groupStatsPeriod: period});
  657. }
  658. };
  659. onRealtimePoll = (data: any, {queryCount}: {queryCount: number}) => {
  660. // Note: We do not update state with cursors from polling,
  661. // `CursorPoller` updates itself with new cursors
  662. GroupStore.addToFront(data);
  663. this.setState({queryCount});
  664. };
  665. listener = GroupStore.listen(() => this.onGroupChange(), undefined);
  666. onGroupChange() {
  667. const {organization} = this.props;
  668. const {actionTakenGroupData} = this.state;
  669. const query = this.getQuery();
  670. if (!this.state.realtimeActive && actionTakenGroupData.length > 0) {
  671. const filteredItems = GroupStore.getAllItems().filter(item => {
  672. return actionTakenGroupData.findIndex(data => data.id === item.id) !== -1;
  673. });
  674. const resolvedIds = filteredItems
  675. .filter(item => item.status === 'resolved')
  676. .map(id => id.id);
  677. const ignoredIds = filteredItems
  678. .filter(item => item.status === 'ignored')
  679. .map(i => i.id);
  680. // need to include resolve and ignored statuses because marking as resolved/ignored also
  681. // counts as reviewed
  682. const reviewedIds = filteredItems
  683. .filter(
  684. item => !item.inbox && item.status !== 'resolved' && item.status !== 'ignored'
  685. )
  686. .map(i => i.id);
  687. // Remove Ignored and Resolved group ids from the issue stream if on the All Unresolved,
  688. // For Review, or Ignored tab. Still include on the saved/custom search tab.
  689. if (
  690. resolvedIds.length > 0 &&
  691. (query.includes('is:unresolved') ||
  692. query.includes('is:ignored') ||
  693. isForReviewQuery(query))
  694. ) {
  695. this.onIssueAction(resolvedIds, 'Resolved');
  696. }
  697. if (
  698. ignoredIds.length > 0 &&
  699. (query.includes('is:unresolved') || isForReviewQuery(query))
  700. ) {
  701. const hasEscalatingIssues = organization.features.includes('escalating-issues');
  702. this.onIssueAction(ignoredIds, hasEscalatingIssues ? 'Archived' : 'Ignored');
  703. }
  704. // Remove issues that are marked as Reviewed from the For Review tab, but still include the
  705. // issues if on the All Unresolved tab or saved/custom searches.
  706. if (
  707. reviewedIds.length > 0 &&
  708. (isForReviewQuery(query) || query.includes('is:ignored'))
  709. ) {
  710. this.onIssueAction(reviewedIds, 'Reviewed');
  711. }
  712. }
  713. const groupIds = GroupStore.getAllItems()
  714. .map(item => item.id)
  715. .slice(0, MAX_ISSUES_COUNT);
  716. if (!isEqual(groupIds, this.state.groupIds)) {
  717. this.setState({groupIds});
  718. }
  719. }
  720. trackTabViewed(groups: string[], data: Group[]) {
  721. const {organization, location} = this.props;
  722. const page = location.query.page;
  723. const endpointParams = this.getEndpointParams();
  724. const tabQueriesWithCounts = getTabsWithCounts(organization);
  725. const currentTabQuery = tabQueriesWithCounts.includes(endpointParams.query as Query)
  726. ? endpointParams.query
  727. : null;
  728. const tab = getTabs(organization).find(
  729. ([tabQuery]) => currentTabQuery === tabQuery
  730. )?.[1];
  731. const numPerfIssues = groups.filter(
  732. group => GroupStore.get(group)?.issueCategory === IssueCategory.PERFORMANCE
  733. ).length;
  734. // First and last seen are only available after the group has fetched stats
  735. // Number of issues shown whose first seen is more than 30 days ago
  736. const numOldIssues = data.filter((group: BaseGroup) =>
  737. moment(new Date(group.firstSeen)).isBefore(moment().subtract(30, 'd'))
  738. ).length;
  739. // number of issues shown whose first seen is less than 7 days
  740. const numNewIssues = data.filter((group: BaseGroup) =>
  741. moment(new Date(group.firstSeen)).isAfter(moment().subtract(7, 'd'))
  742. ).length;
  743. trackAnalytics('issues_tab.viewed', {
  744. organization,
  745. tab: tab?.analyticsName,
  746. page: page ? parseInt(page, 10) : 0,
  747. query: this.getQuery(),
  748. num_perf_issues: numPerfIssues,
  749. num_old_issues: numOldIssues,
  750. num_new_issues: numNewIssues,
  751. num_issues: data.length,
  752. sort: this.getSort(),
  753. });
  754. }
  755. onSearch = (query: string) => {
  756. if (query === this.state.query) {
  757. // if query is the same, just re-fetch data
  758. this.fetchData();
  759. } else {
  760. // Clear the saved search as the user wants something else.
  761. this.transitionTo({query}, null);
  762. }
  763. };
  764. onSortChange = (sort: string) => {
  765. trackAnalytics('issues_stream.sort_changed', {
  766. organization: this.props.organization,
  767. sort,
  768. });
  769. this.transitionTo({sort});
  770. };
  771. onCursorChange: CursorHandler = (nextCursor, _path, _query, delta) => {
  772. const queryPageInt = parseInt(this.props.location.query.page, 10);
  773. let nextPage: number | undefined = isNaN(queryPageInt) ? delta : queryPageInt + delta;
  774. let cursor: undefined | string = nextCursor;
  775. // unset cursor and page when we navigate back to the first page
  776. // also reset cursor if somehow the previous button is enabled on
  777. // first page and user attempts to go backwards
  778. if (nextPage <= 0) {
  779. cursor = undefined;
  780. nextPage = undefined;
  781. }
  782. this.transitionTo({cursor, page: nextPage});
  783. };
  784. paginationAnalyticsEvent = (direction: string) => {
  785. trackAnalytics('issues_stream.paginate', {
  786. organization: this.props.organization,
  787. direction,
  788. });
  789. };
  790. /**
  791. * Returns true if all results in the current query are visible/on this page
  792. */
  793. allResultsVisible(): boolean {
  794. if (!this.state.pageLinks) {
  795. return false;
  796. }
  797. const links = parseLinkHeader(this.state.pageLinks);
  798. return links && !links.previous.results && !links.next.results;
  799. }
  800. transitionTo = (
  801. newParams: Partial<EndpointParams> = {},
  802. savedSearch: (SavedSearch & {projectId?: number}) | null = this.props.savedSearch
  803. ) => {
  804. const query = {
  805. ...omit(this.props.location.query, ['page', 'cursor']),
  806. referrer: 'issue-list',
  807. ...this.getEndpointParams(),
  808. ...newParams,
  809. };
  810. const {organization} = this.props;
  811. let path: string;
  812. if (savedSearch && savedSearch.id) {
  813. path = `/organizations/${organization.slug}/issues/searches/${savedSearch.id}/`;
  814. // Remove the query as saved searches bring their own query string.
  815. delete query.query;
  816. // If we aren't going to another page in the same search
  817. // drop the query and replace the current project, with the saved search search project
  818. // if available.
  819. if (!query.cursor && savedSearch.projectId) {
  820. query.project = [savedSearch.projectId];
  821. }
  822. if (!query.cursor && !newParams.sort && savedSearch.sort) {
  823. query.sort = savedSearch.sort;
  824. }
  825. } else {
  826. path = `/organizations/${organization.slug}/issues/`;
  827. }
  828. if (
  829. query.sort === IssueSortOptions.INBOX &&
  830. !FOR_REVIEW_QUERIES.includes(query.query || '')
  831. ) {
  832. delete query.sort;
  833. }
  834. if (
  835. path !== this.props.location.pathname ||
  836. !isEqual(query, this.props.location.query)
  837. ) {
  838. browserHistory.push({
  839. pathname: normalizeUrl(path),
  840. query,
  841. });
  842. this.setState({issuesLoading: true});
  843. }
  844. };
  845. displayReprocessingTab() {
  846. const {organization} = this.props;
  847. const {queryCounts} = this.state;
  848. return (
  849. organization.features.includes('reprocessing-v2') &&
  850. !!queryCounts?.[Query.REPROCESSING]?.count
  851. );
  852. }
  853. displayReprocessingLayout(showReprocessingTab: boolean, query: string) {
  854. return showReprocessingTab && query === Query.REPROCESSING;
  855. }
  856. renderLoading(): React.ReactNode {
  857. return (
  858. <Layout.Page withPadding>
  859. <LoadingIndicator />
  860. </Layout.Page>
  861. );
  862. }
  863. onSavedSearchSelect = (savedSearch: SavedSearch) => {
  864. trackAnalytics('organization_saved_search.selected', {
  865. organization: this.props.organization,
  866. search_type: 'issues',
  867. id: savedSearch.id ? parseInt(savedSearch.id, 10) : -1,
  868. is_global: savedSearch.isGlobal,
  869. query: savedSearch.query,
  870. visibility: savedSearch.visibility,
  871. });
  872. this.setState({issuesLoading: true}, () => this.transitionTo(undefined, savedSearch));
  873. };
  874. onDelete = () => {
  875. this.setState({actionTaken: true});
  876. this.fetchData(true);
  877. };
  878. onUndo = () => {
  879. const {organization, selection} = this.props;
  880. const {actionTakenGroupData} = this.state;
  881. const query = this.getQuery();
  882. const groupIds = actionTakenGroupData.map(data => data.id);
  883. const projectIds = selection?.projects?.map(p => p.toString());
  884. const endpoint = `/organizations/${organization.slug}/issues/`;
  885. if (this._lastRequest) {
  886. this._lastRequest.cancel();
  887. }
  888. if (this._lastFetchCountsRequest) {
  889. this._lastFetchCountsRequest.cancel();
  890. }
  891. this.props.api.request(endpoint, {
  892. method: 'PUT',
  893. data: {
  894. status: 'unresolved',
  895. },
  896. query: {
  897. project: projectIds,
  898. id: groupIds,
  899. },
  900. success: response => {
  901. if (!response) {
  902. return;
  903. }
  904. // If on the Ignore or For Review tab, adding back to the GroupStore will make the issue show up
  905. // on this page for a second and then be removed (will show up on All Unresolved). This is to
  906. // stop this from happening and avoid confusion.
  907. if (!query.includes('is:ignored') && !isForReviewQuery(query)) {
  908. GroupStore.add(actionTakenGroupData);
  909. }
  910. this.setState({undo: true});
  911. },
  912. error: err => {
  913. this.setState({
  914. error: parseApiError(err),
  915. issuesLoading: false,
  916. });
  917. },
  918. complete: () => {
  919. this.setState({actionTakenGroupData: []});
  920. this.fetchData();
  921. },
  922. });
  923. };
  924. onMarkReviewed = (itemIds: string[]) => {
  925. const query = this.getQuery();
  926. if (!isForReviewQuery(query)) {
  927. if (itemIds.length > 1) {
  928. addMessage(
  929. tn('Reviewed %s Issue', 'Reviewed %s Issues', itemIds.length),
  930. 'success',
  931. {duration: 4000}
  932. );
  933. } else {
  934. const shortId = itemIds.map(item => GroupStore.get(item)?.shortId).toString();
  935. addMessage(t('Reviewed %s', shortId), 'success', {duration: 4000});
  936. }
  937. return;
  938. }
  939. const {queryCounts, itemsRemoved} = this.state;
  940. const currentQueryCount = queryCounts[query as Query];
  941. if (itemIds.length && currentQueryCount) {
  942. const inInboxCount = itemIds.filter(id => GroupStore.get(id)?.inbox).length;
  943. currentQueryCount.count -= inInboxCount;
  944. this.setState({
  945. queryCounts: {
  946. ...queryCounts,
  947. [query as Query]: currentQueryCount,
  948. },
  949. itemsRemoved: itemsRemoved + inInboxCount,
  950. });
  951. }
  952. };
  953. onActionTaken = (itemIds: string[]) => {
  954. const actionTakenGroupData = itemIds
  955. .map(id => GroupStore.get(id) as Group | undefined)
  956. .filter(defined);
  957. this.setState({
  958. actionTakenGroupData,
  959. });
  960. };
  961. onIssueAction = (
  962. itemIds: string[],
  963. actionType: 'Reviewed' | 'Resolved' | 'Ignored' | 'Archived'
  964. ) => {
  965. if (itemIds.length > 1) {
  966. addMessage(`${actionType} ${itemIds.length} ${t('Issues')}`, 'success', {
  967. duration: 4000,
  968. ...(actionType !== 'Reviewed' && {undo: this.onUndo}),
  969. });
  970. } else {
  971. const shortId = itemIds.map(item => GroupStore.get(item)?.shortId).toString();
  972. addMessage(`${actionType} ${shortId}`, 'success', {
  973. duration: 4000,
  974. ...(actionType !== 'Reviewed' && {undo: this.onUndo}),
  975. });
  976. }
  977. const links = parseLinkHeader(this.state.pageLinks);
  978. GroupStore.remove(itemIds);
  979. const queryCount = this.state.queryCount - itemIds.length;
  980. this.setState({
  981. actionTaken: true,
  982. queryCount,
  983. });
  984. if (GroupStore.getAllItemIds().length === 0) {
  985. // If we run out of issues on the last page, navigate back a page to
  986. // avoid showing an empty state - if not on the last page, just show a spinner
  987. const shouldGoBackAPage = links?.previous?.results && !links?.next?.results;
  988. this.transitionTo({cursor: shouldGoBackAPage ? links.previous.cursor : undefined});
  989. this.fetchCounts(queryCount, true);
  990. } else {
  991. this.fetchData(true);
  992. }
  993. };
  994. tagValueLoader = (key: string, search: string) => {
  995. const {organization} = this.props;
  996. const projectIds = this.getSelectedProjectIds();
  997. const endpointParams = this.getEndpointParams();
  998. return fetchTagValues({
  999. api: this.props.api,
  1000. orgSlug: organization.slug,
  1001. tagKey: key,
  1002. search,
  1003. projectIds,
  1004. endpointParams: endpointParams as any,
  1005. });
  1006. };
  1007. getPageCounts = () => {
  1008. const {location} = this.props;
  1009. const {pageLinks, queryCount, groupIds} = this.state;
  1010. const links = parseLinkHeader(pageLinks);
  1011. const queryPageInt = parseInt(location.query.page, 10);
  1012. // Cursor must be present for the page number to be used
  1013. const page = isNaN(queryPageInt) || !location.query.cursor ? 0 : queryPageInt;
  1014. let numPreviousIssues = Math.min(page * MAX_ITEMS, queryCount);
  1015. // Because the query param `page` is not tied to the request, we need to
  1016. // validate that it's correct at the first and last page
  1017. if (!links?.next?.results || this.allResultsVisible()) {
  1018. // On last available page
  1019. numPreviousIssues = Math.max(queryCount - groupIds.length, 0);
  1020. } else if (!links?.previous?.results) {
  1021. // On first available page
  1022. numPreviousIssues = 0;
  1023. }
  1024. return {
  1025. numPreviousIssues,
  1026. numIssuesOnPage: groupIds.length,
  1027. };
  1028. };
  1029. onStatsQuery = (query: GroupStatsQuery) => {
  1030. switch (query.status) {
  1031. case 'loading':
  1032. break;
  1033. case 'success':
  1034. const data = Object.values(query.data ?? {});
  1035. if (data && data[0]) {
  1036. // The type being cast was wrong in the previous implementations as well
  1037. // because inference was broken. Ignore it for now.
  1038. this.trackTabViewed(this.state.groupIds, data as Group[]);
  1039. }
  1040. const currentTransaction = Sentry.getCurrentHub().getScope()?.getTransaction();
  1041. if (currentTransaction?.op === 'navigation') {
  1042. currentTransaction.finish();
  1043. }
  1044. break;
  1045. case 'error':
  1046. this.setState({
  1047. // Missing our custom getResponseHeader function, but parseApiError does not require it
  1048. error: parseApiError(query?.error),
  1049. });
  1050. break;
  1051. default:
  1052. }
  1053. };
  1054. render() {
  1055. if (
  1056. this.props.savedSearchLoading &&
  1057. !this.props.organization.features.includes('issue-stream-performance')
  1058. ) {
  1059. return this.renderLoading();
  1060. }
  1061. const {
  1062. pageLinks,
  1063. queryCount,
  1064. queryCounts,
  1065. realtimeActive,
  1066. groupIds,
  1067. queryMaxCount,
  1068. itemsRemoved,
  1069. issuesLoading,
  1070. error,
  1071. } = this.state;
  1072. const {organization, selection, router} = this.props;
  1073. const query = this.getQuery();
  1074. const modifiedQueryCount = Math.max(queryCount - itemsRemoved, 0);
  1075. const projectIds = selection?.projects?.map(p => p.toString());
  1076. const showReprocessingTab = this.displayReprocessingTab();
  1077. const displayReprocessingActions = this.displayReprocessingLayout(
  1078. showReprocessingTab,
  1079. query
  1080. );
  1081. const {numPreviousIssues, numIssuesOnPage} = this.getPageCounts();
  1082. return (
  1083. <Layout.Page>
  1084. <IssueListHeader
  1085. organization={organization}
  1086. query={query}
  1087. sort={this.getSort()}
  1088. queryCount={queryCount}
  1089. queryCounts={queryCounts}
  1090. realtimeActive={realtimeActive}
  1091. onRealtimeChange={this.onRealtimeChange}
  1092. router={router}
  1093. displayReprocessingTab={showReprocessingTab}
  1094. selectedProjectIds={selection.projects}
  1095. />
  1096. <StyledBody>
  1097. <StyledMain>
  1098. <IssueListFilters query={query} onSearch={this.onSearch} />
  1099. <Panel>
  1100. <IssueListActions
  1101. selection={selection}
  1102. query={query}
  1103. queryCount={modifiedQueryCount}
  1104. onSelectStatsPeriod={this.onSelectStatsPeriod}
  1105. onMarkReviewed={this.onMarkReviewed}
  1106. onActionTaken={this.onActionTaken}
  1107. onDelete={this.onDelete}
  1108. statsPeriod={this.getGroupStatsPeriod()}
  1109. groupIds={groupIds}
  1110. allResultsVisible={this.allResultsVisible()}
  1111. displayReprocessingActions={displayReprocessingActions}
  1112. sort={this.getSort()}
  1113. onSortChange={this.onSortChange}
  1114. />
  1115. <PanelBody>
  1116. <ProcessingIssueList
  1117. organization={organization}
  1118. projectIds={projectIds}
  1119. showProject
  1120. />
  1121. <VisuallyCompleteWithData
  1122. id="IssueList-Body"
  1123. hasData={this.state.groupIds.length > 0}
  1124. isLoading={this.state.issuesLoading}
  1125. >
  1126. <GroupStatsProvider
  1127. groupIds={this.state.statsForGroupIds}
  1128. selection={this.props.selection}
  1129. organization={this.props.organization}
  1130. period={this.getGroupStatsPeriod()}
  1131. query={this.getQuery()}
  1132. onStatsQuery={this.onStatsQuery}
  1133. >
  1134. <GroupListBody
  1135. memberList={this.state.memberList}
  1136. groupStatsPeriod={this.getGroupStatsPeriod()}
  1137. groupIds={groupIds}
  1138. displayReprocessingLayout={displayReprocessingActions}
  1139. sort={this.getSort()}
  1140. selectedProjectIds={selection.projects}
  1141. loading={issuesLoading}
  1142. error={error}
  1143. query={query}
  1144. refetchGroups={this.fetchData}
  1145. />
  1146. </GroupStatsProvider>
  1147. </VisuallyCompleteWithData>
  1148. </PanelBody>
  1149. </Panel>
  1150. <StyledPagination
  1151. caption={
  1152. !issuesLoading && modifiedQueryCount > 0
  1153. ? tct('[start]-[end] of [total]', {
  1154. start: numPreviousIssues + 1,
  1155. end: numPreviousIssues + numIssuesOnPage,
  1156. total: (
  1157. <StyledQueryCount
  1158. hideParens
  1159. hideIfEmpty={false}
  1160. count={modifiedQueryCount}
  1161. max={queryMaxCount || 100}
  1162. />
  1163. ),
  1164. })
  1165. : null
  1166. }
  1167. pageLinks={pageLinks}
  1168. onCursor={this.onCursorChange}
  1169. paginationAnalyticsEvent={this.paginationAnalyticsEvent}
  1170. />
  1171. </StyledMain>
  1172. <SavedIssueSearches
  1173. {...{organization, query}}
  1174. onSavedSearchSelect={this.onSavedSearchSelect}
  1175. sort={this.getSort()}
  1176. />
  1177. </StyledBody>
  1178. </Layout.Page>
  1179. );
  1180. }
  1181. }
  1182. export default withRouteAnalytics(
  1183. withApi(
  1184. withPageFilters(
  1185. withSavedSearches(withOrganization(withIssueTags(withProfiler(IssueListOverview))))
  1186. )
  1187. )
  1188. );
  1189. export {IssueListOverview};
  1190. const StyledBody = styled('div')`
  1191. background-color: ${p => p.theme.background};
  1192. flex: 1;
  1193. display: grid;
  1194. gap: 0;
  1195. padding: 0;
  1196. grid-template-rows: 1fr;
  1197. grid-template-columns: minmax(0, 1fr) auto;
  1198. grid-template-areas: 'content saved-searches';
  1199. `;
  1200. const StyledMain = styled('section')`
  1201. grid-area: content;
  1202. padding: ${space(2)};
  1203. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  1204. padding: ${space(3)} ${space(4)};
  1205. }
  1206. `;
  1207. const StyledPagination = styled(Pagination)`
  1208. margin-top: 0;
  1209. `;
  1210. const StyledQueryCount = styled(QueryCount)`
  1211. margin-left: 0;
  1212. `;