Просмотр исходного кода

fix(ui) Fix error in account settings for new users (#45638)

When a user is new and hasn't completed their membership requirements
(setup 2fa) they will not be part of any organizations but will need to
be able to view account settings.

Fixes #45577
Fixes JAVASCRIPT-2FHE
Mark Story 2 лет назад
Родитель
Сommit
7c650365f4
1 измененных файлов с 16 добавлено и 10 удалено
  1. 16 10
      static/app/views/organizationDetails/body.tsx

+ 16 - 10
static/app/views/organizationDetails/body.tsx

@@ -12,12 +12,17 @@ import useApi from 'sentry/utils/useApi';
 import {useRouteContext} from 'sentry/utils/useRouteContext';
 import withOrganization from 'sentry/utils/withOrganization';
 
-type Props = {
+type OrganizationProps = {
   organization: Organization;
+};
+
+type BodyProps = {
   children?: React.ReactNode;
+  // Organization can be null in account settings
+  organization?: Organization;
 };
 
-function DeletionInProgress({organization}: Props) {
+function DeletionInProgress({organization}: OrganizationProps) {
   return (
     <Layout.Body>
       <Layout.Main>
@@ -34,7 +39,7 @@ function DeletionInProgress({organization}: Props) {
   );
 }
 
-function DeletionPending({organization}: Props) {
+function DeletionPending({organization}: OrganizationProps) {
   const api = useApi();
   const [isRestoring, setIsRestoring] = useState(false);
 
@@ -99,34 +104,35 @@ function DeletionPending({organization}: Props) {
   );
 }
 
-function OrganizationDetailsBody({children, organization}: Props) {
+function OrganizationDetailsBody({children, organization}: BodyProps) {
   const status = organization?.status?.id;
   const routeContext = useRouteContext();
 
-  if (status === 'pending_deletion') {
+  if (organization && status === 'pending_deletion') {
     return <DeletionPending organization={organization} />;
   }
 
-  if (status === 'deletion_in_progress') {
+  if (organization && status === 'deletion_in_progress') {
     return <DeletionInProgress organization={organization} />;
   }
 
   const heartbeatFooter = !!organization?.features.includes(
     'onboarding-heartbeat-footer'
   );
+  const slug = organization?.slug;
 
   const gettingStartedRoutes = [
     `/getting-started/${routeContext.params.projectId}/${routeContext.params.platform}/`,
-    `/${organization.slug}/${routeContext.params.projectId}/getting-started/${routeContext.params.platform}/`,
+    `/${slug}/${routeContext.params.projectId}/getting-started/${routeContext.params.platform}/`,
   ];
 
   const onboardingRoutes = [
     `/onboarding/welcome/`,
     `/onboarding/setup-docs/`,
     `/onboarding/select-platform/`,
-    `/onboarding/${organization.slug}/welcome/`,
-    `/onboarding/${organization.slug}/setup-docs/`,
-    `/onboarding/${organization.slug}/select-platform/`,
+    `/onboarding/${slug}/welcome/`,
+    `/onboarding/${slug}/setup-docs/`,
+    `/onboarding/${slug}/select-platform/`,
   ];
 
   const showFooter = !heartbeatFooter