From 4c9dc55205848c24d2b8e8330e6272e146e81e89 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:32:47 -0300 Subject: [PATCH] removeApiKeys migration done --- src/frontend/src/modals/exportModal/index.tsx | 2 +- src/frontend/src/utils.ts | 18 +----------------- src/frontend/src/utils/reactflowUtils.ts | 13 +++++++++++++ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/frontend/src/modals/exportModal/index.tsx b/src/frontend/src/modals/exportModal/index.tsx index fb6867811..3a1d27b6f 100644 --- a/src/frontend/src/modals/exportModal/index.tsx +++ b/src/frontend/src/modals/exportModal/index.tsx @@ -16,7 +16,7 @@ import { EXPORT_DIALOG_SUBTITLE } from "../../constants"; import { alertContext } from "../../contexts/alertContext"; import { PopUpContext } from "../../contexts/popUpContext"; import { TabsContext } from "../../contexts/tabsContext"; -import { removeApiKeys } from "../../utils"; +import { removeApiKeys } from "../../utils/reactflowUtils"; export default function ExportModal() { const [open, setOpen] = useState(true); diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 95890a3c8..8e9b6cb64 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -5,7 +5,7 @@ import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; import { APITemplateType } from "./types/api"; import { IVarHighlightType } from "./types/components"; -import { FlowType, NodeType } from "./types/flow"; +import { NodeType } from "./types/flow"; export function classNames(...classes: Array) { return classes.filter(Boolean).join(" "); @@ -70,22 +70,6 @@ export function normalCaseToSnakeCase(str: string) { .join("_"); } -export function roundNumber(x: number, decimals: number) { - return Math.round(x * Math.pow(10, decimals)) / Math.pow(10, decimals); -} - -export function removeApiKeys(flow: FlowType): FlowType { - let cleanFLow = _.cloneDeep(flow); - cleanFLow.data.nodes.forEach((node) => { - for (const key in node.data.node.template) { - if (node.data.node.template[key].password) { - node.data.node.template[key].value = ""; - } - } - }); - return cleanFLow; -} - export function updateObject>( reference: T, objectToUpdate: T diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index c5fe272e7..7bd9cc4a2 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,5 +1,6 @@ import _ from "lodash"; import { Connection, ReactFlowInstance } from "reactflow"; +import { FlowType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; export function cleanEdges({ @@ -87,3 +88,15 @@ export function isValidConnection( } return false; } + +export function removeApiKeys(flow: FlowType): FlowType { + let cleanFLow = _.cloneDeep(flow); + cleanFLow.data.nodes.forEach((node) => { + for (const key in node.data.node.template) { + if (node.data.node.template[key].password) { + node.data.node.template[key].value = ""; + } + } + }); + return cleanFLow; +}