Justin Rhee 3 лет назад
Родитель
Сommit
0445f8e1f7

+ 10 - 7
dashboard/src/main/home/app-dashboard/new-app-flow/GithubActionModal.tsx

@@ -1,21 +1,22 @@
+import { RouteComponentProps, withRouter } from "react-router";
+import styled from "styled-components";
+import React from "react";
+
 import Modal from "components/porter/Modal";
-import React, { useContext } from "react";
 import Text from "components/porter/Text";
 import Spacer from "components/porter/Spacer";
 import ExpandableSection from "components/porter/ExpandableSection";
 import Fieldset from "components/porter/Fieldset";
-import styled from "styled-components";
 import Button from "components/porter/Button";
 import Select from "components/porter/Select";
 import api from "shared/api";
-import { CopyBlock } from "react-code-blocks";
 import { getGithubAction } from "./utils";
 import AceEditor from "react-ace";
 import YamlEditor from "components/YamlEditor";
 import Error from "components/porter/Error";
 
 
-interface GithubActionModalProps {
+type Props = RouteComponentProps & {
   closeModal: () => void;
   githubAppInstallationID?: number;
   githubRepoOwner?: string;
@@ -30,7 +31,7 @@ interface GithubActionModalProps {
 
 type Choice = "open_pr" | "copy";
 
-const GithubActionModal: React.FC<GithubActionModalProps> = ({
+const GithubActionModal: React.FC<Props> = ({
   closeModal,
   githubAppInstallationID,
   githubRepoOwner,
@@ -41,6 +42,7 @@ const GithubActionModal: React.FC<GithubActionModalProps> = ({
   clusterId,
   deployPorterApp,
   deploymentError,
+  ...props
 }) => {
   const [choice, setChoice] = React.useState<Choice>("open_pr");
   const [loading, setLoading] = React.useState<boolean>(false);
@@ -71,7 +73,8 @@ const GithubActionModal: React.FC<GithubActionModalProps> = ({
             }
           );
           if (res?.data?.url) {
-            window.open(res.data.url, "_blank", "noreferrer")
+            window.open(res.data.url, "_blank", "noreferrer");
+            props.history.push(`/apps/${stackName}`);
           }
         }
       } catch (error) {
@@ -140,7 +143,7 @@ const GithubActionModal: React.FC<GithubActionModalProps> = ({
   )
 }
 
-export default GithubActionModal;
+export default withRouter(GithubActionModal);
 
 const Tab = styled.span`
   margin-left: 20px;

+ 5 - 5
dashboard/src/main/home/app-dashboard/new-app-flow/NewAppFlow.tsx

@@ -1,5 +1,6 @@
 import React, { useEffect, useState, useContext, useMemo } from "react";
 import styled from "styled-components";
+import { RouteComponentProps, withRouter } from "react-router";
 import _ from "lodash";
 import yaml from "js-yaml";
 
@@ -19,8 +20,6 @@ import VerticalSteps from "components/porter/VerticalSteps";
 import PorterFormWrapper from "components/porter-form/PorterFormWrapper";
 import Placeholder from "components/Placeholder";
 import Button from "components/porter/Button";
-import { generateSlug } from "random-word-slugs";
-import { RouteComponentProps, withRouter } from "react-router";
 import SourceSelector, { SourceType } from "./SourceSelector";
 import SourceSettings from "./SourceSettings";
 import Services from "./Services";
@@ -227,7 +226,7 @@ const NewAppFlow: React.FC<Props> = ({ ...props }) => {
           git_branch: branch,
           build_context: folderPath,
           builder: (buildConfig as any)?.builder,
-          buildpacks: (buildConfig as any)?.buildpacks.join(",") ?? "",
+          buildpacks: (buildConfig as any)?.buildpacks?.join(",") ?? "",
           dockerfile: dockerfilePath,
           image_repo_uri: imageUrl,
         },
@@ -237,7 +236,6 @@ const NewAppFlow: React.FC<Props> = ({ ...props }) => {
         }
       );
 
-      // deploy dummy chart
       await api.updatePorterStack(
         "<token>",
         {
@@ -250,7 +248,9 @@ const NewAppFlow: React.FC<Props> = ({ ...props }) => {
           project_id: currentProject.id,
         }
       )
-
+      if (!actionConfig?.git_repo) {
+        props.history.push(`/apps/${formState.applicationName}`);
+      }
       return true;
     } catch (err) {
       // TODO: better error handling