feedbackListPage.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import {Fragment} from 'react';
  2. import type {RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import ErrorBoundary from 'sentry/components/errorBoundary';
  5. import FeedbackFilters from 'sentry/components/feedback/feedbackFilters';
  6. import FeedbackItemLoader from 'sentry/components/feedback/feedbackItem/feedbackItemLoader';
  7. import FeedbackWidgetBanner from 'sentry/components/feedback/feedbackOnboarding/feedbackWidgetBanner';
  8. import FeedbackSearch from 'sentry/components/feedback/feedbackSearch';
  9. import FeedbackSetupPanel from 'sentry/components/feedback/feedbackSetupPanel';
  10. import FeedbackWhatsNewBanner from 'sentry/components/feedback/feedbackWhatsNewBanner';
  11. import FeedbackList from 'sentry/components/feedback/list/feedbackList';
  12. import useCurrentFeedbackId from 'sentry/components/feedback/useCurrentFeedbackId';
  13. import useHaveSelectedProjectsSetupFeedback, {
  14. useHaveSelectedProjectsSetupNewFeedback,
  15. } from 'sentry/components/feedback/useFeedbackOnboarding';
  16. import {FeedbackQueryKeys} from 'sentry/components/feedback/useFeedbackQueryKeys';
  17. import useRedirectToFeedbackFromEvent from 'sentry/components/feedback/useRedirectToFeedbackFromEvent';
  18. import FullViewport from 'sentry/components/layouts/fullViewport';
  19. import * as Layout from 'sentry/components/layouts/thirds';
  20. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  21. import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip';
  22. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  23. import {feedbackWidgetPlatforms} from 'sentry/data/platformCategories';
  24. import {t} from 'sentry/locale';
  25. import {space} from 'sentry/styles/space';
  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. <FeedbackSearch style={{gridArea: 'search'}} />
  81. <Container style={{gridArea: 'details'}}>
  82. <FeedbackItemLoader />
  83. </Container>
  84. </Fragment>
  85. ) : (
  86. <SetupContainer>
  87. <FeedbackSetupPanel />
  88. </SetupContainer>
  89. )}
  90. </LayoutGrid>
  91. </ErrorBoundary>
  92. </PageFiltersContainer>
  93. </FeedbackQueryKeys>
  94. </FullViewport>
  95. </SentryDocumentTitle>
  96. );
  97. }
  98. const LayoutGrid = styled('div')`
  99. background: ${p => p.theme.background};
  100. overflow: hidden;
  101. flex-grow: 1;
  102. display: grid;
  103. gap: ${space(2)};
  104. place-items: stretch;
  105. grid-template-rows: max-content 1fr;
  106. grid-template-areas:
  107. 'filters search'
  108. 'list details';
  109. &[data-banner='true'] {
  110. grid-template-rows: max-content max-content 1fr;
  111. grid-template-areas:
  112. 'banner banner'
  113. 'filters search'
  114. 'list details';
  115. }
  116. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  117. padding: ${space(2)};
  118. grid-template-columns: 1fr;
  119. grid-template-areas:
  120. 'filters'
  121. 'search'
  122. 'list'
  123. 'details';
  124. &[data-banner='true'] {
  125. grid-template-areas:
  126. 'banner'
  127. 'filters'
  128. 'search'
  129. 'list'
  130. 'details';
  131. }
  132. }
  133. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  134. padding: ${space(2)};
  135. grid-template-columns: minmax(1fr, 195px) 1fr;
  136. }
  137. @media (min-width: ${p => p.theme.breakpoints.large}) {
  138. padding: ${space(2)} ${space(4)} ${space(2)} ${space(4)};
  139. grid-template-columns: 390px 1fr;
  140. }
  141. @media (min-width: ${p => p.theme.breakpoints.large}) {
  142. grid-template-columns: minmax(390px, 1fr) 2fr;
  143. }
  144. `;
  145. const Container = styled(FluidHeight)`
  146. border: 1px solid ${p => p.theme.border};
  147. border-radius: ${p => p.theme.borderRadius};
  148. `;
  149. const SetupContainer = styled('div')`
  150. overflow: hidden;
  151. grid-column: 1 / -1;
  152. `;