-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Publisher][Bug] Remove additional context logic from FormStore and DataEntryFormComponents #1341
[Publisher][Bug] Remove additional context logic from FormStore and DataEntryFormComponents #1341
Conversation
… in Metric Settings by MetricConfigStore
5c4dad1
to
542d933
Compare
@@ -158,68 +157,3 @@ export const DisaggregationDimensionTextInput = observer( | |||
); | |||
} | |||
); | |||
|
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 entire component is not being used anywhere.
expect( | ||
rootStore.formStore.metricsValues[0].PROSECUTION_STAFF.error?.message | ||
).toBe("You are also required to enter a value for this field."); | ||
}); |
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.
Test no longer necessary as there are no context fields in the record pages.
).toEqual("100"); | ||
|
||
expect.hasAssertions(); | ||
}); |
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.
FormStore no longer needs to worry about the contexts, and as a result, updateContextValue
will be deprecated.
metric.enabled | ||
); | ||
} | ||
}); |
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.
No contexts in the record page means we don't have to loop through them and update/validate their values.
), | ||
error: contextError, | ||
}; | ||
}), |
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.
All of this logic is unnecessary since we are deprecating updateContextValue
and have no interest in the values of the context in the record page.
key: context.key, | ||
value: contextValue, | ||
}); | ||
}); |
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.
Cleaning up anywhere else that has context logic.
contextKey | ||
); | ||
} | ||
}; |
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.
And finally - since we have no interest in anything context-related in the record page, we can safely deprecate this method and all of its dependants.
@mxosman successfully triggered a playtest deployment. Full deployment usually takes 5 minutes. Your playtest link is https://mahmoudtest---publisher-web-b47yvyxs3q-uc.a.run.app/ |
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.
Thank you so much for digging into this so deeply, figuring out the best fix, and testing so thoroughly!
Description of the change
Remove additional context logic from FormStore and DataEntryFormComponents as contexts are no longer handled by the record page.
There was a bug reported in staging for agency 11 where opening up a monthly record resulted in a crash. The crash was a result of the record page validation of previously saved inputs attempting to delete an error on the
metricsValues
object (in the FormStore - this object keeps track of the metric values and error state for each metric value) for a metric that did not exist in this object.How is this happening?
I'm not entirely sure when this happened or if it's always been this way, but it appears that when you add a value to the additional context field in the Metric Settings definition for a top-level metric, save it, and then delete the value and save it (so an empty string is saved) -- the empty string slips through this check here, and gets unnecessarily validated through
this.updateContextValue
:justice-counts/publisher/src/stores/FormStore.ts
Lines 87 to 88 in c7bea89
It's still unclear whether this bug was here the entire time, or whether there was a relatively recent change in how empty string contexts are saved and later retrieved from the BE. But, I think the right move here would be to avoid running unnecessary logic for contexts in the FormStore and record page all together because they are not used in any way on the record page as they now live within the Metric Settings definitions and are handled by the
MetricConfigStore
.Steps to repro:
git switch e695ea5cda6c015e5982f86853cbd579b74e061c --detach
TypeError: Cannot read properties of undefined (reading 'SUPERVISION_FUNDING') at updateFieldErrorMessage (FormStore.ts:341:1)
I tested this using the agencies in our playbook, going through the repro steps and ensuring there are no issues in the record page, going through and adding data to the records, reloading, and publishing, and really any areas that involve the FormStore.
Type of change
Related issues
Closes Recidiviz/recidiviz-data#28666
Checklists
Development
This box MUST be checked by the submitter prior to merging:
These boxes should be checked by the submitter prior to merging:
Code review
These boxes should be checked by reviewers prior to merging: