🐛 fix(buildTrigger): rename import of TabsState to FlowsState to improve semantics
🐛 fix(EditNodeModal): rename import of TabsState to FlowsState to improve semantics 🐛 fix(formModal): rename import of TabsState to FlowsState to improve semantics 🐛 fix(PageComponent): rename import of TabsState to FlowsState to improve semantics 🐛 fix(reactflowUtils): rename import of TabsState to FlowsState to improve semantics 🐛 fix(utils): rename import of TabsState to FlowsState to improve semantics 🚚 chore(server.ts): change port variable case from lowercase port to uppercase PORT to improve semantics ✨ feat(server.ts): add support for process.env.PORT environment variable to be able to run app on a configurable port
This commit is contained in:
parent
98e0668e10
commit
c1bc2de720
6 changed files with 25 additions and 24 deletions
|
|
@ -9,7 +9,7 @@ import { FlowType } from "../../../types/flow";
|
||||||
|
|
||||||
import { FlowsContext } from "../../../contexts/flowsContext";
|
import { FlowsContext } from "../../../contexts/flowsContext";
|
||||||
import { parsedDataType } from "../../../types/components";
|
import { parsedDataType } from "../../../types/components";
|
||||||
import { TabsState } from "../../../types/tabs";
|
import { FlowsState } from "../../../types/tabs";
|
||||||
import { validateNodes } from "../../../utils/reactflowUtils";
|
import { validateNodes } from "../../../utils/reactflowUtils";
|
||||||
import RadialProgressComponent from "../../RadialProgress";
|
import RadialProgressComponent from "../../RadialProgress";
|
||||||
import IconComponent from "../../genericIconComponent";
|
import IconComponent from "../../genericIconComponent";
|
||||||
|
|
@ -99,7 +99,7 @@ export default function BuildTrigger({
|
||||||
setSuccessData({ title: parsedData.log });
|
setSuccessData({ title: parsedData.log });
|
||||||
} else if (parsedData.input_keys !== undefined) {
|
} else if (parsedData.input_keys !== undefined) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
setTabsState((old: TabsState) => {
|
setTabsState((old: FlowsState) => {
|
||||||
return {
|
return {
|
||||||
...old,
|
...old,
|
||||||
[flowId]: {
|
[flowId]: {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import { limitScrollFieldsModal } from "../../constants/constants";
|
||||||
import { FlowsContext } from "../../contexts/flowsContext";
|
import { FlowsContext } from "../../contexts/flowsContext";
|
||||||
import { typesContext } from "../../contexts/typesContext";
|
import { typesContext } from "../../contexts/typesContext";
|
||||||
import { NodeDataType } from "../../types/flow";
|
import { NodeDataType } from "../../types/flow";
|
||||||
import { TabsState } from "../../types/tabs";
|
import { FlowsState } from "../../types/tabs";
|
||||||
import {
|
import {
|
||||||
convertObjToArray,
|
convertObjToArray,
|
||||||
convertValuesToNumbers,
|
convertValuesToNumbers,
|
||||||
|
|
@ -542,7 +542,7 @@ const EditNodeModal = forwardRef(
|
||||||
const newData = cloneDeep(myData.current);
|
const newData = cloneDeep(myData.current);
|
||||||
myData.current = newData;
|
myData.current = newData;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
setTabsState((prev: TabsState) => {
|
setTabsState((prev: FlowsState) => {
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
[tabId]: {
|
[tabId]: {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import { CHAT_FORM_DIALOG_SUBTITLE } from "../../constants/constants";
|
||||||
import { AuthContext } from "../../contexts/authContext";
|
import { AuthContext } from "../../contexts/authContext";
|
||||||
import { FlowsContext } from "../../contexts/flowsContext";
|
import { FlowsContext } from "../../contexts/flowsContext";
|
||||||
import { getBuildStatus } from "../../controllers/API";
|
import { getBuildStatus } from "../../controllers/API";
|
||||||
import { TabsState } from "../../types/tabs";
|
import { FlowsState } from "../../types/tabs";
|
||||||
import { validateNodes } from "../../utils/reactflowUtils";
|
import { validateNodes } from "../../utils/reactflowUtils";
|
||||||
|
|
||||||
export default function FormModal({
|
export default function FormModal({
|
||||||
|
|
@ -401,7 +401,7 @@ export default function FormModal({
|
||||||
chatKey: chatKey!,
|
chatKey: chatKey!,
|
||||||
});
|
});
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
setTabsState((old: TabsState) => {
|
setTabsState((old: FlowsState) => {
|
||||||
if (!chatKey) return old;
|
if (!chatKey) return old;
|
||||||
let newTabsState = _.cloneDeep(old);
|
let newTabsState = _.cloneDeep(old);
|
||||||
newTabsState[id.current].formKeysData.input_keys![chatKey] = "";
|
newTabsState[id.current].formKeysData.input_keys![chatKey] = "";
|
||||||
|
|
@ -522,7 +522,7 @@ export default function FormModal({
|
||||||
}
|
}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
setTabsState((old: TabsState) => {
|
setTabsState((old: FlowsState) => {
|
||||||
let newTabsState = _.cloneDeep(old);
|
let newTabsState = _.cloneDeep(old);
|
||||||
newTabsState[
|
newTabsState[
|
||||||
id.current
|
id.current
|
||||||
|
|
@ -634,7 +634,7 @@ export default function FormModal({
|
||||||
setChatValue={(value) => {
|
setChatValue={(value) => {
|
||||||
setChatValue(value);
|
setChatValue(value);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
setTabsState((old: TabsState) => {
|
setTabsState((old: FlowsState) => {
|
||||||
let newTabsState = _.cloneDeep(old);
|
let newTabsState = _.cloneDeep(old);
|
||||||
newTabsState[id.current].formKeysData.input_keys![
|
newTabsState[id.current].formKeysData.input_keys![
|
||||||
chatKey!
|
chatKey!
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import { typesContext } from "../../../../contexts/typesContext";
|
||||||
import { undoRedoContext } from "../../../../contexts/undoRedoContext";
|
import { undoRedoContext } from "../../../../contexts/undoRedoContext";
|
||||||
import { APIClassType } from "../../../../types/api";
|
import { APIClassType } from "../../../../types/api";
|
||||||
import { FlowType, NodeType, targetHandleType } from "../../../../types/flow";
|
import { FlowType, NodeType, targetHandleType } from "../../../../types/flow";
|
||||||
import { TabsState } from "../../../../types/tabs";
|
import { FlowsState } from "../../../../types/tabs";
|
||||||
import {
|
import {
|
||||||
generateFlow,
|
generateFlow,
|
||||||
generateNodeFromFlow,
|
generateNodeFromFlow,
|
||||||
|
|
@ -208,7 +208,7 @@ export default function Page({
|
||||||
return newX;
|
return newX;
|
||||||
});
|
});
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
setTabsState((prev: TabsState) => {
|
setTabsState((prev: FlowsState) => {
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
[tabId]: {
|
[tabId]: {
|
||||||
|
|
@ -225,7 +225,7 @@ export default function Page({
|
||||||
(change: NodeChange[]) => {
|
(change: NodeChange[]) => {
|
||||||
onNodesChange(change);
|
onNodesChange(change);
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
setTabsState((prev: TabsState) => {
|
setTabsState((prev: FlowsState) => {
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
[tabId]: {
|
[tabId]: {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import {
|
||||||
unselectAllNodesType,
|
unselectAllNodesType,
|
||||||
updateEdgesHandleIdsType,
|
updateEdgesHandleIdsType,
|
||||||
} from "../types/utils/reactflowUtils";
|
} from "../types/utils/reactflowUtils";
|
||||||
import { getFieldTitle } from "./utils";
|
import { getFieldTitle, toTitleCase } from "./utils";
|
||||||
|
|
||||||
export function cleanEdges({
|
export function cleanEdges({
|
||||||
flow: { edges, nodes },
|
flow: { edges, nodes },
|
||||||
|
|
@ -506,7 +506,7 @@ export function generateFlow(
|
||||||
name: string
|
name: string
|
||||||
): generateFlowType {
|
): generateFlowType {
|
||||||
const newFlowData = reactFlowInstance.toObject();
|
const newFlowData = reactFlowInstance.toObject();
|
||||||
|
const uid = new ShortUniqueId({ length: 5 });
|
||||||
/* remove edges that are not connected to selected nodes on both ends
|
/* remove edges that are not connected to selected nodes on both ends
|
||||||
in future we can save this edges to when ungrouping reconect to the old nodes
|
in future we can save this edges to when ungrouping reconect to the old nodes
|
||||||
*/
|
*/
|
||||||
|
|
@ -869,7 +869,7 @@ export function ungroupNode(
|
||||||
let { field, id } = template[key].proxy!;
|
let { field, id } = template[key].proxy!;
|
||||||
let nodeIndex = gNodes.findIndex((n) => n.id === id);
|
let nodeIndex = gNodes.findIndex((n) => n.id === id);
|
||||||
if (nodeIndex !== -1) {
|
if (nodeIndex !== -1) {
|
||||||
let display_name: string;
|
let display_name: string | undefined;
|
||||||
let show = gNodes[nodeIndex].data.node!.template[field].show;
|
let show = gNodes[nodeIndex].data.node!.template[field].show;
|
||||||
let advanced = gNodes[nodeIndex].data.node!.template[field].advanced;
|
let advanced = gNodes[nodeIndex].data.node!.template[field].advanced;
|
||||||
if (gNodes[nodeIndex].data.node!.template[field].display_name) {
|
if (gNodes[nodeIndex].data.node!.template[field].display_name) {
|
||||||
|
|
@ -959,7 +959,7 @@ export function expandGroupNode(
|
||||||
let nodeIndex = gNodes.findIndex((n) => n.id === id);
|
let nodeIndex = gNodes.findIndex((n) => n.id === id);
|
||||||
if (nodeIndex !== -1) {
|
if (nodeIndex !== -1) {
|
||||||
let proxy: { id: string; field: string } | undefined;
|
let proxy: { id: string; field: string } | undefined;
|
||||||
let display_name: string;
|
let display_name: string | undefined;
|
||||||
let show = gNodes[nodeIndex].data.node!.template[field].show;
|
let show = gNodes[nodeIndex].data.node!.template[field].show;
|
||||||
let advanced = gNodes[nodeIndex].data.node!.template[field].advanced;
|
let advanced = gNodes[nodeIndex].data.node!.template[field].advanced;
|
||||||
if (gNodes[nodeIndex].data.node!.template[field].display_name) {
|
if (gNodes[nodeIndex].data.node!.template[field].display_name) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
tweakType,
|
tweakType,
|
||||||
} from "../types/components";
|
} from "../types/components";
|
||||||
import { FlowType, NodeType } from "../types/flow";
|
import { FlowType, NodeType } from "../types/flow";
|
||||||
import { TabsState } from "../types/tabs";
|
import { FlowsState } from "../types/tabs";
|
||||||
import { buildTweaks } from "./reactflowUtils";
|
import { buildTweaks } from "./reactflowUtils";
|
||||||
|
|
||||||
export function classNames(...classes: Array<string>): string {
|
export function classNames(...classes: Array<string>): string {
|
||||||
|
|
@ -57,7 +57,8 @@ export function normalCaseToSnakeCase(str: string): string {
|
||||||
.join("_");
|
.join("_");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toTitleCase(str: string): string {
|
export function toTitleCase(str: string | undefined): string {
|
||||||
|
if (!str) return "";
|
||||||
let result = str
|
let result = str
|
||||||
.split("_")
|
.split("_")
|
||||||
.map((word, index) => {
|
.map((word, index) => {
|
||||||
|
|
@ -199,7 +200,7 @@ export function groupByFamily(
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildInputs(tabsState: TabsState, id: string): string {
|
export function buildInputs(tabsState: FlowsState, id: string): string {
|
||||||
return tabsState &&
|
return tabsState &&
|
||||||
tabsState[id] &&
|
tabsState[id] &&
|
||||||
tabsState[id].formKeysData &&
|
tabsState[id].formKeysData &&
|
||||||
|
|
@ -277,10 +278,10 @@ export function buildTweakObject(tweak: tweakType) {
|
||||||
/**
|
/**
|
||||||
* Function to get Chat Input Field
|
* Function to get Chat Input Field
|
||||||
* @param {FlowType} flow - The current flow.
|
* @param {FlowType} flow - The current flow.
|
||||||
* @param {TabsState} tabsState - The current tabs state.
|
* @param {FlowsState} tabsState - The current tabs state.
|
||||||
* @returns {string} - The chat input field
|
* @returns {string} - The chat input field
|
||||||
*/
|
*/
|
||||||
export function getChatInputField(flow: FlowType, tabsState?: TabsState) {
|
export function getChatInputField(flow: FlowType, tabsState?: FlowsState) {
|
||||||
let chat_input_field = "text";
|
let chat_input_field = "text";
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
@ -305,7 +306,7 @@ export function getPythonApiCode(
|
||||||
flow: FlowType,
|
flow: FlowType,
|
||||||
isAuth: boolean,
|
isAuth: boolean,
|
||||||
tweak?: any[],
|
tweak?: any[],
|
||||||
tabsState?: TabsState
|
tabsState?: FlowsState
|
||||||
): string {
|
): string {
|
||||||
const flowId = flow.id;
|
const flowId = flow.id;
|
||||||
|
|
||||||
|
|
@ -369,7 +370,7 @@ export function getCurlCode(
|
||||||
flow: FlowType,
|
flow: FlowType,
|
||||||
isAuth: boolean,
|
isAuth: boolean,
|
||||||
tweak?: any[],
|
tweak?: any[],
|
||||||
tabsState?: TabsState
|
tabsState?: FlowsState
|
||||||
): string {
|
): string {
|
||||||
const flowId = flow.id;
|
const flowId = flow.id;
|
||||||
const tweaks = buildTweaks(flow);
|
const tweaks = buildTweaks(flow);
|
||||||
|
|
@ -397,7 +398,7 @@ export function getCurlCode(
|
||||||
export function getPythonCode(
|
export function getPythonCode(
|
||||||
flow: FlowType,
|
flow: FlowType,
|
||||||
tweak?: any[],
|
tweak?: any[],
|
||||||
tabsState?: TabsState
|
tabsState?: FlowsState
|
||||||
): string {
|
): string {
|
||||||
const flowName = flow.name;
|
const flowName = flow.name;
|
||||||
const tweaks = buildTweaks(flow);
|
const tweaks = buildTweaks(flow);
|
||||||
|
|
@ -422,7 +423,7 @@ flow(inputs)`;
|
||||||
export function getWidgetCode(
|
export function getWidgetCode(
|
||||||
flow: FlowType,
|
flow: FlowType,
|
||||||
isAuth: boolean,
|
isAuth: boolean,
|
||||||
tabsState?: TabsState
|
tabsState?: FlowsState
|
||||||
): string {
|
): string {
|
||||||
const flowId = flow.id;
|
const flowId = flow.id;
|
||||||
const flowName = flow.name;
|
const flowName = flow.name;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue