feedbackListPage.tsx 6.0 KB

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