Skip to content
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

feat: add tools table for creating and deleting tools #284

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

tylerslaton
Copy link
Contributor

Screen.Recording.2024-10-23.at.11.43.25.AM.mov

Comment on lines 21 to 30
await ToolReferenceService.createToolReference({
toolReference: { ...data, toolType: "tool" },
});
reset();
onSuccess();
} catch (error) {
console.error("Failed to create tool reference:", error);
} finally {
setIsSubmitting(false);
}
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    const { execute: onSubmit, isLoading } = useAsync(
        async (data: CreateToolReference) => {
            await ToolReferenceService.createToolReference({
                toolReference: { ...data, toolType: "tool" },
            });
            reset();
            onSuccess();
        },
        {
            onError: (error) =>
                console.error("Failed to create tool reference:", error),
        }
    );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦🏻 So much better, thanks Ryan.

Comment on lines 110 to 143
<Dialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
<DialogTrigger asChild>
<Button variant="ghost" size="sm">
<Trash2Icon className="h-4 w-4" />
</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Are you sure?</DialogTitle>
<DialogDescription>
This action cannot be undone. This will permanently
delete the tool reference.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button
variant="outline"
onClick={() => setIsDeleteDialogOpen(false)}
>
Cancel
</Button>
<Button
variant="destructive"
onClick={() => {
onDelete();
setIsDeleteDialogOpen(false);
}}
>
Delete
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a helper component called ConfirmationDialog that will handle this quite nicely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yep does this exactly.

Comment on lines +21 to +33
const { data: tools, mutate } = useSWR(
ToolReferenceService.getToolReferences.key("tool"),
() => ToolReferenceService.getToolReferences("tool")
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: preload in a clientLoader?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@ryanhopperlowe ryanhopperlowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of small things but other than that looks great!

@tylerslaton
Copy link
Contributor Author

@ryanhopperlowe Mind giving this another look?

@ryanhopperlowe
Copy link
Contributor

All set here!

@tylerslaton tylerslaton merged commit b117891 into obot-platform:main Oct 23, 2024
1 check passed
@tylerslaton tylerslaton deleted the tools-view branch October 23, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants