feedbackListPage.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 OldFeedbackButton from 'sentry/components/feedback/oldFeedbackButton';
  13. import useCurrentFeedbackId from 'sentry/components/feedback/useCurrentFeedbackId';
  14. import useHaveSelectedProjectsSetupFeedback, {
  15. useHaveSelectedProjectsSetupNewFeedback,
  16. } from 'sentry/components/feedback/useFeedbackOnboarding';
  17. import {FeedbackQueryKeys} from 'sentry/components/feedback/useFeedbackQueryKeys';
  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. const feedbackSlug = useCurrentFeedbackId();
  37. const hasSlug = Boolean(feedbackSlug);
  38. const pageFilters = usePageFilters();
  39. const projects = useProjects();
  40. const selectedProjects = projects.projects.filter(p =>
  41. pageFilters.selection.projects.includes(Number(p.id))
  42. );
  43. // one selected project is widget eligible
  44. const oneIsWidgetEligible = selectedProjects.some(p =>
  45. feedbackWidgetPlatforms.includes(p.platform!)
  46. );
  47. const showWidgetBanner = showWhatsNewBanner && oneIsWidgetEligible;
  48. return (
  49. <SentryDocumentTitle title={t('User Feedback')} orgSlug={organization.slug}>
  50. <FullViewport>
  51. <FeedbackQueryKeys organization={organization}>
  52. <Layout.Header>
  53. <Layout.HeaderContent>
  54. <Layout.Title>
  55. {t('User Feedback')}
  56. <PageHeadingQuestionTooltip
  57. title={t(
  58. 'The User Feedback Widget allows users to submit feedback quickly and easily any time they encounter something that isn’t working as expected.'
  59. )}
  60. docsUrl="https://docs.sentry.io/product/user-feedback/"
  61. />
  62. </Layout.Title>
  63. </Layout.HeaderContent>
  64. <Layout.HeaderActions>
  65. <OldFeedbackButton />
  66. </Layout.HeaderActions>
  67. </Layout.Header>
  68. <PageFiltersContainer>
  69. <ErrorBoundary>
  70. <LayoutGrid data-banner={showWhatsNewBanner}>
  71. {showWidgetBanner ? (
  72. <FeedbackWidgetBanner style={{gridArea: 'banner'}} />
  73. ) : showWhatsNewBanner ? (
  74. <FeedbackWhatsNewBanner style={{gridArea: 'banner'}} />
  75. ) : null}
  76. <FeedbackFilters style={{gridArea: 'filters'}} />
  77. {hasSetupOneFeedback || hasSlug ? (
  78. <Fragment>
  79. <Container style={{gridArea: 'list'}}>
  80. <FeedbackList />
  81. </Container>
  82. <FeedbackSearch style={{gridArea: 'search'}} />
  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. `;