add dialog for confirmation of code cache deletion (#3641)

This commit is contained in:
Shuchang Zheng
2025-10-07 18:16:19 -07:00
committed by GitHub
parent 360def0de5
commit 2b81a1090e
2 changed files with 94 additions and 26 deletions

View File

@@ -198,6 +198,34 @@ function Workspace({
splitLeft: useRef<HTMLInputElement>(null),
};
const handleOnSave = async () => {
const errors = getWorkflowErrors(nodes);
if (errors.length > 0) {
toast({
title: "Encountered error while trying to save workflow:",
description: (
<div className="space-y-2">
{errors.map((error) => (
<p key={error}>{error}</p>
))}
</div>
),
variant: "destructive",
});
return;
}
await saveWorkflow.mutateAsync();
workflowChangesStore.setSaidOkToCodeCacheDeletion(false);
queryClient.invalidateQueries({
queryKey: ["cache-key-values", workflowPermanentId, cacheKey],
});
setCacheKeyValueFilter("");
};
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") {
@@ -802,6 +830,39 @@ function Workspace({
</DialogContent>
</Dialog>
{/* confirm code cache deletion dialog */}
<Dialog
open={workflowChangesStore.showConfirmCodeCacheDeletion}
onOpenChange={(open) => {
!open && workflowChangesStore.setShowConfirmCodeCacheDeletion(false);
!open && workflowChangesStore.setSaidOkToCodeCacheDeletion(false);
}}
>
<DialogContent>
<DialogHeader>
<DialogTitle>Are you sure?</DialogTitle>
<DialogDescription>
Saving will delete cached code, and Skyvern will re-generate it in
the next run. Proceed?
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose asChild>
<Button variant="secondary">Cancel</Button>
</DialogClose>
<Button
variant="default"
onClick={async () => {
workflowChangesStore.setSaidOkToCodeCacheDeletion(true);
await handleOnSave();
}}
>
Yes
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
{/* cache key value delete dialog */}
<Dialog
open={openConfirmCacheKeyValueDeleteDialogue}
@@ -914,30 +975,7 @@ function Workspace({
});
}
}}
onSave={async () => {
const errors = getWorkflowErrors(nodes);
if (errors.length > 0) {
toast({
title: "Can not save workflow because of errors:",
description: (
<div className="space-y-2">
{errors.map((error) => (
<p key={error}>{error}</p>
))}
</div>
),
variant: "destructive",
});
return;
}
await saveWorkflow.mutateAsync();
queryClient.invalidateQueries({
queryKey: ["cache-key-values", workflowPermanentId, cacheKey],
});
setCacheKeyValueFilter("");
}}
onSave={async () => await handleOnSave()}
onRun={() => {
closeWorkflowPanel();
}}