From be8cae012287f239fb537d1d332418422cbe8e9a Mon Sep 17 00:00:00 2001 From: "Shaun A. Noordin" Date: Tue, 7 May 2024 01:05:47 +0100 Subject: [PATCH] TasksPage: adding/moving/deleting pages triggers linear workflow rules --- .../components/TasksPage/TasksPage.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx b/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx index e146613d48..1c3cf3eac1 100644 --- a/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx +++ b/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx @@ -5,6 +5,7 @@ import createStep from '../../helpers/createStep.js'; import createTask from '../../helpers/createTask.js'; import getNewStepKey from '../../helpers/getNewStepKey.js'; import getNewTaskKey from '../../helpers/getNewTaskKey.js'; +import linkStepsInWorkflow from '../../helpers/linkStepsInWorkflow.js'; import moveItemInArray from '../../helpers/moveItemInArray.js'; import cleanupTasksAndSteps from '../../helpers/cleanupTasksAndSteps.js'; // import strings from '../../strings.json'; // TODO: move all text into strings @@ -40,7 +41,7 @@ export default function TasksPage() { if (!workflow) return; const newTaskKey = getNewTaskKey(workflow.tasks); const newTask = createTask(taskType); - const steps = workflow.steps?.slice() || []; + let steps = workflow.steps?.slice() || []; let step if (stepIndex < 0) { @@ -70,6 +71,10 @@ export default function TasksPage() { [newTaskKey]: newTask }; + if (linkStepsInWorkflow) { + steps = linkStepsInWorkflow(steps, tasks); + } + await update({ tasks, steps }); return (stepIndex < 0) ? steps.length - 1 : stepIndex; } @@ -125,7 +130,10 @@ export default function TasksPage() { const oldSteps = workflow.steps || []; if (from < 0 || to < 0 || from >= oldSteps.length || to >= oldSteps.length) return; - const steps = moveItemInArray(oldSteps, from, to); + let steps = moveItemInArray(oldSteps, from, to); + if (linkStepsInWorkflow) { + steps = linkStepsInWorkflow(steps, workflow.tasks); + } update({ steps }); } @@ -142,6 +150,9 @@ export default function TasksPage() { // cleanedupTasksAndSteps() will also remove tasks not associated with any step. const cleanedTasksAndSteps = cleanupTasksAndSteps(newTasks, newSteps); + if (linkStepsInWorkflow) { + cleanedTasksAndSteps.steps = linkStepsInWorkflow(cleanedTasksAndSteps.steps, cleanedTasksAndSteps.tasks); + } update(cleanedTasksAndSteps); }