accountSettingsLayout.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {Component} from 'react';
  2. import {fetchOrganizationDetails} from 'sentry/actionCreators/organizations';
  3. import type {Client} from 'sentry/api';
  4. import type {Organization} from 'sentry/types/organization';
  5. import withApi from 'sentry/utils/withApi';
  6. import withLatestContext from 'sentry/utils/withLatestContext';
  7. import AccountSettingsNavigation from 'sentry/views/settings/account/accountSettingsNavigation';
  8. import SettingsLayout from 'sentry/views/settings/components/settingsLayout';
  9. type Props = React.ComponentProps<typeof SettingsLayout> & {
  10. api: Client;
  11. organization: Organization;
  12. };
  13. class AccountSettingsLayout extends Component<Props> {
  14. componentDidUpdate(prevProps: Props) {
  15. const {api, organization} = this.props;
  16. if (prevProps.organization === organization) {
  17. return;
  18. }
  19. // if there is no org in context, SidebarDropdown uses an org from `withLatestContext`
  20. // (which queries the org index endpoint instead of org details)
  21. // and does not have `access` info
  22. if (organization && typeof organization.access === 'undefined') {
  23. fetchOrganizationDetails(api, organization.slug, {
  24. setActive: true,
  25. loadProjects: true,
  26. });
  27. }
  28. }
  29. render() {
  30. const {organization} = this.props;
  31. return (
  32. <SettingsLayout
  33. {...this.props}
  34. renderNavigation={() => <AccountSettingsNavigation organization={organization} />}
  35. >
  36. {this.props.children}
  37. </SettingsLayout>
  38. );
  39. }
  40. }
  41. export default withLatestContext(withApi(AccountSettingsLayout));