projectSettingsLayout.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {cloneElement, isValidElement} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import * as AppStoreConnectContext from 'sentry/components/projects/appStoreConnectContext';
  4. import {Organization} from 'sentry/types';
  5. import withOrganization from 'sentry/utils/withOrganization';
  6. import ProjectContext from 'sentry/views/projects/projectContext';
  7. import SettingsLayout from 'sentry/views/settings/components/settingsLayout';
  8. import ProjectSettingsNavigation from 'sentry/views/settings/project/projectSettingsNavigation';
  9. type Props = {
  10. children: React.ReactNode;
  11. organization: Organization;
  12. } & RouteComponentProps<{orgId: string; projectId: string}, {}>;
  13. function ProjectSettingsLayout({
  14. params,
  15. organization,
  16. children,
  17. routes,
  18. ...props
  19. }: Props) {
  20. const {orgId, projectId} = params;
  21. return (
  22. <ProjectContext orgId={orgId} projectId={projectId}>
  23. {({project}) => (
  24. <AppStoreConnectContext.Provider project={project} organization={organization}>
  25. <SettingsLayout
  26. params={params}
  27. routes={routes}
  28. {...props}
  29. renderNavigation={() => (
  30. <ProjectSettingsNavigation organization={organization} />
  31. )}
  32. >
  33. {children && isValidElement(children)
  34. ? cloneElement(children, {organization, project})
  35. : children}
  36. </SettingsLayout>
  37. </AppStoreConnectContext.Provider>
  38. )}
  39. </ProjectContext>
  40. );
  41. }
  42. export default withOrganization(ProjectSettingsLayout);