organizationStatsWrapper.tsx 639 B

123456789101112131415161718192021
  1. import {useRedirectNavV2Routes} from 'sentry/components/nav/useRedirectNavV2Routes';
  2. import Redirect from 'sentry/components/redirect';
  3. type OrganizationStatsWrapperProps = {
  4. children: React.ReactNode;
  5. };
  6. // Wraps all routes under /stats/ to redirect to /settings/stats/
  7. // Can be removed once navigation-sidebar-v2 is fully launched
  8. export function OrganizationStatsWrapper({children}: OrganizationStatsWrapperProps) {
  9. const redirectPath = useRedirectNavV2Routes({
  10. oldPathPrefix: '/stats/',
  11. newPathPrefix: '/settings/stats/',
  12. });
  13. if (redirectPath) {
  14. return <Redirect to={redirectPath} />;
  15. }
  16. return children;
  17. }