index.tsx 6.0 KB

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