Fixed the paramChange Issue and finally done with the rendering issue of Subflow

This commit is contained in:
monilprajapati
2024-07-17 15:14:03 +05:30
parent 6c593f2ed4
commit 0c035b6ac7
2 changed files with 68 additions and 61 deletions
+46 -8
View File
@@ -109,6 +109,7 @@ const CodeEditor = (props) => {
setActiveDialog,
fieldname,
contentLoading,
selectedTrigger,
} = props
const [localcodedata, setlocalcodedata] = React.useState(codedata === undefined || codedata === null || codedata.length === 0 ? "" : codedata);
@@ -436,7 +437,8 @@ const CodeEditor = (props) => {
}
const autoFormat = (input) => {
// Check if it's default too
if(selectedAction && selectedAction.parameters && selectedAction.parameters.length > 0){
// Check if it's default too
if (validation !== true) {
// Should try to automatically fix this input
@@ -475,6 +477,48 @@ const CodeEditor = (props) => {
if (input !== localcodedata) {
setlocalcodedata(input)
}
}
if(selectedTrigger && selectedTrigger.parameters && selectedTrigger.parameters.length > 0){
if (validation !== true) {
// Should try to automatically fix this input
console.log("Running AI input fixer")
if (aiSubmit !== undefined && parameterName !== undefined && selectedTrigger !== undefined) {
// Should remove params from selectedAction that aren't parameterName
var tmpAction = JSON.parse(JSON.stringify(selectedTrigger))
var tmpParams = selectedTrigger.parameters.filter((param) => param.name === parameterName)
var aiMsg = `Make it valid for trigger ${tmpAction.label} with parameter ${parameterName}: `
if (tmpParams.length > 0) {
aiMsg += tmpParams[0].value
}
if (localcodedata.startsWith("//")) {
aiMsg = localcodedata
}
tmpAction.parameters = tmpParams
console.log("Parameters: ", tmpParams.length)
aiSubmit(aiMsg, tmpAction)
}
return
}
try {
input = JSON.stringify(JSON.parse(input), null, 4)
} catch (e) {
console.log("Failed magic JSON stringification: ", e)
}
if (input !== localcodedata) {
setlocalcodedata(input)
}
}
}
const findIndex = (line, loc) => {
@@ -1767,7 +1811,6 @@ const CodeEditor = (props) => {
// This is to make it so we don't need to handle these fixes on the
// backend by itself
var fixedcodedata = localcodedata
console.log("Fixedcodedata: ", fixedcodedata)
const valid = validateJson(localcodedata, true)
if (valid.valid) {
fixedcodedata = JSON.stringify(valid.result, null, 2)
@@ -1780,11 +1823,6 @@ const CodeEditor = (props) => {
setcodedata(fixedcodedata);
setExpansionModalOpen(false)
} else if (changeActionParameterCodeMirror !== undefined) {
console.log("Entering in Submit onCLick")
console.log("Data passing to chnageActionParameterCodeMirror: ", fixedcodedata)
console.log("Fieldcount: ", fieldCount)
console.log("Actionlist: ", actionlist)
console.log("Event: ", event)
//changeActionParameterCodeMirror(event, fieldCount, fixedcodedata)
changeActionParameterCodeMirror(event, fieldCount, fixedcodedata, actionlist)
setExpansionModalOpen(false)
@@ -1808,4 +1846,4 @@ const CodeEditor = (props) => {
</Dialog>)
}
export default CodeEditor;
export default CodeEditor;