Remove global variables from components
This commit is contained in:
parent
f12ae7db8f
commit
07852a1532
2 changed files with 16 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ import {
|
||||||
downloadNode,
|
downloadNode,
|
||||||
removeApiKeys,
|
removeApiKeys,
|
||||||
removeFileNameFromComponents,
|
removeFileNameFromComponents,
|
||||||
|
removeGlobalVariableFromComponents,
|
||||||
} from "../../utils/reactflowUtils";
|
} from "../../utils/reactflowUtils";
|
||||||
import { getTagsIds } from "../../utils/storeUtils";
|
import { getTagsIds } from "../../utils/storeUtils";
|
||||||
import ConfirmationModal from "../ConfirmationModal";
|
import ConfirmationModal from "../ConfirmationModal";
|
||||||
|
|
@ -100,6 +101,7 @@ export default function ShareModal({
|
||||||
const handleShareComponent = async (update = false) => {
|
const handleShareComponent = async (update = false) => {
|
||||||
//remove file names from flows before sharing
|
//remove file names from flows before sharing
|
||||||
removeFileNameFromComponents(component);
|
removeFileNameFromComponents(component);
|
||||||
|
removeGlobalVariableFromComponents(component);
|
||||||
const flow: FlowType = removeApiKeys({
|
const flow: FlowType = removeApiKeys({
|
||||||
id: component!.id,
|
id: component!.id,
|
||||||
data: component!.data,
|
data: component!.data,
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
export function typesGenerator(data: APIObjectType) {
|
||||||
return Object.keys(data)
|
return Object.keys(data)
|
||||||
.reverse()
|
.reverse()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue