Browse Source

fix(relocation): Working relocation page when organization is set to null (#63633)

I believe this [PR](https://github.com/getsentry/sentry/pull/63380)
broke the relocation page, since it is intended to be used when a user
does not have any organizations created, so no organization context.
This sets the `allowNull` option for `useOrganization`, so that the
feature component can be used for pages when an organization context is
not available.
Hubert Deng 1 year ago
parent
commit
152269bf72

+ 1 - 0
static/app/components/acl/feature.tsx

@@ -44,6 +44,7 @@ type Props = {
    * function.
    */
   hookName?: keyof FeatureDisabledHooks;
+  organizationAllowNull?: undefined | true;
   project?: Project;
   /**
    * Custom renderer function for when the feature is not enabled.

+ 2 - 1
static/app/utils/withOrganization.tsx

@@ -5,6 +5,7 @@ import useOrganization from './useOrganization';
 
 type InjectedOrganizationProps = {
   organization?: Organization;
+  organizationAllowNull?: undefined | true;
 };
 
 function withOrganization<P extends InjectedOrganizationProps>(
@@ -14,7 +15,7 @@ function withOrganization<P extends InjectedOrganizationProps>(
     Partial<InjectedOrganizationProps>;
 
   function Wrapper(props: Props) {
-    const organization = useOrganization();
+    const organization = useOrganization({allowNull: props.organizationAllowNull});
 
     const allProps = {organization, ...props} as P;
 

+ 1 - 0
static/app/views/relocation/index.tsx

@@ -13,6 +13,7 @@ export default function RelocationOnboardingContainer(props: Props) {
   return (
     <Feature
       features={['relocation:enabled']}
+      organizationAllowNull
       renderDisabled={() => (
         <Layout.Page withPadding>
           <Alert type="warning">{t("You don't have access to this feature")}</Alert>