From 8716f33cbebcfea48ae5731000690fdb7d6596d5 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Mon, 25 Sep 2023 10:26:16 -0400 Subject: [PATCH] do not prompt to delete workflow file if workflow file not found (#3637) --- .../app-dashboard/app-view/tabs/Settings.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dashboard/src/main/home/app-dashboard/app-view/tabs/Settings.tsx b/dashboard/src/main/home/app-dashboard/app-view/tabs/Settings.tsx index 48b075cb09..927943e11f 100644 --- a/dashboard/src/main/home/app-dashboard/app-view/tabs/Settings.tsx +++ b/dashboard/src/main/home/app-dashboard/app-view/tabs/Settings.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import styled from "styled-components"; import { useHistory } from "react-router"; @@ -20,7 +20,7 @@ const Settings: React.FC = () => { const { updateAppStep } = useAppAnalytics(); const [isDeleting, setIsDeleting] = useState(false); - const githubWorkflowFilename = `porter_stack_${porterApp.name}.yml`; + const [githubWorkflowFilename, setGithubWorkflowFilename] = useState(`porter_stack_${porterApp.name}.yml`); const workflowFileExists = useCallback(async () => { try { @@ -51,7 +51,18 @@ const Settings: React.FC = () => { } catch (err) { return false; } - }, [githubWorkflowFilename, porterApp.name, clusterId, projectId]); + }, [porterApp.name, clusterId, projectId]); + + useEffect(() => { + const checkWorkflowExists = async () => { + const exists = await workflowFileExists(); + if (!exists) { + setGithubWorkflowFilename(""); + } + }; + + checkWorkflowExists(); + }, [workflowFileExists]); const onDelete = useCallback( async (deleteWorkflow?: boolean) => { @@ -103,7 +114,7 @@ const Settings: React.FC = () => { return; } - updateAppStep({ step: "stack-deletion", deleteWorkflow: false }); + updateAppStep({ step: "stack-deletion", deleteWorkflow: false, appName: porterApp.name }); history.push("/apps"); } catch (err) { } finally {