Remove global variables from components

This commit is contained in:
anovazzi1 2024-04-01 18:44:21 -03:00
commit 07852a1532
2 changed files with 16 additions and 0 deletions

View file

@ -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,

View file

@ -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()