From c440edc53a446d849de8f9f4fa2e8ee7688ecd7e Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Thu, 9 May 2024 21:59:26 +0100 Subject: [PATCH] fix: prevent tasks linking to themselves A second go at fixing this, previously fixed in #5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself. This has to be edited in the editors for each individual task type, but I think I got them all. --- app/classifier/tasks/combo/editor.cjsx | 3 ++- app/classifier/tasks/dropdown/editor.jsx | 3 ++- app/classifier/tasks/generic-editor.cjsx | 5 +++-- app/classifier/tasks/next-task-selector.cjsx | 2 +- app/classifier/tasks/slider/editor.jsx | 3 ++- app/classifier/tasks/survey/editor.cjsx | 3 ++- app/classifier/tasks/text/editor.cjsx | 3 ++- app/classifier/tasks/textFromSubject/editor.jsx | 3 ++- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/classifier/tasks/combo/editor.cjsx b/app/classifier/tasks/combo/editor.cjsx index 323c43982f..5dd9082316 100644 --- a/app/classifier/tasks/combo/editor.cjsx +++ b/app/classifier/tasks/combo/editor.cjsx @@ -47,6 +47,7 @@ ComboTaskEditor = createReactClass render: -> + [root, taskKey] = @props.taskPrefix.split '.' tasks = require('..').default

Add any number of tasks here and they'll be shown in one step.

@@ -77,7 +78,7 @@ ComboTaskEditor = createReactClass


This overrides anything set by a sub-task. diff --git a/app/classifier/tasks/dropdown/editor.jsx b/app/classifier/tasks/dropdown/editor.jsx index d77bd47d8c..fcebbd77c3 100644 --- a/app/classifier/tasks/dropdown/editor.jsx +++ b/app/classifier/tasks/dropdown/editor.jsx @@ -120,6 +120,7 @@ export default class DropdownEditor extends React.Component { } render() { + const [root, taskKey] = this.props.taskPrefix.split('.'); const handleChange = handleInputChange.bind(this.props.workflow); const selects = this.props.task.selects; @@ -218,7 +219,7 @@ export default class DropdownEditor extends React.Component { Next task
+ [root, taskKey] = @props.taskPrefix.split '.' handleChange = handleInputChange.bind @props.workflow [mainTextKey, choicesKey] = switch @props.task.type @@ -130,7 +131,7 @@ module.exports = createReactClass

Next task{' '} - +
@@ -304,7 +305,7 @@ module.exports = createReactClass
Next task{' '} - +
}
diff --git a/app/classifier/tasks/next-task-selector.cjsx b/app/classifier/tasks/next-task-selector.cjsx index 796da49f88..76f54ce1d0 100644 --- a/app/classifier/tasks/next-task-selector.cjsx +++ b/app/classifier/tasks/next-task-selector.cjsx @@ -21,7 +21,7 @@ module.exports = createReactClass