index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Feature from 'sentry/components/acl/feature';
  2. import {Alert} from 'sentry/components/core/alert';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import {useRedirectNavV2Routes} from 'sentry/components/nav/useRedirectNavV2Routes';
  5. import NoProjectMessage from 'sentry/components/noProjectMessage';
  6. import Redirect from 'sentry/components/redirect';
  7. import {t} from 'sentry/locale';
  8. import type {Organization} from 'sentry/types/organization';
  9. import withOrganization from 'sentry/utils/withOrganization';
  10. type Props = {
  11. children: React.ReactNode;
  12. organization: Organization;
  13. };
  14. function DiscoverContainer({organization, children}: Props) {
  15. const redirectPath = useRedirectNavV2Routes({
  16. oldPathPrefix: '/discover/',
  17. newPathPrefix: '/explore/discover/',
  18. });
  19. if (redirectPath) {
  20. return <Redirect to={redirectPath} />;
  21. }
  22. function renderNoAccess() {
  23. return (
  24. <Layout.Page withPadding>
  25. <Alert.Container>
  26. <Alert type="warning">{t("You don't have access to this feature")}</Alert>
  27. </Alert.Container>
  28. </Layout.Page>
  29. );
  30. }
  31. return (
  32. <Feature
  33. features="discover-basic"
  34. organization={organization}
  35. hookName="feature-disabled:discover2-page"
  36. renderDisabled={renderNoAccess}
  37. >
  38. <NoProjectMessage organization={organization}>{children}</NoProjectMessage>
  39. </Feature>
  40. );
  41. }
  42. export default withOrganization(DiscoverContainer);