Skip to content
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

"Fix" prefill copy button #4902

Merged
merged 4 commits into from
Dec 11, 2024
Merged

Conversation

sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented Dec 11, 2024

Closes #4859

Changes

  • Moved the dependent-fields reset from a side-effect handler to the actual onChange handler. This makes is possible for proper programmatic changes to be done while keeping the reset behaviour when the end-user changes API groups and/or object types
  • Ensured that the copy-prefill-from-registration-config controls are only displayed when there are actual backends available to copy from
  • Refactored/cleaned up some state handling/API

This affects the Objects API registration a bit with a behaviour change, but makes it consistent in the sense that form state is not reset anymore when upstream APIs are not available, for example, making it consistent with the behaviour of the ZGW API's configuration. Previously, the first available item in a dropdown was selected, but this is not needed anymore now that we're using react-select.

Checklist

Check off the items that are completed or not relevant.

  • Impact on features

    • Checked copying a form
    • Checked import/export of a form
    • Config checks in the configuration overview admin page
    • Problem detection in the admin email digest is handled
  • Release management

    • I have labelled the PR as "needs-backport" accordingly
  • I have updated the translations assets (you do NOT need to provide translations)

    • Ran ./bin/makemessages_js.sh
    • Ran ./bin/compilemessages_js.sh
  • Commit hygiene

    • Commit messages refer to the relevant Github issue
    • Commit messages explain the "why" of change, not the how

It's obsolete now we're using react-select. The react-select component
does accurately reflect the state of option selection, even if no
value is selected while leaving the select blank is not allowed.
Handling the reset of dependent fields in the ObjectTypeSelect
component is too naive - there's no guarantee that the fields must
always be reset, for example with the copy-config-from-registration
button. Clicking that button updates a bunch of form state at once,
and it already manages the dependent fields.

So, providing a callback to handle the reset allows us to handle the
dependent fields still, while having to option to incorporate extra
context.
The toggle is not displayed if there are no backends to copy from, so
the UI can be de-cluttered.

Additionally, the mechanism/slot for the extra controls has been
refactored to be more generic - anything can now be rendered there that
may be relevant, and the state is specific to the UI being rendered so
that has been removed from the generic parent component.

We use the formik status to track form-specific state, through a small
hook that normalizes the shape of the status (since it can be anything).
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.62%. Comparing base (81094f7) to head (7291cfa).
Report is 23 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4902      +/-   ##
==========================================
- Coverage   96.62%   96.62%   -0.01%     
==========================================
  Files         757      757              
  Lines       25952    25942      -10     
  Branches     3420     3417       -3     
==========================================
- Hits        25076    25066      -10     
  Misses        613      613              
  Partials      263      263              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@vaszig vaszig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have something to mention. Clear and nice addition of the onObjectTypeChange!

@sergei-maertens sergei-maertens merged commit 895b800 into master Dec 11, 2024
34 checks passed
@sergei-maertens sergei-maertens deleted the issue/4859-prefill-copy-button branch December 11, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Objects API prefill configuration copy button doesn't work
2 participants