feedbackListPage.tsx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import ErrorBoundary from 'sentry/components/errorBoundary';
  4. import FeedbackFilters from 'sentry/components/feedback/feedbackFilters';
  5. import FeedbackItemLoader from 'sentry/components/feedback/feedbackItem/feedbackItemLoader';
  6. import FeedbackWidgetBanner from 'sentry/components/feedback/feedbackOnboarding/feedbackWidgetBanner';
  7. import FeedbackSearch from 'sentry/components/feedback/feedbackSearch';
  8. import FeedbackSetupPanel from 'sentry/components/feedback/feedbackSetupPanel';
  9. import FeedbackWhatsNewBanner from 'sentry/components/feedback/feedbackWhatsNewBanner';
  10. import FeedbackList from 'sentry/components/feedback/list/feedbackList';
  11. import useCurrentFeedbackId from 'sentry/components/feedback/useCurrentFeedbackId';
  12. import useHaveSelectedProjectsSetupFeedback, {
  13. useHaveSelectedProjectsSetupNewFeedback,
  14. } from 'sentry/components/feedback/useFeedbackOnboarding';
  15. import {FeedbackQueryKeys} from 'sentry/components/feedback/useFeedbackQueryKeys';
  16. import useRedirectToFeedbackFromEvent from 'sentry/components/feedback/useRedirectToFeedbackFromEvent';
  17. import FullViewport from 'sentry/components/layouts/fullViewport';
  18. import * as Layout from 'sentry/components/layouts/thirds';
  19. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  20. import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip';
  21. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  22. import {feedbackWidgetPlatforms} from 'sentry/data/platformCategories';
  23. import {t} from 'sentry/locale';
  24. import {space} from 'sentry/styles/space';
  25. import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
  26. import useOrganization from 'sentry/utils/useOrganization';
  27. import usePageFilters from 'sentry/utils/usePageFilters';
  28. import useProjects from 'sentry/utils/useProjects';
  29. import FluidHeight from 'sentry/views/replays/detail/layout/fluidHeight';
  30. interface Props extends RouteComponentProps<{}, {}, {}> {}
  31. export default function FeedbackListPage({}: Props) {
  32. const organization = useOrganization();
  33. const {hasSetupOneFeedback} = useHaveSelectedProjectsSetupFeedback();
  34. const {hasSetupNewFeedback} = useHaveSelectedProjectsSetupNewFeedback();
  35. const showWhatsNewBanner = hasSetupOneFeedback && !hasSetupNewFeedback;
  36. useRedirectToFeedbackFromEvent();
  37. const feedbackId = useCurrentFeedbackId();
  38. const hasSlug = Boolean(feedbackId);
  39. const pageFilters = usePageFilters();
  40. const projects = useProjects();
  41. const selectedProjects = projects.projects.filter(p =>
  42. pageFilters.selection.projects.includes(Number(p.id))
  43. );
  44. // one selected project is widget eligible
  45. const oneIsWidgetEligible = selectedProjects.some(p =>
  46. feedbackWidgetPlatforms.includes(p.platform!)
  47. );
  48. const showWidgetBanner = showWhatsNewBanner && oneIsWidgetEligible;
  49. return (
  50. <SentryDocumentTitle title={t('User Feedback')} orgSlug={organization.slug}>
  51. <FullViewport>
  52. <FeedbackQueryKeys organization={organization}>
  53. <Layout.Header>
  54. <Layout.HeaderContent>
  55. <Layout.Title>
  56. {t('User Feedback')}
  57. <PageHeadingQuestionTooltip
  58. title={t(
  59. 'The User Feedback Widget allows users to submit feedback quickly and easily any time they encounter something that isn’t working as expected.'
  60. )}
  61. docsUrl="https://docs.sentry.io/product/user-feedback/"
  62. />
  63. </Layout.Title>
  64. </Layout.HeaderContent>
  65. </Layout.Header>
  66. <PageFiltersContainer>
  67. <ErrorBoundary>
  68. <LayoutGrid data-banner={showWhatsNewBanner}>
  69. {showWidgetBanner ? (
  70. <FeedbackWidgetBanner style={{gridArea: 'banner'}} />
  71. ) : showWhatsNewBanner ? (
  72. <FeedbackWhatsNewBanner style={{gridArea: 'banner'}} />
  73. ) : null}
  74. <FeedbackFilters style={{gridArea: 'filters'}} />
  75. {hasSetupOneFeedback || hasSlug ? (
  76. <Fragment>
  77. <Container style={{gridArea: 'list'}}>
  78. <FeedbackList />
  79. </Container>
  80. <SearchContainer>
  81. <FeedbackSearch />
  82. </SearchContainer>
  83. <Container style={{gridArea: 'details'}}>
  84. <FeedbackItemLoader />
  85. </Container>
  86. </Fragment>
  87. ) : (
  88. <SetupContainer>
  89. <FeedbackSetupPanel />
  90. </SetupContainer>
  91. )}
  92. </LayoutGrid>
  93. </ErrorBoundary>
  94. </PageFiltersContainer>
  95. </FeedbackQueryKeys>
  96. </FullViewport>
  97. </SentryDocumentTitle>
  98. );
  99. }
  100. const LayoutGrid = styled('div')`
  101. background: ${p => p.theme.background};
  102. overflow: hidden;
  103. flex-grow: 1;
  104. display: grid;
  105. gap: ${space(2)};
  106. place-items: stretch;
  107. grid-template-rows: max-content 1fr;
  108. grid-template-areas:
  109. 'filters search'
  110. 'list details';
  111. &[data-banner='true'] {
  112. grid-template-rows: max-content max-content 1fr;
  113. grid-template-areas:
  114. 'banner banner'
  115. 'filters search'
  116. 'list details';
  117. }
  118. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  119. padding: ${space(2)};
  120. grid-template-columns: 1fr;
  121. grid-template-areas:
  122. 'filters'
  123. 'search'
  124. 'list'
  125. 'details';
  126. &[data-banner='true'] {
  127. grid-template-areas:
  128. 'banner'
  129. 'filters'
  130. 'search'
  131. 'list'
  132. 'details';
  133. }
  134. }
  135. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  136. padding: ${space(2)};
  137. grid-template-columns: minmax(1fr, 195px) 1fr;
  138. }
  139. @media (min-width: ${p => p.theme.breakpoints.large}) {
  140. padding: ${space(2)} ${space(4)} ${space(2)} ${space(4)};
  141. grid-template-columns: 390px 1fr;
  142. }
  143. @media (min-width: ${p => p.theme.breakpoints.large}) {
  144. grid-template-columns: minmax(390px, 1fr) 2fr;
  145. }
  146. `;
  147. const Container = styled(FluidHeight)`
  148. border: 1px solid ${p => p.theme.border};
  149. border-radius: ${p => p.theme.borderRadius};
  150. `;
  151. const SetupContainer = styled('div')`
  152. overflow: hidden;
  153. grid-column: 1 / -1;
  154. `;
  155. const SearchContainer = styled('div')`
  156. flex-grow: 1;
  157. min-width: 0;
  158. `;