-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(classifier): make task.required a boolean #6094
base: master
Are you sure you want to change the base?
refactor(classifier): make task.required a boolean #6094
Conversation
@@ -6,10 +6,22 @@ const Task = types.model('Task', { | |||
// override annotation in individual task models with specific annotation types | |||
annotation: types.safeReference(Annotation), | |||
taskKey: types.identifier, | |||
required: types.maybe(types.union(types.string, types.boolean)), // text task required default = false | |||
required: types.optional(types.boolean, false), // text task required default = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone remember what the comment means here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned in a PR description here: #1768 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That bug (the project builder stringifying everything) was fixed a long time ago, so the comment can be deleted.
be8797c
to
fca9cc2
Compare
fca9cc2
to
0b28270
Compare
0b28270
to
9603648
Compare
|
@@ -22,22 +22,22 @@ describe('Model > DrawingTools > Tool', function () { | |||
{ | |||
type: 'multiple', | |||
answers: ['apples', 'oranges', 'pears'], | |||
required: '', | |||
required: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back in 2020, the project builder had a bug that converted all values to strings, including booleans from checkboxes. That was fixed a while ago. Checkboxes should be saved as true/false now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the PR that fixed handleInputChange
in the project builder, so checkboxes have been fixed since October 2020.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't all other files (Mark.spec, DrawingTask.spec, Task.spec, TextTask.spec, AnnotationStore.spec, etc) be updated to required: false
in this PR too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is agnostic about whether Panoptes stored task.required
as a string or a boolean, so mocks can use either and should still be represented internally as booleans in the classifier (via the snapshot preprocessor.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the tests here, where the tests expected task.required
to be an empty string. Otherwise, they should be unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't all other files (Mark.spec, DrawingTask.spec, Task.spec, TextTask.spec, AnnotationStore.spec, etc) be updated to required: false in this PR too?
That's a good question. I'd say not in this PR, since the tests are passing and a refactor must not change public tested behaviour, but maybe those mocks could be updated as maintenance for the classifier package? Those mocks mirror how the project builder behaved when they were written (five years ago, maybe?) Since then, bugs in the project builder have been fixed, and the new editor has been written. The mocks are now out of step with the tasks and steps that are created by current project builder code, but do reflect legacy workflows that were created by buggy code and may still exist in Panoptes.
Depending on how old live projects are, the mocks might need to reflect both the state of the project builder now, and the state of the project builder five years ago, in order to catch regressions that break backwards compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is also an argument for breaking tasks out into their own NPM package, so that the project builder can import and use them along with the classifier. At the moment, task code is being edited in at least three places: the old PFE workflow editor, the new Pages Editor, and the task models here in the monorepo.
bc94077
to
692b35c
Compare
Remove `types.string` from `task.required`. Fixes a small bug where a task with `required: 'false'` would be required. String values are now coerced to booleans in a snapshot preprocessor.
Tests should only be updated where they're failing on this branch.
692b35c
to
3a1b004
Compare
Remove
types.string
fromtask.required
. Fixes a small bug where a task withrequired: 'false'
would be required. String values are now coerced to booleans in a snapshot preprocessor.Please request review from
@zooniverse/frontend
team or an individual member of that team.Package
Linked Issue and/or Talk Post
How to Review
This shouldn't change any live projects. The project builder nowadays should be saving
task.required
as a boolean, so the string type was only needed for very old workflows. You could deliberately create a workflow task withrequired: 'false'
, with an API client, but I've added tests to verify that legacy string values are handled correctly now.Checklist
PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.
General
yarn panic && yarn bootstrap
ordocker-compose up --build
and FEM works as expectedGeneral UX
Example Staging Project: i-fancy-cats
Refactoring