♻️ (reactflowUtils.ts): reorder imports for better readability
♻️ (reactflowUtils.ts): remove unnecessary console.log statements ♻️ (reactflowUtils.ts): fix formatting issues and improve code consistency 💡 (reactflowUtils.ts): remove trailing commas to improve code consistency and readability ♻️ (utils.ts): use toTitleCase function for headerName to improve readability
This commit is contained in:
parent
3925d15eaa
commit
aed7d2eeca
2 changed files with 15 additions and 20 deletions
|
|
@ -16,6 +16,8 @@ import {
|
|||
specialCharsRegex,
|
||||
} from "../constants/constants";
|
||||
import { downloadFlowsFromDatabase } from "../controllers/API";
|
||||
import getFieldTitle from "../customNodes/utils/get-field-title";
|
||||
import { DESCRIPTIONS } from "../flow_constants";
|
||||
import {
|
||||
APIClassType,
|
||||
APIKindType,
|
||||
|
|
@ -37,8 +39,6 @@ import {
|
|||
updateEdgesHandleIdsType,
|
||||
} from "../types/utils/reactflowUtils";
|
||||
import { createRandomKey, toTitleCase } from "./utils";
|
||||
import { DESCRIPTIONS } from "../flow_constants";
|
||||
import getFieldTitle from "../customNodes/utils/get-field-title";
|
||||
const uid = new ShortUniqueId({ length: 5 });
|
||||
|
||||
export function checkChatInput(nodes: Node[]) {
|
||||
|
|
@ -350,12 +350,7 @@ export function updateEdges(edges: Edge[]) {
|
|||
}
|
||||
|
||||
export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) {
|
||||
console.log("flow", flow);
|
||||
console.log("flows", flows);
|
||||
const existingNames = flows
|
||||
.filter((f) => f.folder_id === flow.folder_id)
|
||||
.map((item) => item.name);
|
||||
console.log("existingNames", existingNames);
|
||||
const existingNames = flows.map((item) => item.name);
|
||||
let newName = flow.name;
|
||||
let count = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export function normalCaseToSnakeCase(str: string): string {
|
|||
|
||||
export function toTitleCase(
|
||||
str: string | undefined,
|
||||
isNodeField?: boolean
|
||||
isNodeField?: boolean,
|
||||
): string {
|
||||
if (!str) return "";
|
||||
let result = str
|
||||
|
|
@ -64,7 +64,7 @@ export function toTitleCase(
|
|||
if (isNodeField) return word;
|
||||
if (index === 0) {
|
||||
return checkUpperWords(
|
||||
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||
word[0].toUpperCase() + word.slice(1).toLowerCase(),
|
||||
);
|
||||
}
|
||||
return checkUpperWords(word.toLowerCase());
|
||||
|
|
@ -77,7 +77,7 @@ export function toTitleCase(
|
|||
if (isNodeField) return word;
|
||||
if (index === 0) {
|
||||
return checkUpperWords(
|
||||
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||
word[0].toUpperCase() + word.slice(1).toLowerCase(),
|
||||
);
|
||||
}
|
||||
return checkUpperWords(word.toLowerCase());
|
||||
|
|
@ -181,7 +181,7 @@ export function checkLocalStorageKey(key: string): boolean {
|
|||
|
||||
export function IncrementObjectKey(
|
||||
object: object,
|
||||
key: string
|
||||
key: string,
|
||||
): { newKey: string; increment: number } {
|
||||
let count = 1;
|
||||
const type = removeCountFromString(key);
|
||||
|
|
@ -216,7 +216,7 @@ export function groupByFamily(
|
|||
data: APIDataType,
|
||||
baseClasses: string,
|
||||
left: boolean,
|
||||
flow?: NodeType[]
|
||||
flow?: NodeType[],
|
||||
): groupedObjType[] {
|
||||
const baseClassesSet = new Set(baseClasses.split("\n"));
|
||||
let arrOfPossibleInputs: Array<{
|
||||
|
|
@ -242,7 +242,7 @@ export function groupByFamily(
|
|||
baseClassesSet.has(template.type)) ||
|
||||
(template.input_types &&
|
||||
template.input_types.some((inputType) =>
|
||||
baseClassesSet.has(inputType)
|
||||
baseClassesSet.has(inputType),
|
||||
)))
|
||||
);
|
||||
};
|
||||
|
|
@ -262,7 +262,7 @@ export function groupByFamily(
|
|||
hasBaseClassInBaseClasses:
|
||||
foundNode?.hasBaseClassInBaseClasses ||
|
||||
nodeData.node!.base_classes.some((baseClass) =>
|
||||
baseClassesSet.has(baseClass)
|
||||
baseClassesSet.has(baseClass),
|
||||
), //seta como anterior ou verifica se o node tem base class
|
||||
displayName: nodeData.node?.display_name,
|
||||
});
|
||||
|
|
@ -279,10 +279,10 @@ export function groupByFamily(
|
|||
if (!foundNode) {
|
||||
foundNode = {
|
||||
hasBaseClassInTemplate: Object.values(node!.template).some(
|
||||
checkBaseClass
|
||||
checkBaseClass,
|
||||
),
|
||||
hasBaseClassInBaseClasses: node!.base_classes.some((baseClass) =>
|
||||
baseClassesSet.has(baseClass)
|
||||
baseClassesSet.has(baseClass),
|
||||
),
|
||||
displayName: node?.display_name,
|
||||
};
|
||||
|
|
@ -351,7 +351,7 @@ export function isTimeStampString(str: string): boolean {
|
|||
|
||||
export function extractColumnsFromRows(
|
||||
rows: object[],
|
||||
mode: "intersection" | "union" | "all"
|
||||
mode: "intersection" | "union" | "all",
|
||||
): (ColDef<any> | ColGroupDef<any>)[] {
|
||||
const columnsKeys: { [key: string]: ColDef<any> | ColGroupDef<any> } = {};
|
||||
if (rows.length === 0) {
|
||||
|
|
@ -360,7 +360,7 @@ export function extractColumnsFromRows(
|
|||
function intersection() {
|
||||
for (const key in rows[0]) {
|
||||
columnsKeys[key] = {
|
||||
headerName: key,
|
||||
headerName: toTitleCase(key),
|
||||
field: key,
|
||||
cellRenderer: TableAutoCellRender,
|
||||
filter: true,
|
||||
|
|
@ -378,7 +378,7 @@ export function extractColumnsFromRows(
|
|||
for (const row of rows) {
|
||||
for (const key in row) {
|
||||
columnsKeys[key] = {
|
||||
headerName: key,
|
||||
headerName: toTitleCase(key),
|
||||
field: key,
|
||||
filter: true,
|
||||
cellRenderer: TableAutoCellRender,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue