Merge branch 'main' into dev

This commit is contained in:
Gabriel Almeida 2023-05-22 20:09:21 -03:00
commit 14f27df3ae
8 changed files with 85 additions and 88 deletions

View file

@ -7370,4 +7370,4 @@
} }
} }
} }
} }

View file

@ -1,7 +1,7 @@
import { Transition } from "@headlessui/react"; import { Transition } from "@headlessui/react";
import { import {
Bars3CenterLeftIcon, Bars3CenterLeftIcon,
ChatBubbleBottomCenterTextIcon, ChatBubbleBottomCenterTextIcon,
} from "@heroicons/react/24/outline"; } from "@heroicons/react/24/outline";
import { nodeColors } from "../../../utils"; import { nodeColors } from "../../../utils";
import { PopUpContext } from "../../../contexts/popUpContext"; import { PopUpContext } from "../../../contexts/popUpContext";
@ -9,37 +9,37 @@ import { useContext } from "react";
import ChatModal from "../../../modals/chatModal"; import ChatModal from "../../../modals/chatModal";
export default function ChatTrigger({ open, setOpen }) { export default function ChatTrigger({ open, setOpen }) {
const { openPopUp } = useContext(PopUpContext); const { openPopUp } = useContext(PopUpContext);
return ( return (
<Transition <Transition
show={!open} show={!open}
appear={true} appear={true}
enter="transition ease-out duration-300" enter="transition ease-out duration-300"
enterFrom="translate-y-96" enterFrom="translate-y-96"
enterTo="translate-y-0" enterTo="translate-y-0"
leave="transition ease-in duration-300" leave="transition ease-in duration-300"
leaveFrom="translate-y-0" leaveFrom="translate-y-0"
leaveTo="translate-y-96" leaveTo="translate-y-96"
> >
<div className="absolute bottom-4 right-3"> <div className="absolute bottom-4 right-3">
<div <div
// style={{ backgroundColor: nodeColors["chat"] }} // style={{ backgroundColor: nodeColors["chat"] }}
className="border flex justify-center align-center py-1 px-3 w-12 h-12 rounded-full bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 dark:border-gray-600" className="border flex justify-center align-center py-1 px-3 w-12 h-12 rounded-full bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 dark:border-gray-600"
> >
<button <button
onClick={() => { onClick={() => {
setOpen(true); setOpen(true);
}} }}
> >
<div className="flex gap-3 items-center"> <div className="flex gap-3 items-center">
<ChatBubbleBottomCenterTextIcon <ChatBubbleBottomCenterTextIcon
className="h-6 w-6 mt-1" className="h-6 w-6 mt-1"
style={{ color: "white" }} style={{ color: "white" }}
/> />
</div> </div>
</button> </button>
</div> </div>
</div> </div>
</Transition> </Transition>
); );
} }

View file

@ -57,7 +57,7 @@ export default function CodeAreaComponent({
); );
}} }}
> >
<ArrowTopRightOnSquareIcon className="w-6 h-6 hover:text-blue-600" /> <ArrowTopRightOnSquareIcon className="w-6 h-6 hover:text-blue-600 dark:text-gray-300" />
</button> </button>
</div> </div>
</div> </div>

View file

@ -58,7 +58,7 @@ export default function PromptAreaComponent({
); );
}} }}
> >
<ArrowTopRightOnSquareIcon className="w-6 h-6 hover:text-blue-600" /> <ArrowTopRightOnSquareIcon className="w-6 h-6 hover:text-blue-600 dark:text-gray-300" />
</button> </button>
</div> </div>
</div> </div>

View file

@ -25,7 +25,7 @@ export default function TextAreaComponent({ value, onChange, disabled }:TextArea
{myValue !== "" ? myValue : 'Text empty'} {myValue !== "" ? myValue : 'Text empty'}
</span> </span>
<button onClick={()=>{openPopUp(<TextAreaModal value={myValue} setValue={(t:string) => {setMyValue(t); onChange(t);}}/>)}}> <button onClick={()=>{openPopUp(<TextAreaModal value={myValue} setValue={(t:string) => {setMyValue(t); onChange(t);}}/>)}}>
<ArrowTopRightOnSquareIcon className="w-6 h-6 hover:text-blue-600" /> <ArrowTopRightOnSquareIcon className="w-6 h-6 hover:text-blue-600 dark:text-gray-300" />
</button> </button>
</div> </div>
</div> </div>

View file

@ -92,10 +92,10 @@ export default function ButtonBox({
<div className={textColor}>{icon}</div> <div className={textColor}>{icon}</div>
</div> </div>
</div> </div>
<div className="mt-auto mb-auto"> <div className="w-full mt-auto mb-auto">
<h3 <h3
className={classNames( className={classNames(
"font-semibold text-white dark:text-white/80", "w-full font-semibold break-words text-white dark:text-white/80",
titleFontSize, titleFontSize,
marginTop marginTop
)} )}

View file

@ -30,9 +30,7 @@ import { typesContext } from "../../contexts/typesContext";
import ConnectionLineComponent from "./components/ConnectionLineComponent"; import ConnectionLineComponent from "./components/ConnectionLineComponent";
import { FlowType, NodeType } from "../../types/flow"; import { FlowType, NodeType } from "../../types/flow";
import { APIClassType } from "../../types/api"; import { APIClassType } from "../../types/api";
import { import { isValidConnection } from "../../utils";
isValidConnection,
} from "../../utils";
import useUndoRedo from "./hooks/useUndoRedo"; import useUndoRedo from "./hooks/useUndoRedo";
const nodeTypes = { const nodeTypes = {
@ -43,49 +41,48 @@ export default function FlowPage({ flow }: { flow: FlowType }) {
let { updateFlow, disableCopyPaste, addFlow, getNodeId, paste } = let { updateFlow, disableCopyPaste, addFlow, getNodeId, paste } =
useContext(TabsContext); useContext(TabsContext);
const { types, reactFlowInstance, setReactFlowInstance, templates } = const { types, reactFlowInstance, setReactFlowInstance, templates } =
useContext(typesContext); useContext(typesContext);
const reactFlowWrapper = useRef(null); const reactFlowWrapper = useRef(null);
const { undo, redo, canUndo, canRedo, takeSnapshot } = useUndoRedo(); const { undo, redo, canUndo, canRedo, takeSnapshot } = useUndoRedo();
const [position, setPosition] = useState({ x: 0, y: 0 }); const [position, setPosition] = useState({ x: 0, y: 0 });
const [lastSelection, setLastSelection] = const [lastSelection, setLastSelection] =
useState<OnSelectionChangeParams>(null); useState<OnSelectionChangeParams>(null);
const [lastCopiedSelection, setLastCopiedSelection] = useState(null); const [lastCopiedSelection, setLastCopiedSelection] = useState(null);
useEffect(() => { useEffect(() => {
// this effect is used to attach the global event handlers // this effect is used to attach the global event handlers
const onKeyDown = (event: KeyboardEvent) => { const onKeyDown = (event: KeyboardEvent) => {
console.log("keydownou", lastCopiedSelection, position) console.log("keydownou", lastCopiedSelection, position);
if ( if (
(event.ctrlKey || event.metaKey) && (event.ctrlKey || event.metaKey) &&
event.key === "c" && event.key === "c" &&
lastSelection && lastSelection &&
!disableCopyPaste !disableCopyPaste
) { ) {
event.preventDefault(); event.preventDefault();
setLastCopiedSelection(_.cloneDeep(lastSelection)); setLastCopiedSelection(_.cloneDeep(lastSelection));
} }
if ( if (
(event.ctrlKey || event.metaKey) && (event.ctrlKey || event.metaKey) &&
event.key === "v" && event.key === "v" &&
lastCopiedSelection && lastCopiedSelection &&
!disableCopyPaste !disableCopyPaste
) { ) {
event.preventDefault(); event.preventDefault();
let bounds = reactFlowWrapper.current.getBoundingClientRect(); let bounds = reactFlowWrapper.current.getBoundingClientRect();
paste(lastCopiedSelection, { paste(lastCopiedSelection, {
x: position.x - bounds.left, x: position.x - bounds.left,
y: position.y - bounds.top, y: position.y - bounds.top,
}); });
} }
if ( if (
(event.ctrlKey || event.metaKey) && (event.ctrlKey || event.metaKey) &&
event.key === "g" && event.key === "g" &&
lastSelection lastSelection
) { ) {
event.preventDefault(); event.preventDefault();
// addFlow(newFlow, false); // addFlow(newFlow, false);
@ -94,21 +91,18 @@ export default function FlowPage({ flow }: { flow: FlowType }) {
const handleMouseMove = (event) => { const handleMouseMove = (event) => {
setPosition({ x: event.clientX, y: event.clientY }); setPosition({ x: event.clientX, y: event.clientY });
}; };
document.addEventListener('keydown', onKeyDown); document.addEventListener("keydown", onKeyDown);
document.addEventListener('mousemove', handleMouseMove); document.addEventListener("mousemove", handleMouseMove);
return () => { return () => {
document.removeEventListener('keydown', onKeyDown); document.removeEventListener("keydown", onKeyDown);
document.removeEventListener('mousemove', handleMouseMove); document.removeEventListener("mousemove", handleMouseMove);
}; };
}, [position, lastCopiedSelection, lastSelection]); }, [position, lastCopiedSelection, lastSelection]);
const [selectionMenuVisible, setSelectionMenuVisible] = useState(false); const [selectionMenuVisible, setSelectionMenuVisible] = useState(false);
const { setExtraComponent, setExtraNavigation } = useContext(locationContext); const { setExtraComponent, setExtraNavigation } = useContext(locationContext);
const { setErrorData } = useContext(alertContext); const { setErrorData } = useContext(alertContext);
const [nodes, setNodes, onNodesChange] = useNodesState( const [nodes, setNodes, onNodesChange] = useNodesState(
@ -314,10 +308,7 @@ export default function FlowPage({ flow }: { flow: FlowType }) {
}, []); }, []);
return ( return (
<div <div className="w-full h-full" ref={reactFlowWrapper}>
className="w-full h-full"
ref={reactFlowWrapper}
>
{Object.keys(templates).length > 0 && Object.keys(types).length > 0 ? ( {Object.keys(templates).length > 0 && Object.keys(types).length > 0 ? (
<> <>
<ReactFlow <ReactFlow
@ -357,4 +348,4 @@ export default function FlowPage({ flow }: { flow: FlowType }) {
)} )}
</div> </div>
); );
} }

View file

@ -76,6 +76,12 @@ module.exports = {
backgroundColor: "#bbb", backgroundColor: "#bbb",
}, },
}, },
".dark .theme-attribution .react-flow__attribution": {
backgroundColor: "rgba(255, 255, 255, 0.2)",
},
".dark .theme-attribution .react-flow__attribution a": {
color: "black",
},
}); });
}), }),
require("@tailwindcss/typography"), require("@tailwindcss/typography"),