Add download functionality to node toolbar component

This commit is contained in:
anovazzi1 2024-03-28 23:28:00 -03:00
commit 9c025d5889

View file

@ -31,6 +31,7 @@ import {
} from "../../../../utils/reactflowUtils"; } from "../../../../utils/reactflowUtils";
import { classNames, cn } from "../../../../utils/utils"; import { classNames, cn } from "../../../../utils/utils";
import ToolbarSelectItem from "./toolbarSelectItem"; import ToolbarSelectItem from "./toolbarSelectItem";
import { iconClasses } from "@mui/material";
export default function NodeToolbarComponent({ export default function NodeToolbarComponent({
data, data,
@ -341,6 +342,10 @@ export default function NodeToolbarComponent({
title: `${data.id} docs is not available at the moment.`, title: `${data.id} docs is not available at the moment.`,
}); });
} }
if (selected && (event.ctrlKey || event.metaKey) && event.key === "j") {
event.preventDefault();
downloadNode(flowComponent!);
}
} }
document.addEventListener("keydown", onKeyDown); document.addEventListener("keydown", onKeyDown);
@ -501,13 +506,13 @@ export default function NodeToolbarComponent({
)} )}
{(!hasStore || !hasApiKey || !validApiKey) && ( {(!hasStore || !hasApiKey || !validApiKey) && (
<SelectItem value={"Download"}> <SelectItem value={"Download"}>
<div className="flex"> <ToolbarSelectItem
<IconComponent value="Download"
name="Download" shift={false}
className="relative top-0.5 mr-2 h-4 w-4" isMac={navigator.userAgent.toUpperCase().includes("MAC")}
/>{" "} icon="Download"
Download{" "} styleObj={{ iconClasses: "relative top-0.5 mr-2 h-4 w-4" }}
</div>{" "} keyboardKey={"j"} dataTestId={"Dowload-button-nodeToolbar"} />
</SelectItem> </SelectItem>
)} )}
<SelectItem <SelectItem