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