Skip to content

Commit

Permalink
Merge branch 'Significant-Gravitas:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ymrohit authored Oct 24, 2024
2 parents 0b824d3 + e908068 commit 8352185
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useCallback, useEffect } from "react";
import {
Popover,
PopoverContent,
Expand All @@ -15,6 +15,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { useToast } from "@/components/ui/use-toast";

interface SaveControlProps {
agentMeta: GraphMeta | null;
Expand Down Expand Up @@ -52,14 +53,35 @@ export const SaveControl = ({

// Determines if we're saving a template or an agent
let isTemplate = agentMeta?.is_template ? true : undefined;
const handleSave = () => {
const handleSave = useCallback(() => {
onSave(isTemplate);
};
}, [onSave, isTemplate]);

const getType = () => {
return agentMeta?.is_template ? "template" : "agent";
};

const { toast } = useToast();

useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if ((event.ctrlKey || event.metaKey) && event.key === "s") {
event.preventDefault(); // Stop the browser default action
handleSave(); // Call your save function
toast({
duration: 2000,
title: "All changes saved successfully!",
});
}
};

window.addEventListener("keydown", handleKeyDown);

return () => {
window.removeEventListener("keydown", handleKeyDown);
};
}, [handleSave]);

return (
<Popover open={pinSavePopover ? true : undefined}>
<Tooltip delayDuration={500}>
Expand Down

0 comments on commit 8352185

Please sign in to comment.