overview.tsx 41 KB

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