Skip to content

Commit

Permalink
do not prompt to delete workflow file if workflow file not found (#3637)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Sep 25, 2023
1 parent 97256e8 commit 8716f33
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions dashboard/src/main/home/app-dashboard/app-view/tabs/Settings.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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 {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8716f33

Please sign in to comment.