Browse Source

ref(js): Remove useApiRequests from releasesPromo (#69743)

Tested and verified this works the same
Evan Purkhiser 10 months ago
parent
commit
9676c664dd
1 changed files with 19 additions and 18 deletions
  1. 19 18
      static/app/views/releases/list/releasesPromo.tsx

+ 19 - 18
static/app/views/releases/list/releasesPromo.tsx

@@ -13,6 +13,7 @@ import {CodeSnippet} from 'sentry/components/codeSnippet';
 import DropdownAutoComplete from 'sentry/components/dropdownAutoComplete';
 import type {Item} from 'sentry/components/dropdownAutoComplete/types';
 import Link from 'sentry/components/links/link';
+import LoadingIndicator from 'sentry/components/loadingIndicator';
 import type {TourStep} from 'sentry/components/modals/featureTourModal';
 import {TourImage, TourText} from 'sentry/components/modals/featureTourModal';
 import Panel from 'sentry/components/panels/panel';
@@ -28,8 +29,8 @@ import type {
   SentryApp,
 } from 'sentry/types';
 import {trackAnalytics} from 'sentry/utils/analytics';
+import {useApiQuery} from 'sentry/utils/queryClient';
 import useApi from 'sentry/utils/useApi';
-import useApiRequests from 'sentry/utils/useApiRequests';
 
 const releasesSetupUrl = 'https://docs.sentry.io/product/releases/';
 
@@ -94,28 +95,24 @@ type Props = {
   project: Project;
 };
 
-const ReleasesPromo = ({organization, project}: Props) => {
-  const {data, renderComponent, isLoading} = useApiRequests<{
-    internalIntegrations: SentryApp[];
-  }>({
-    endpoints: [
-      [
-        'internalIntegrations',
-        `/organizations/${organization.slug}/sentry-apps/`,
-        {query: {status: 'internal'}},
-      ],
-    ],
-  });
+function ReleasesPromo({organization, project}: Props) {
+  const {data, isLoading} = useApiQuery<SentryApp[]>(
+    [`/organizations/${organization.slug}/sentry-apps/`, {query: {status: 'internal'}}],
+    {
+      staleTime: 0,
+    }
+  );
+
   const api = useApi();
   const [token, setToken] = useState<string | null>(null);
   const [integrations, setIntegrations] = useState<SentryApp[]>([]);
   const [selectedItem, selectItem] = useState<Pick<Item, 'label' | 'value'> | null>(null);
 
   useEffect(() => {
-    if (!isLoading && data.internalIntegrations) {
-      setIntegrations(data.internalIntegrations);
+    if (!isLoading && data) {
+      setIntegrations(data);
     }
-  }, [isLoading, data.internalIntegrations]);
+  }, [isLoading, data]);
   useEffect(() => {
     trackAnalytics('releases.quickstart_viewed', {
       organization,
@@ -200,7 +197,11 @@ sentry-cli releases finalize "$VERSION"`,
     [token, selectedItem, organization.slug, project.slug]
   );
 
-  return renderComponent(
+  if (isLoading) {
+    return <LoadingIndicator />;
+  }
+
+  return (
     <Panel>
       <Container>
         <ContainerHeader>
@@ -311,7 +312,7 @@ sentry-cli releases finalize "$VERSION"`,
       </Container>
     </Panel>
   );
-};
+}
 
 const Container = styled('div')`
   padding: ${space(3)};