Fixed the actionlist exec arg issue

This commit is contained in:
monilprajapati
2024-06-18 21:00:07 +05:30
parent 399e1c1650
commit 34e5913bfa
+39 -31
View File
@@ -442,15 +442,22 @@ const ParsedAction = (props) => {
setSelectedVariableParameter(workflow.workflow_variables[0].name);
}
// Initialize action list if it is empty
if (actionlist.length === 0) {
},
[selectedAction,selectedApp,setNewSelectedAction,workflow, workflowExecutions, getParents]
);
useEffect(() => {
const newActionList = [];
// Process workflowExecutions
if (workflowExecutions.length > 0) {
for (let [key, keyval] of Object.entries(workflowExecutions)) {
const execArg = workflowExecutions[key].execution_argument;
for (let execution of workflowExecutions) {
const execArg = execution.execution_argument;
if (execArg && execArg.length > 0) {
const valid = validateJson(execArg);
if (valid.valid) {
actionlist.push({
newActionList.push({
type: "Execution Argument",
name: "Execution Argument",
value: "$exec",
@@ -464,8 +471,9 @@ const ParsedAction = (props) => {
}
}
if (actionlist.length === 0) {
actionlist.push({
// Add default Execution Argument if none were added
if (newActionList.length === 0) {
newActionList.push({
type: "Execution Argument",
name: "Execution Argument",
value: "$exec",
@@ -473,7 +481,6 @@ const ParsedAction = (props) => {
autocomplete: "exec",
example: "",
});
}
let cacheKey = {
type: "Shuffle DB",
@@ -497,44 +504,46 @@ const ParsedAction = (props) => {
}
}
actionlist.push(cacheKey);
newActionList.push(cacheKey);
}
// Process workflow variables
if (workflow.workflow_variables?.length > 0) {
for (let [key, keyval] of Object.entries(workflow.workflow_variables)) {
const item = workflow.workflow_variables[key];
actionlist.push({
for (let variable of workflow.workflow_variables) {
newActionList.push({
type: "workflow_variable",
name: item.name,
value: item.value,
id: item.id,
autocomplete: item.name.split(" ").join("_"),
example: item.value,
name: variable.name,
value: variable.value,
id: variable.id,
autocomplete: variable.name.split(" ").join("_"),
example: variable.value,
});
}
}
// Process execution variables
if (workflow.execution_variables?.length > 0) {
for (let [key, keyval] of Object.entries(workflow.execution_variables)) {
const item = workflow.execution_variables[key];
for (let variable of workflow.execution_variables) {
let exampleOutput = "";
for (let exec of workflowExecutions) {
const foundExec = exec.execution_variables?.find(exvar => exvar.name === item.name);
const foundExec = exec.execution_variables?.find(exvar => exvar.name === variable.name);
if (foundExec?.value) {
exampleOutput = foundExec.value;
break;
}
}
actionlist.push({
newActionList.push({
type: "execution_variable",
name: item.name,
value: item.value,
id: item.id,
autocomplete: item.name.split(" ").join("_"),
name: variable.name,
value: variable.value,
id: variable.id,
autocomplete: variable.name.split(" ").join("_"),
example: exampleOutput,
});
}
}
// Process parent actions if getParents is provided
if (getParents) {
const parents = getParents(selectedAction);
if (parents.length > 1) {
@@ -555,7 +564,7 @@ const ParsedAction = (props) => {
}
}
}
actionlist.push({
newActionList.push({
type: "action",
id: parentNode.id,
name: parentNode.label,
@@ -567,11 +576,10 @@ const ParsedAction = (props) => {
}
}
setActionlist(actionlist);
}
},
[selectedAction,selectedApp,setNewSelectedAction,workflow, workflowExecutions, getParents]
);
// Update the actionlist state
setActionlist(newActionList);
}, [workflow.execution_variables, workflow.workflow_variables, workflowExecutions, workflow, selectedAction, listCache, getParents]);
useEffect(() => {
selectedNameChange(appActionName)
actionDelayChange(delay)