index.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 ExternalLink from 'sentry/components/links/externalLink';
  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 PageHeading from 'sentry/components/pageHeading';
  17. import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip';
  18. import Pagination from 'sentry/components/pagination';
  19. import {Panel} from 'sentry/components/panels';
  20. import ProjectPageFilter from 'sentry/components/projectPageFilter';
  21. import {t, tct} from 'sentry/locale';
  22. import {PageContent} from 'sentry/styles/organization';
  23. import space from 'sentry/styles/space';
  24. import {Organization, UserReport} from 'sentry/types';
  25. import withOrganization from 'sentry/utils/withOrganization';
  26. import AsyncView from 'sentry/views/asyncView';
  27. import {UserFeedbackEmpty} from './userFeedbackEmpty';
  28. import {getQuery} from './utils';
  29. type State = AsyncView['state'] & {
  30. reportList: UserReport[];
  31. };
  32. type Props = RouteComponentProps<{orgId: string}, {}> & {
  33. organization: Organization;
  34. };
  35. class OrganizationUserFeedback extends AsyncView<Props, State> {
  36. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  37. const {
  38. organization,
  39. location: {search},
  40. } = this.props;
  41. return [
  42. [
  43. 'reportList',
  44. `/organizations/${organization.slug}/user-feedback/`,
  45. {
  46. query: getQuery(search),
  47. },
  48. ],
  49. ];
  50. }
  51. getTitle() {
  52. return `${t('User Feedback')} - ${this.props.organization.slug}`;
  53. }
  54. get projectIds() {
  55. const {project} = this.props.location.query;
  56. return Array.isArray(project)
  57. ? project
  58. : typeof project === 'string'
  59. ? [project]
  60. : [];
  61. }
  62. renderResults() {
  63. const {orgId} = this.props.params;
  64. return (
  65. <Panel className="issue-list" data-test-id="user-feedback-list">
  66. {this.state.reportList.map(item => {
  67. const issue = item.issue;
  68. return (
  69. <CompactIssue key={item.id} id={issue.id} data={issue} eventId={item.eventID}>
  70. <StyledEventUserFeedback report={item} orgId={orgId} issueId={issue.id} />
  71. </CompactIssue>
  72. );
  73. })}
  74. </Panel>
  75. );
  76. }
  77. renderEmpty() {
  78. return <UserFeedbackEmpty projectIds={this.projectIds} />;
  79. }
  80. renderLoading() {
  81. return this.renderBody();
  82. }
  83. renderStreamBody() {
  84. const {loading, reportList} = this.state;
  85. if (loading) {
  86. return (
  87. <Panel>
  88. <LoadingIndicator />
  89. </Panel>
  90. );
  91. }
  92. if (!reportList.length) {
  93. return this.renderEmpty();
  94. }
  95. return this.renderResults();
  96. }
  97. renderBody() {
  98. const {organization} = this.props;
  99. const {location} = this.props;
  100. const {pathname, search, query} = location;
  101. const {status} = getQuery(search);
  102. const {reportListPageLinks} = this.state;
  103. const unresolvedQuery = omit(query, 'status');
  104. const allIssuesQuery = {...query, status: ''};
  105. return (
  106. <PageFiltersContainer>
  107. <PageContent>
  108. <NoProjectMessage organization={organization}>
  109. <div data-test-id="user-feedback">
  110. <Header>
  111. <PageHeading>
  112. {t('User Feedback')}
  113. <PageHeadingQuestionTooltip
  114. title={tct(
  115. 'Feedback submitted by users who experienced an error while using your application, including their name, email address, and any additional comments. [link: Read the docs].',
  116. {
  117. link: (
  118. <ExternalLink href="https://docs.sentry.io/product/user-feedback/" />
  119. ),
  120. }
  121. )}
  122. />
  123. </PageHeading>
  124. </Header>
  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. </div>
  143. </NoProjectMessage>
  144. </PageContent>
  145. </PageFiltersContainer>
  146. );
  147. }
  148. }
  149. export default withOrganization(withProfiler(OrganizationUserFeedback));
  150. const Header = styled('div')`
  151. display: flex;
  152. align-items: center;
  153. justify-content: space-between;
  154. margin-bottom: ${space(2)};
  155. `;
  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 0;
  171. `;