Merge branch 'feature/store' of github.com:logspace-ai/langflow into feature/store
This commit is contained in:
commit
1033369795
3 changed files with 56 additions and 20 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
import { ConfirmationModalType } from "../../types/components";
|
import { ConfirmationModalType } from "../../types/components";
|
||||||
import { nodeIconsLucide } from "../../utils/styleUtils";
|
import { nodeIconsLucide } from "../../utils/styleUtils";
|
||||||
|
|
@ -17,12 +17,18 @@ export default function ConfirmationModal({
|
||||||
data,
|
data,
|
||||||
index,
|
index,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
}: ConfirmationModalType) {
|
}: ConfirmationModalType) {
|
||||||
const Icon: any = nodeIconsLucide[icon];
|
const Icon: any = nodeIconsLucide[icon];
|
||||||
|
const [modalOpen, setModalOpen] = useState(open ?? false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (onClose) onClose!(modalOpen);
|
||||||
|
}, [modalOpen]);
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
|
||||||
return (
|
return (
|
||||||
<BaseModal size="x-small" open={open} setOpen={setOpen}>
|
<BaseModal size="x-small" open={modalOpen} setOpen={setModalOpen}>
|
||||||
<BaseModal.Trigger asChild={asChild}>{children}</BaseModal.Trigger>
|
<BaseModal.Trigger asChild={asChild}>{children}</BaseModal.Trigger>
|
||||||
<BaseModal.Header description={titleHeader}>
|
<BaseModal.Header description={titleHeader}>
|
||||||
<span className="pr-2">{title}</span>
|
<span className="pr-2">{title}</span>
|
||||||
|
|
@ -46,7 +52,7 @@ export default function ConfirmationModal({
|
||||||
<Button
|
<Button
|
||||||
className="ml-3"
|
className="ml-3"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpen(false);
|
setModalOpen(false);
|
||||||
onConfirm(index, data);
|
onConfirm(index, data);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
@ -56,7 +62,7 @@ export default function ConfirmationModal({
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpen(false);
|
setModalOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{cancelText}
|
{cancelText}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import {
|
||||||
import { alertContext } from "../../../../contexts/alertContext";
|
import { alertContext } from "../../../../contexts/alertContext";
|
||||||
import { TabsContext } from "../../../../contexts/tabsContext";
|
import { TabsContext } from "../../../../contexts/tabsContext";
|
||||||
import { saveFlowStore } from "../../../../controllers/API";
|
import { saveFlowStore } from "../../../../controllers/API";
|
||||||
|
import ConfirmationModal from "../../../../modals/ConfirmationModal";
|
||||||
import EditNodeModal from "../../../../modals/EditNodeModal";
|
import EditNodeModal from "../../../../modals/EditNodeModal";
|
||||||
import { nodeToolbarPropsType } from "../../../../types/components";
|
import { nodeToolbarPropsType } from "../../../../types/components";
|
||||||
import {
|
import {
|
||||||
|
|
@ -64,8 +65,26 @@ export default function NodeToolbarComponent({
|
||||||
const { paste, saveComponent } = useContext(TabsContext);
|
const { paste, saveComponent } = useContext(TabsContext);
|
||||||
const reactFlowInstance = useReactFlow();
|
const reactFlowInstance = useReactFlow();
|
||||||
const [showModalAdvanced, setShowModalAdvanced] = useState(false);
|
const [showModalAdvanced, setShowModalAdvanced] = useState(false);
|
||||||
|
const [showconfirmShare, setShowconfirmShare] = useState(false);
|
||||||
const [selectedValue, setSelectedValue] = useState("");
|
const [selectedValue, setSelectedValue] = useState("");
|
||||||
|
|
||||||
|
function handleShareComponent() {
|
||||||
|
const componentFlow = cloneDeep(data);
|
||||||
|
saveFlowStore(createFlowComponent(componentFlow)).then(
|
||||||
|
() => {
|
||||||
|
saveComponent(componentFlow);
|
||||||
|
setSuccessData({
|
||||||
|
title: "Component shared successfully",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
setErrorData({
|
||||||
|
title: "Error sharing component",
|
||||||
|
list: [err["response"]["data"]["detail"]],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
const handleSelectChange = (event) => {
|
const handleSelectChange = (event) => {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case "advanced":
|
case "advanced":
|
||||||
|
|
@ -79,21 +98,8 @@ export default function NodeToolbarComponent({
|
||||||
downloadNode(createFlowComponent(cloneDeep(data)));
|
downloadNode(createFlowComponent(cloneDeep(data)));
|
||||||
break;
|
break;
|
||||||
case "Share":
|
case "Share":
|
||||||
const componentFlow = cloneDeep(data);
|
console.log("Share");
|
||||||
saveFlowStore(createFlowComponent(componentFlow)).then(
|
setShowconfirmShare(true);
|
||||||
() => {
|
|
||||||
saveComponent(componentFlow);
|
|
||||||
setSuccessData({
|
|
||||||
title: "Component shared successfully",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
setErrorData({
|
|
||||||
title: "Error sharing component",
|
|
||||||
list: [err["response"]["data"]["detail"]],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case "SaveAll":
|
case "SaveAll":
|
||||||
saveComponent(cloneDeep(data));
|
saveComponent(cloneDeep(data));
|
||||||
|
|
@ -269,6 +275,28 @@ export default function NodeToolbarComponent({
|
||||||
<></>
|
<></>
|
||||||
</EditNodeModal>
|
</EditNodeModal>
|
||||||
)}
|
)}
|
||||||
|
{showconfirmShare && (
|
||||||
|
<ConfirmationModal
|
||||||
|
key={data.id}
|
||||||
|
index={0}
|
||||||
|
modalContentTitle="Are you sure you want to share this component?"
|
||||||
|
modalContent="This component will be available for everyone to use."
|
||||||
|
title="Share Component"
|
||||||
|
confirmationText="Share"
|
||||||
|
icon="Share2"
|
||||||
|
onConfirm={() => {
|
||||||
|
handleShareComponent();
|
||||||
|
}}
|
||||||
|
titleHeader=""
|
||||||
|
cancelText="Cancel"
|
||||||
|
open={showconfirmShare}
|
||||||
|
onClose={(modal) => {
|
||||||
|
setShowconfirmShare(modal);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div></div>
|
||||||
|
</ConfirmationModal>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,8 @@ export type ConfirmationModalType = {
|
||||||
data?: any;
|
data?: any;
|
||||||
index: number;
|
index: number;
|
||||||
onConfirm: (index, data) => void;
|
onConfirm: (index, data) => void;
|
||||||
|
open?: boolean;
|
||||||
|
onClose?: (close: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UserManagementType = {
|
export type UserManagementType = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue