Browse Source

Fixed 404 error setting the redirect modal

jnfrati 4 years ago
parent
commit
5dbea4fe0e

+ 1 - 0
dashboard/src/main/home/Home.tsx

@@ -261,6 +261,7 @@ class Home extends Component<PropsType, StateType> {
     ) {
       this.context.setCurrentModal("RedirectToOnboardingModal");
     }
+
     if (prevProps.currentProject?.id !== this.props.currentProject?.id) {
       this.checkOnboarding();
       this.checkIfProjectHasBilling(this?.context?.currentProject?.id)

+ 9 - 7
dashboard/src/main/home/ModalHandler.tsx

@@ -14,6 +14,7 @@ import RedirectToOnboardingModal from "./modals/RedirectToOnboardingModal";
 
 import UsageWarningModal from "./modals/UsageWarningModal";
 import api from "shared/api";
+import { AxiosError } from "axios";
 
 const ModalHandler: React.FC<{
   setRefreshClusters: (x: boolean) => void;
@@ -43,12 +44,6 @@ const ModalHandler: React.FC<{
       const project_id = currentProject?.id;
       const res = await api.getOnboardingState("<token>", {}, { project_id });
 
-      if (res.status === 404) {
-        return {
-          finished: true,
-        };
-      }
-
       if (res?.data && res?.data.current_step !== "clean_up") {
         return {
           finished: false,
@@ -58,7 +53,14 @@ const ModalHandler: React.FC<{
           finished: true,
         };
       }
-    } catch (error) {}
+    } catch (error) {
+      const err: AxiosError = error;
+      if (err.response.status === 404) {
+        return {
+          finished: true,
+        };
+      }
+    }
   };
 
   useEffect(() => {

+ 17 - 18
dashboard/src/main/home/onboarding/steps/ConnectSource.tsx

@@ -92,29 +92,28 @@ const ConnectSource: React.FC<{
         <>
           <Helper>Porter currently has access to:</Helper>
           <List>
-            {
-              accountData?.accounts.length > 0 ? (
-                accountData?.accounts.map((name, i) => {
-                  return (
-                    <Row
-                      key={i}
-                      isLastItem={i === accountData.accounts.length - 1}
-                    >
-                      <i className="material-icons">bookmark</i>
-                      {name}
-                    </Row>
-                  );
-                })
-              ) : (
-                <Placeholder>No repositories found.</Placeholder>
-              )
-            }
+            {accountData?.accounts.length > 0 ? (
+              accountData?.accounts.map((name, i) => {
+                return (
+                  <Row
+                    key={i}
+                    isLastItem={i === accountData.accounts.length - 1}
+                  >
+                    <i className="material-icons">bookmark</i>
+                    {name}
+                  </Row>
+                );
+              })
+            ) : (
+              <Placeholder>No repositories found.</Placeholder>
+            )}
           </List>
           <Helper>
             Don't see the right repos?{" "}
             <A href={"/api/integrations/github-app/install"}>
               Install Porter in more repositories
-            </A>.
+            </A>
+            .
           </Helper>
           <NextStep
             text="Continue"