From 180fa3114d65053340cee19194bb2f87621bd012 Mon Sep 17 00:00:00 2001 From: Ben Hearsum Date: Wed, 20 Mar 2024 10:17:56 -0400 Subject: [PATCH] Ensure 'taskGroup' is always defined when fetching scopes for submitting an action task. This is in support of making actions like "Cancel All" work on task groups that have been created by an Action Task (see https://github.com/mozilla/firefox-translations-training/issues/250). In an ideal world I'd like to understanding how `task.decisionTask` fits into things a bit more, and see if it could be removed...but that's more work than I'm willing to put in at the moment. I think this is a fairly safe fix to take in the meantime. --- changelog/N39Wr4udTH-1jL1N6rTggw.md | 5 +++++ ui/src/views/Tasks/submitTaskAction.js | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 changelog/N39Wr4udTH-1jL1N6rTggw.md diff --git a/changelog/N39Wr4udTH-1jL1N6rTggw.md b/changelog/N39Wr4udTH-1jL1N6rTggw.md new file mode 100644 index 00000000000..fb9f936da44 --- /dev/null +++ b/changelog/N39Wr4udTH-1jL1N6rTggw.md @@ -0,0 +1,5 @@ +audience: users +level: patch +--- + +Action tasks now work correctly for task groups created by another action task. diff --git a/ui/src/views/Tasks/submitTaskAction.js b/ui/src/views/Tasks/submitTaskAction.js index 05f01e885cd..4b61c90d128 100644 --- a/ui/src/views/Tasks/submitTaskAction.js +++ b/ui/src/views/Tasks/submitTaskAction.js @@ -13,7 +13,19 @@ import ajv from '../../utils/ajv'; export default async ({ task, form, action, apolloClient, taskActions }) => { const actions = removeKeys(cloneDeep(taskActions), ['__typename']); - const taskGroup = task.taskId === task.taskGroupId ? task : task.decisionTask; + // We need to source scopes from somewhere. Typically these come from the + // task we're given, which is either a regular decision task or an action + // task. Decision tasks are easily identified, because their taskId matches + // the taskGroupId that they are in. Action tasks do not have such a + // mapping. Instead, we're simply going to try our best by falling back to + // `task` if `task.decisionTask` is null or undefined. At the time of + // writing, it's not clear whether the `task.decisionTask` case is even + // valid anymore, but it's being kept for the time being because verifying + // that is not a trivial matter. + const taskGroup = + task.taskId === task.taskGroupId || !task.decisionTask + ? task + : task.decisionTask; const input = load(form); const validate = ajv.compile(action.schema || {}); const valid = validate(input);