Merge branch 'dev' into cz/fix-messages-deleting-error
This commit is contained in:
commit
f6ceb59b6f
10 changed files with 49 additions and 11 deletions
|
|
@ -26,6 +26,7 @@ import {
|
||||||
TabsTrigger,
|
TabsTrigger,
|
||||||
} from "../../components/ui/tabs";
|
} from "../../components/ui/tabs";
|
||||||
import { LANGFLOW_SUPPORTED_TYPES } from "../../constants/constants";
|
import { LANGFLOW_SUPPORTED_TYPES } from "../../constants/constants";
|
||||||
|
import getTabsOrder from "../../modals/apiModal/utils/get-tabs-order";
|
||||||
import { Case } from "../../shared/components/caseComponent";
|
import { Case } from "../../shared/components/caseComponent";
|
||||||
import { useDarkStore } from "../../stores/darkStore";
|
import { useDarkStore } from "../../stores/darkStore";
|
||||||
import useFlowStore from "../../stores/flowStore";
|
import useFlowStore from "../../stores/flowStore";
|
||||||
|
|
@ -56,6 +57,8 @@ export default function CodeTabsComponent({
|
||||||
setActiveTweaks,
|
setActiveTweaks,
|
||||||
activeTweaks,
|
activeTweaks,
|
||||||
allowExport = false,
|
allowExport = false,
|
||||||
|
isThereTweaks = false,
|
||||||
|
isThereWH = false,
|
||||||
}: codeTabsPropsType) {
|
}: codeTabsPropsType) {
|
||||||
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
||||||
const [data, setData] = useState(flow ? flow["data"]!["nodes"] : null);
|
const [data, setData] = useState(flow ? flow["data"]!["nodes"] : null);
|
||||||
|
|
@ -93,6 +96,8 @@ export default function CodeTabsComponent({
|
||||||
return node.data.node.template[templateParam].type;
|
return node.data.node.template[templateParam].type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tabsOrder = getTabsOrder(isThereWH, isThereTweaks);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
value={activeTab}
|
value={activeTab}
|
||||||
|
|
@ -172,7 +177,7 @@ export default function CodeTabsComponent({
|
||||||
className="api-modal-tabs-content overflow-hidden"
|
className="api-modal-tabs-content overflow-hidden"
|
||||||
key={idx} // Remember to add a unique key prop
|
key={idx} // Remember to add a unique key prop
|
||||||
>
|
>
|
||||||
{idx < 5 ? (
|
{tabsOrder[idx].toLowerCase() !== "tweaks" ? (
|
||||||
<div className="flex h-full w-full flex-col">
|
<div className="flex h-full w-full flex-col">
|
||||||
{tab.description && (
|
{tab.description && (
|
||||||
<div
|
<div
|
||||||
|
|
@ -188,7 +193,7 @@ export default function CodeTabsComponent({
|
||||||
{tab.code}
|
{tab.code}
|
||||||
</SyntaxHighlighter>
|
</SyntaxHighlighter>
|
||||||
</div>
|
</div>
|
||||||
) : idx === 5 ? (
|
) : tabsOrder[idx].toLowerCase() === "tweaks" ? (
|
||||||
<>
|
<>
|
||||||
<div className="api-modal-according-display">
|
<div className="api-modal-according-display">
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,14 @@ function DataOutputComponent({
|
||||||
columnMode = "union",
|
columnMode = "union",
|
||||||
}: {
|
}: {
|
||||||
pagination: boolean;
|
pagination: boolean;
|
||||||
rows: any;
|
rows: any[];
|
||||||
columnMode?: "intersection" | "union";
|
columnMode?: "intersection" | "union";
|
||||||
}) {
|
}) {
|
||||||
|
// If the rows are not an array of objects, convert them to an array of objects
|
||||||
|
if (rows.some((row) => typeof row !== "object")) {
|
||||||
|
rows = rows.map((row) => ({ data: row }));
|
||||||
|
}
|
||||||
|
|
||||||
const columns = extractColumnsFromRows(rows, columnMode);
|
const columns = extractColumnsFromRows(rows, columnMode);
|
||||||
|
|
||||||
const columnDefs = columns.map((col, idx) => ({
|
const columnDefs = columns.map((col, idx) => ({
|
||||||
|
|
|
||||||
|
|
@ -1124,5 +1124,8 @@ export async function deleteMessagesFn(ids: string[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateMessageApi(data: Message) {
|
export async function updateMessageApi(data: Message) {
|
||||||
return await api.post(`${BASE_URL_API}monitor/messages/${data.id}`, data);
|
if (data.files && typeof data.files === "string") {
|
||||||
|
data.files = JSON.parse(data.files);
|
||||||
|
}
|
||||||
|
return await api.put(`${BASE_URL_API}monitor/messages/${data.id}`, data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,12 @@ const ApiModal = forwardRef(
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
|
const tweaksCode = buildTweaks(flow);
|
||||||
const tweak = useTweaksStore((state) => state.tweak);
|
const tweak = useTweaksStore((state) => state.tweak);
|
||||||
const addTweaks = useTweaksStore((state) => state.setTweak);
|
const addTweaks = useTweaksStore((state) => state.setTweak);
|
||||||
const setTweaksList = useTweaksStore((state) => state.setTweaksList);
|
const setTweaksList = useTweaksStore((state) => state.setTweaksList);
|
||||||
const tweaksList = useTweaksStore((state) => state.tweaksList);
|
const tweaksList = useTweaksStore((state) => state.tweaksList);
|
||||||
|
const isThereTweaks = Object.keys(tweaksCode).length > 0;
|
||||||
const [activeTweaks, setActiveTweaks] = useState(false);
|
const [activeTweaks, setActiveTweaks] = useState(false);
|
||||||
const { autoLogin } = useContext(AuthContext);
|
const { autoLogin } = useContext(AuthContext);
|
||||||
const [open, setOpen] =
|
const [open, setOpen] =
|
||||||
|
|
@ -82,7 +83,6 @@ const ApiModal = forwardRef(
|
||||||
const pythonCode = getPythonCode(flow?.name, tweak);
|
const pythonCode = getPythonCode(flow?.name, tweak);
|
||||||
const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin);
|
const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin);
|
||||||
const includeWebhook = flow.webhook;
|
const includeWebhook = flow.webhook;
|
||||||
const tweaksCode = buildTweaks(flow);
|
|
||||||
const codesArray = [
|
const codesArray = [
|
||||||
runCurlCode,
|
runCurlCode,
|
||||||
webhookCurlCode,
|
webhookCurlCode,
|
||||||
|
|
@ -121,7 +121,7 @@ const ApiModal = forwardRef(
|
||||||
|
|
||||||
filterNodes();
|
filterNodes();
|
||||||
|
|
||||||
if (Object.keys(tweaksCode).length > 0) {
|
if (isThereTweaks) {
|
||||||
setActiveTab("0");
|
setActiveTab("0");
|
||||||
setTabs(createTabsArray(codesArray, includeWebhook, true));
|
setTabs(createTabsArray(codesArray, includeWebhook, true));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -215,7 +215,6 @@ const ApiModal = forwardRef(
|
||||||
);
|
);
|
||||||
const pythonCode = getPythonCode(flow?.name, cloneTweak);
|
const pythonCode = getPythonCode(flow?.name, cloneTweak);
|
||||||
const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin);
|
const widgetCode = getWidgetCode(flow?.id, flow?.name, autoLogin);
|
||||||
const isThereTweaks = Object.keys(tweaksCode).length > 0;
|
|
||||||
const codesObj = getCodesObj({
|
const codesObj = getCodesObj({
|
||||||
runCurlCode,
|
runCurlCode,
|
||||||
webhookCurlCode,
|
webhookCurlCode,
|
||||||
|
|
@ -251,6 +250,8 @@ const ApiModal = forwardRef(
|
||||||
</BaseModal.Header>
|
</BaseModal.Header>
|
||||||
<BaseModal.Content overflowHidden>
|
<BaseModal.Content overflowHidden>
|
||||||
<CodeTabsComponent
|
<CodeTabsComponent
|
||||||
|
isThereTweaks={isThereTweaks}
|
||||||
|
isThereWH={includeWebhook ?? false}
|
||||||
flow={flow}
|
flow={flow}
|
||||||
tabs={tabs!}
|
tabs={tabs!}
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
|
import { cloneDeep } from "lodash";
|
||||||
import { TABS_ORDER } from "../../../constants/constants";
|
import { TABS_ORDER } from "../../../constants/constants";
|
||||||
|
|
||||||
export default function getTabsOrder(
|
export default function getTabsOrder(
|
||||||
isThereWH: boolean = false,
|
isThereWH: boolean = false,
|
||||||
isThereTweaks: boolean = false,
|
isThereTweaks: boolean = false,
|
||||||
): string[] {
|
): string[] {
|
||||||
const defaultOrder = TABS_ORDER;
|
const defaultOrder = cloneDeep(TABS_ORDER);
|
||||||
if (isThereTweaks) {
|
if (isThereTweaks) {
|
||||||
defaultOrder.push("tweaks");
|
defaultOrder.push("tweaks");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,13 @@ export default function Page({
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCopy(e: KeyboardEvent) {
|
function handleCopy(e: KeyboardEvent) {
|
||||||
if (!isWrappedWithClass(e, "nocopy")) {
|
const multipleSelection = lastSelection?.nodes
|
||||||
|
? lastSelection?.nodes.length > 0
|
||||||
|
: false;
|
||||||
|
if (
|
||||||
|
!isWrappedWithClass(e, "nocopy") &&
|
||||||
|
(isWrappedWithClass(e, "react-flow__node") || multipleSelection)
|
||||||
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
(e as unknown as Event).stopImmediatePropagation();
|
(e as unknown as Event).stopImmediatePropagation();
|
||||||
if (window.getSelection()?.toString().length === 0 && lastSelection) {
|
if (window.getSelection()?.toString().length === 0 && lastSelection) {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import {
|
||||||
ColGroupDef,
|
ColGroupDef,
|
||||||
SelectionChangedEvent,
|
SelectionChangedEvent,
|
||||||
} from "ag-grid-community";
|
} from "ag-grid-community";
|
||||||
|
import { cloneDeep } from "lodash";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import TableComponent from "../../../../components/tableComponent";
|
import TableComponent from "../../../../components/tableComponent";
|
||||||
import useAlertStore from "../../../../stores/alertStore";
|
import useAlertStore from "../../../../stores/alertStore";
|
||||||
|
|
@ -37,7 +38,7 @@ export default function MessagesPage() {
|
||||||
function handleUpdateMessage(event: CellEditRequestEvent<any, string>) {
|
function handleUpdateMessage(event: CellEditRequestEvent<any, string>) {
|
||||||
const newValue = event.newValue;
|
const newValue = event.newValue;
|
||||||
const field = event.column.getColId();
|
const field = event.column.getColId();
|
||||||
const row = event.data;
|
const row = cloneDeep(event.data);
|
||||||
const data = {
|
const data = {
|
||||||
...row,
|
...row,
|
||||||
[field]: newValue,
|
[field]: newValue,
|
||||||
|
|
|
||||||
|
|
@ -695,6 +695,8 @@ type codeTabsFuncTempType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type codeTabsPropsType = {
|
export type codeTabsPropsType = {
|
||||||
|
isThereTweaks?: boolean;
|
||||||
|
isThereWH?: boolean;
|
||||||
flow?: FlowType;
|
flow?: FlowType;
|
||||||
tabs: Array<tabsArrayType>;
|
tabs: Array<tabsArrayType>;
|
||||||
activeTab: string;
|
activeTab: string;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ type Message = {
|
||||||
sender_name: string;
|
sender_name: string;
|
||||||
session_id: string;
|
session_id: string;
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
|
files: Array<string>;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1117,6 +1117,18 @@ export function updateProxyIdsOnTemplate(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateProxyIdsOnOutputs(
|
||||||
|
outputs: OutputFieldType[] | undefined,
|
||||||
|
idsMap: { [key: string]: string },
|
||||||
|
) {
|
||||||
|
if (!outputs) return;
|
||||||
|
outputs.forEach((output) => {
|
||||||
|
if (output.proxy && idsMap[output.proxy.id]) {
|
||||||
|
output.proxy.id = idsMap[output.proxy.id];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function updateEdgesIds(
|
export function updateEdgesIds(
|
||||||
edges: Edge[],
|
edges: Edge[],
|
||||||
idsMap: { [key: string]: string },
|
idsMap: { [key: string]: string },
|
||||||
|
|
@ -1485,6 +1497,7 @@ export function updateGroupRecursion(groupNode: NodeType, edges: Edge[]) {
|
||||||
let newFlow = groupNode.data.node!.flow;
|
let newFlow = groupNode.data.node!.flow;
|
||||||
const idsMap = updateIds(newFlow.data!);
|
const idsMap = updateIds(newFlow.data!);
|
||||||
updateProxyIdsOnTemplate(groupNode.data.node!.template, idsMap);
|
updateProxyIdsOnTemplate(groupNode.data.node!.template, idsMap);
|
||||||
|
updateProxyIdsOnOutputs(groupNode.data.node.outputs, idsMap);
|
||||||
let flowEdges = edges;
|
let flowEdges = edges;
|
||||||
updateEdgesIds(flowEdges, idsMap);
|
updateEdgesIds(flowEdges, idsMap);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue