Skip to content

Commit

Permalink
Ensure 'taskGroup' is always defined when fetching scopes for submitt…
Browse files Browse the repository at this point in the history
…ing 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 mozilla/translations#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.
  • Loading branch information
bhearsum committed Mar 20, 2024
1 parent cd55492 commit 201aa4e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ui/src/views/Tasks/submitTaskAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ 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);
Expand Down

0 comments on commit 201aa4e

Please sign in to comment.