overview.tsx 41 KB

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