diff --git a/src/frontend/src/modals/shareModal/index.tsx b/src/frontend/src/modals/shareModal/index.tsx index 2dddbe232..83dbb7137 100644 --- a/src/frontend/src/modals/shareModal/index.tsx +++ b/src/frontend/src/modals/shareModal/index.tsx @@ -20,6 +20,7 @@ import { downloadNode, removeApiKeys, removeFileNameFromComponents, + removeGlobalVariableFromComponents, } from "../../utils/reactflowUtils"; import { getTagsIds } from "../../utils/storeUtils"; import ConfirmationModal from "../ConfirmationModal"; @@ -100,6 +101,7 @@ export default function ShareModal({ const handleShareComponent = async (update = false) => { //remove file names from flows before sharing removeFileNameFromComponents(component); + removeGlobalVariableFromComponents(component); const flow: FlowType = removeApiKeys({ id: component!.id, data: component!.data, diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index f9de6099b..901dd1cf7 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1192,6 +1192,20 @@ export function removeFileNameFromComponents(flow: FlowType) { }); } +export function removeGlobalVariableFromComponents(flow: FlowType) { + flow.data!.nodes.forEach((node: NodeType) => { + Object.keys(node.data.node!.template).forEach((field) => { + if (node.data?.node?.template[field]?.load_from_db) { + node.data.node!.template[field].value = ""; + node.data.node!.template[field].load_from_db = false; + } + }); + if (node.data.node?.flow) { + removeGlobalVariableFromComponents(node.data.node.flow); + } + }); +} + export function typesGenerator(data: APIObjectType) { return Object.keys(data) .reverse()