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); 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) { if (workflowExecutions.length > 0) {
for (let [key, keyval] of Object.entries(workflowExecutions)) { for (let execution of workflowExecutions) {
const execArg = workflowExecutions[key].execution_argument; const execArg = execution.execution_argument;
if (execArg && execArg.length > 0) { if (execArg && execArg.length > 0) {
const valid = validateJson(execArg); const valid = validateJson(execArg);
if (valid.valid) { if (valid.valid) {
actionlist.push({ newActionList.push({
type: "Execution Argument", type: "Execution Argument",
name: "Execution Argument", name: "Execution Argument",
value: "$exec", value: "$exec",
@@ -464,8 +471,9 @@ const ParsedAction = (props) => {
} }
} }
if (actionlist.length === 0) { // Add default Execution Argument if none were added
actionlist.push({ if (newActionList.length === 0) {
newActionList.push({
type: "Execution Argument", type: "Execution Argument",
name: "Execution Argument", name: "Execution Argument",
value: "$exec", value: "$exec",
@@ -473,7 +481,6 @@ const ParsedAction = (props) => {
autocomplete: "exec", autocomplete: "exec",
example: "", example: "",
}); });
}
let cacheKey = { let cacheKey = {
type: "Shuffle DB", 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) { if (workflow.workflow_variables?.length > 0) {
for (let [key, keyval] of Object.entries(workflow.workflow_variables)) { for (let variable of workflow.workflow_variables) {
const item = workflow.workflow_variables[key]; newActionList.push({
actionlist.push({
type: "workflow_variable", type: "workflow_variable",
name: item.name, name: variable.name,
value: item.value, value: variable.value,
id: item.id, id: variable.id,
autocomplete: item.name.split(" ").join("_"), autocomplete: variable.name.split(" ").join("_"),
example: item.value, example: variable.value,
}); });
} }
} }
// Process execution variables
if (workflow.execution_variables?.length > 0) { if (workflow.execution_variables?.length > 0) {
for (let [key, keyval] of Object.entries(workflow.execution_variables)) { for (let variable of workflow.execution_variables) {
const item = workflow.execution_variables[key];
let exampleOutput = ""; let exampleOutput = "";
for (let exec of workflowExecutions) { 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) { if (foundExec?.value) {
exampleOutput = foundExec.value; exampleOutput = foundExec.value;
break; break;
} }
} }
actionlist.push({ newActionList.push({
type: "execution_variable", type: "execution_variable",
name: item.name, name: variable.name,
value: item.value, value: variable.value,
id: item.id, id: variable.id,
autocomplete: item.name.split(" ").join("_"), autocomplete: variable.name.split(" ").join("_"),
example: exampleOutput, example: exampleOutput,
}); });
} }
} }
// Process parent actions if getParents is provided
if (getParents) { if (getParents) {
const parents = getParents(selectedAction); const parents = getParents(selectedAction);
if (parents.length > 1) { if (parents.length > 1) {
@@ -555,7 +564,7 @@ const ParsedAction = (props) => {
} }
} }
} }
actionlist.push({ newActionList.push({
type: "action", type: "action",
id: parentNode.id, id: parentNode.id,
name: parentNode.label, name: parentNode.label,
@@ -567,11 +576,10 @@ const ParsedAction = (props) => {
} }
} }
setActionlist(actionlist); // Update the actionlist state
} setActionlist(newActionList);
}, }, [workflow.execution_variables, workflow.workflow_variables, workflowExecutions, workflow, selectedAction, listCache, getParents]);
[selectedAction,selectedApp,setNewSelectedAction,workflow, workflowExecutions, getParents]
);
useEffect(() => { useEffect(() => {
selectedNameChange(appActionName) selectedNameChange(appActionName)
actionDelayChange(delay) actionDelayChange(delay)