-
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
ERA-7995: Migrate existing report form body into new report UI #805
Conversation
Looking so good!! The checkboxes look great! A few comments that may need to be separated out to other tickets but all related:
Totally open to discussing the changes we want to make and when @JoshuaVulcan @luixlive |
I think it makes sense to work those things in this same ticket. I'd just like to mention that the form is rendered by an external library we use: https://react-jsonschema-form.readthedocs.io/en/latest/ But what we do is to overwrite their styles to give it the ER touch. However, I've faced a couple things that are really tricky to do because of the way they render the DOM nodes and the classes they use. If I find myself in a scenario like that while doing these changes I'll let you know @tiffanynwong 😬 |
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.
Arrays need a little love, checkboxes look AMAZING, lots of surface area touched here and it seems to work quite well. I appreciate the error handling for failed schemas, where the form is rendered sans-body instead of leaving you in loading spinner hell.
I have a few questions about code style and test approach, but it's looking really good. V close to shippable.
@@ -7,6 +7,10 @@ | |||
"dependencies": { | |||
"@fortawesome/fontawesome-svg-core": "^1.2.26", | |||
"@fortawesome/free-solid-svg-icons": "^5.12.0", | |||
"@rjsf/bootstrap-4": "^5.0.0-beta.13", | |||
"@rjsf/core": "^5.0.0-beta.13", |
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 this mean we can remove react-jsonschema-form-bs4
? I'd love to ditch that old stinky fork
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.
Ahh, after we ditch the modals. Cool.
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.
It's removed now. Doesnt' make sense to keep our users waiting if we can deliver upgraded / better-looking forms now 😄
@@ -231,6 +233,21 @@ const ReportDetailView = ({ | |||
reportTracker.track('Change Report Location'); | |||
}, [reportForm, reportTracker]); | |||
|
|||
const onJsonFormChange = useCallback((event) => { |
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.
Any reason to surface jsonForm
instead of just form
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.
Answering all those comments here: It's simply me being over-descriptive. I'll remove the json
prefix.
const onJsonFormChange = useCallback((event) => { | ||
setReportForm({ ...reportForm, event_details: { ...reportForm.event_details, ...event.formData } }); | ||
|
||
reportTracker.track('Change Report Json Form Data'); |
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.
Similar to ^above, why would our analytics care that the form is json? Wouldn't "Change report form data" be more human-friendly and meaningful?
reportTracker.track('Change Report Json Form Data'); | ||
}, [reportForm, reportTracker]); | ||
|
||
const onJsonFormError = (errors) => { |
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.
onFormError
....
jsonFormUISchema, | ||
onJsonFormChange, | ||
onJsonFormError, | ||
onJsonFormSubmit, |
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.
onFormSubmit
const DetailsSection = ({ | ||
jsonFormSchema, | ||
jsonFormUISchema, | ||
onJsonFormChange, |
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.
onFormChange
jsonFormSchema, | ||
jsonFormUISchema, | ||
onJsonFormChange, | ||
onJsonFormError, |
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.
onFormError
src/ReportManager/index.test.js
Outdated
|
||
beforeEach(() => { | ||
AddReportMock = jest.fn(() => null); | ||
AddReport.mockImplementation(AddReportMock); | ||
fetchEventTypeSchemaMock = jest.fn(() => () => {}); |
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.
Didn't we agree to start using msw
for API interactions, instead of stubbing the fetch functions?
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.
Ohh, it's the habit
|
||
const uiOptions = getUiOptions(uiSchema); | ||
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions); | ||
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions); |
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.
Interesting new pattern on rsjf
's part
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.
Your comment reminds me that I simply removed the old code and that probably broke the modals forms 😅 I'll have to add the feature flag check in 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.
No longer needed, I removed the old version of the library. Now even the modals are using these new forms 👍
@JoshuaVulcan @gaboDev @Alcoto95 this is ready for a review 👍 |
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.
@JoshuaVulcan Totally, I like that idea. However, should we use our current spinner? I don't think it matches the beauty of our new form 😂 Maybe @tiffanynwong could help with a new icon / design for the "form loader"? |
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.
LGTM now
We have a this spinner that is displayed when the report list takes time to load. Spoke to Ludwig and agree it could use fixing but we should keep our spinners consistent so if we change it here it should change in the report list as well. If we're going to tidy up the spinner. Can we use a circular indeterminate spinner like this? https://mui.com/material-ui/react-progress/ And also change the color to bright blue #0056C7. Here's an example https://www.figma.com/file/1u3VbK9kbOEuUg9Wi8AHRW/Patrol-%26-Report-UI-Refresh-FINAL?node-id=2964%3A25128&t=JWUQGpSKERPdwnVm-1 Using a skeleton would be really cool but probably not worth the effort for the impact. https://mui.com/material-ui/react-skeleton/ |
@tiffanynwong actually updating the current loader would take way more time than I expected. I did the change in the form loader: But doing it in every other spinner in the app would require a lot of effort. Should I keep the new design in the report's form? |
I pulled the "Arrest with array" event type from develop and put it in your feature environment, you can repro there. |
Yes, please do keep the new spinner in the report form, it looks much better |
Can you check to make sure the blue is the same blue as the save button please :D |
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.
LGTM 🎉 😄
|
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.
see above comment. This is getting suuuper close to being ready!
@JoshuaVulcan thanks! I didn't notice the warnings. I'll work on these things. I could add the error message if it's trivial. But if we require designs again, maybe I agree that we already loaded this task with a lot of stuff. We would require a third QA pass. |
@JoshuaVulcan about the warnings: 1- The first one you mention, a button being inside a button, was not injected in this PR and seems like a rendering issue in the 2- You didn't mention one about |
Ticket: https://allenai.atlassian.net/browse/ERA-7995
Env: https://era-7995.pamdas.org/
Figma: https://www.figma.com/file/1u3VbK9kbOEuUg9Wi8AHRW/Patrol-%26-Report-UI-Refresh-FINAL?node-id=1039%3A8672
Evidence
Desktop:
Mobile:
Notes
As a good boy scout, I took the time not to simply copy and paste our existing React JSON schema form implementation, but to update it to the latest version (I left the existing form in the modals as it was so we will be able to remove the old version of the library once we remove that). Now, as part of this new implementation, I followed the migration process, got rid of unnecessary old props and updated the styles. However, there are some form fields I don't know how to test that I see have some custom styles. @JoshuaVulcan could you help me explaining how to create a custom schema with all those advanced fields to see what styles do they need?