index.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import {RouteComponentProps} from 'react-router';
  2. import styled from '@emotion/styled';
  3. import {withProfiler} from '@sentry/react';
  4. import omit from 'lodash/omit';
  5. import {Button} from 'sentry/components/button';
  6. import ButtonBar from 'sentry/components/buttonBar';
  7. import DatePageFilter from 'sentry/components/datePageFilter';
  8. import EnvironmentPageFilter from 'sentry/components/environmentPageFilter';
  9. import {EventUserFeedback} from 'sentry/components/events/userFeedback';
  10. import CompactIssue from 'sentry/components/issues/compactIssue';
  11. import * as Layout from 'sentry/components/layouts/thirds';
  12. import LoadingIndicator from 'sentry/components/loadingIndicator';
  13. import NoProjectMessage from 'sentry/components/noProjectMessage';
  14. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  15. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  16. import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip';
  17. import Pagination from 'sentry/components/pagination';
  18. import {Panel} from 'sentry/components/panels';
  19. import ProjectPageFilter from 'sentry/components/projectPageFilter';
  20. import {t} from 'sentry/locale';
  21. import space from 'sentry/styles/space';
  22. import {Organization, UserReport} from 'sentry/types';
  23. import withOrganization from 'sentry/utils/withOrganization';
  24. import AsyncView from 'sentry/views/asyncView';
  25. import {UserFeedbackEmpty} from './userFeedbackEmpty';
  26. import {getQuery} from './utils';
  27. type State = AsyncView['state'] & {
  28. reportList: UserReport[];
  29. };
  30. type Props = RouteComponentProps<{}, {}> & {
  31. organization: Organization;
  32. };
  33. class OrganizationUserFeedback extends AsyncView<Props, State> {
  34. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  35. const {
  36. organization,
  37. location: {search},
  38. } = this.props;
  39. return [
  40. [
  41. 'reportList',
  42. `/organizations/${organization.slug}/user-feedback/`,
  43. {
  44. query: getQuery(search),
  45. },
  46. ],
  47. ];
  48. }
  49. getTitle() {
  50. return `${t('User Feedback')} - ${this.props.organization.slug}`;
  51. }
  52. get projectIds() {
  53. const {project} = this.props.location.query;
  54. return Array.isArray(project)
  55. ? project
  56. : typeof project === 'string'
  57. ? [project]
  58. : [];
  59. }
  60. renderResults() {
  61. const {organization} = this.props;
  62. return (
  63. <Panel className="issue-list" data-test-id="user-feedback-list">
  64. {this.state.reportList.map(item => {
  65. const issue = item.issue;
  66. return (
  67. <CompactIssue key={item.id} id={issue.id} data={issue} eventId={item.eventID}>
  68. <StyledEventUserFeedback
  69. report={item}
  70. orgId={organization.slug}
  71. issueId={issue.id}
  72. />
  73. </CompactIssue>
  74. );
  75. })}
  76. </Panel>
  77. );
  78. }
  79. renderEmpty() {
  80. return <UserFeedbackEmpty projectIds={this.projectIds} />;
  81. }
  82. renderLoading() {
  83. return this.renderBody();
  84. }
  85. renderStreamBody() {
  86. const {loading, reportList} = this.state;
  87. if (loading) {
  88. return (
  89. <Panel>
  90. <LoadingIndicator />
  91. </Panel>
  92. );
  93. }
  94. if (!reportList.length) {
  95. return this.renderEmpty();
  96. }
  97. return this.renderResults();
  98. }
  99. renderBody() {
  100. const {organization} = this.props;
  101. const {location} = this.props;
  102. const {pathname, search, query} = location;
  103. const {status} = getQuery(search);
  104. const {reportListPageLinks} = this.state;
  105. const unresolvedQuery = omit(query, 'status');
  106. const allIssuesQuery = {...query, status: ''};
  107. return (
  108. <PageFiltersContainer>
  109. <NoProjectMessage organization={organization}>
  110. <Layout.Header>
  111. <Layout.HeaderContent>
  112. <Layout.Title>
  113. {t('User Feedback')}
  114. <PageHeadingQuestionTooltip
  115. docsUrl="https://docs.sentry.io/product/user-feedback/"
  116. title={t(
  117. 'Feedback submitted by users who experienced an error while using your application, including their name, email address, and any additional comments.'
  118. )}
  119. />
  120. </Layout.Title>
  121. </Layout.HeaderContent>
  122. </Layout.Header>
  123. <Layout.Body data-test-id="user-feedback">
  124. <Layout.Main fullWidth>
  125. <Filters>
  126. <PageFilterBar>
  127. <ProjectPageFilter />
  128. <EnvironmentPageFilter />
  129. <DatePageFilter alignDropdown="right" />
  130. </PageFilterBar>
  131. <ButtonBar active={!Array.isArray(status) ? status || '' : ''} merged>
  132. <Button barId="unresolved" to={{pathname, query: unresolvedQuery}}>
  133. {t('Unresolved')}
  134. </Button>
  135. <Button barId="" to={{pathname, query: allIssuesQuery}}>
  136. {t('All Issues')}
  137. </Button>
  138. </ButtonBar>
  139. </Filters>
  140. {this.renderStreamBody()}
  141. <Pagination pageLinks={reportListPageLinks} />
  142. </Layout.Main>
  143. </Layout.Body>
  144. </NoProjectMessage>
  145. </PageFiltersContainer>
  146. );
  147. }
  148. }
  149. export default withOrganization(withProfiler(OrganizationUserFeedback));
  150. const Filters = styled('div')`
  151. display: grid;
  152. grid-template-columns: minmax(0, max-content) max-content;
  153. justify-content: start;
  154. gap: ${space(2)};
  155. margin-bottom: ${space(2)};
  156. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  157. grid-template-columns: minmax(0, 1fr) max-content;
  158. }
  159. @media (max-width: ${p => p.theme.breakpoints.small}) {
  160. grid-template-columns: minmax(0, 1fr);
  161. }
  162. `;
  163. const StyledEventUserFeedback = styled(EventUserFeedback)`
  164. margin: ${space(2)} 0 0;
  165. `;