-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delete action in workflows table #802
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
type Props = { | ||
className: string; | ||
className?: string; | ||
}; | ||
|
||
function GarbageIcon({ className }: Props) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
skyvern-frontend/src/routes/workflows/WorkflowsBetaAlertCard.tsx
This file was deleted.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
skyvern-frontend/src/routes/workflows/editor/DeleteWorkflowButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { getClient } from "@/api/AxiosClient"; | ||
import { GarbageIcon } from "@/components/icons/GarbageIcon"; | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@/components/ui/dialog"; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "@/components/ui/tooltip"; | ||
import { toast } from "@/components/ui/use-toast"; | ||
import { useCredentialGetter } from "@/hooks/useCredentialGetter"; | ||
import { ReloadIcon } from "@radix-ui/react-icons"; | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { AxiosError } from "axios"; | ||
|
||
type Props = { | ||
id: string; | ||
}; | ||
|
||
function DeleteWorkflowButton({ id }: Props) { | ||
const credentialGetter = useCredentialGetter(); | ||
const queryClient = useQueryClient(); | ||
|
||
const deleteWorkflowMutation = useMutation({ | ||
mutationFn: async (id: string) => { | ||
const client = await getClient(credentialGetter); | ||
return client.delete(`/workflows/${id}`); | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ | ||
queryKey: ["workflows"], | ||
}); | ||
}, | ||
onError: (error: AxiosError) => { | ||
toast({ | ||
variant: "destructive", | ||
title: "Failed to delete workflow", | ||
description: error.message, | ||
}); | ||
}, | ||
}); | ||
|
||
return ( | ||
<Dialog> | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<DialogTrigger asChild> | ||
<Button size="icon" variant="outline"> | ||
<GarbageIcon className="h-4 w-4" /> | ||
</Button> | ||
</DialogTrigger> | ||
</TooltipTrigger> | ||
<TooltipContent>Delete Workflow</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
<DialogContent onCloseAutoFocus={(e) => e.preventDefault()}> | ||
<DialogHeader> | ||
<DialogTitle>Are you sure?</DialogTitle> | ||
<DialogDescription>This workflow will be deleted.</DialogDescription> | ||
</DialogHeader> | ||
<DialogFooter> | ||
<DialogClose asChild> | ||
<Button variant="secondary">Cancel</Button> | ||
</DialogClose> | ||
<Button | ||
variant="destructive" | ||
onClick={() => { | ||
deleteWorkflowMutation.mutate(id); | ||
}} | ||
disabled={deleteWorkflowMutation.isPending} | ||
> | ||
{deleteWorkflowMutation.isPending && ( | ||
<ReloadIcon className="mr-2 h-4 w-4 animate-spin" /> | ||
)} | ||
Delete | ||
</Button> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export { DeleteWorkflowButton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleteWorkflowMutation.isPending
should bedeleteWorkflowMutation.isLoading
to correctly disable the button during the mutation process.