index.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import Feature from 'sentry/components/acl/feature';
  2. import {Alert} from 'sentry/components/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 type="warning">{t("You don't have access to this feature")}</Alert>
  26. </Layout.Page>
  27. );
  28. }
  29. return (
  30. <Feature
  31. features="discover-basic"
  32. organization={organization}
  33. hookName="feature-disabled:discover2-page"
  34. renderDisabled={renderNoAccess}
  35. >
  36. <NoProjectMessage organization={organization}>{children}</NoProjectMessage>
  37. </Feature>
  38. );
  39. }
  40. export default withOrganization(DiscoverContainer);