container.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {Fragment, useEffect, useState} from 'react';
  2. import NoProjectMessage from 'sentry/components/noProjectMessage';
  3. import GlobalSelectionHeader from 'sentry/components/organizations/globalSelectionHeader';
  4. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  5. import {t} from 'sentry/locale';
  6. import GroupStore from 'sentry/stores/groupStore';
  7. import {Organization, Project} from 'sentry/types';
  8. import withOrganization from 'sentry/utils/withOrganization';
  9. import SampleEventAlert from 'sentry/views/organizationGroupDetails/sampleEventAlert';
  10. type Props = {
  11. organization: Organization;
  12. projects: Project[];
  13. children: React.ReactChildren;
  14. };
  15. function IssueListContainer({organization, children}: Props) {
  16. const [showSampleEventBanner, setShowSampleEventBanner] = useState(false);
  17. useEffect(() => {
  18. const unlistener = GroupStore.listen(
  19. () => setShowSampleEventBanner(GroupStore.getAllItemIds().length === 1),
  20. undefined
  21. );
  22. return () => unlistener();
  23. }, []);
  24. return (
  25. <SentryDocumentTitle title={t('Issues')} orgSlug={organization.slug}>
  26. <Fragment>
  27. {showSampleEventBanner && <SampleEventAlert />}
  28. <GlobalSelectionHeader>
  29. <NoProjectMessage organization={organization}>{children}</NoProjectMessage>
  30. </GlobalSelectionHeader>
  31. </Fragment>
  32. </SentryDocumentTitle>
  33. );
  34. }
  35. export default withOrganization(IssueListContainer);