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

✨ [#4608] Modal for Objects API prefill options #4610

Merged
merged 20 commits into from
Oct 8, 2024

Conversation

stevenbal
Copy link
Contributor

@stevenbal stevenbal commented Aug 20, 2024

Closes #4608

Changes

  • Modal for Objects API prefill options

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

@stevenbal stevenbal marked this pull request as draft August 20, 2024 11:31
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@1db0d0d). Learn more about missing BASE report.
Report is 714 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4610   +/-   ##
=========================================
  Coverage          ?   96.56%           
=========================================
  Files             ?      746           
  Lines             ?    25184           
  Branches          ?     3312           
=========================================
  Hits              ?    24319           
  Misses            ?      601           
  Partials          ?      264           

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

@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch 7 times, most recently from c2bba39 to 9424c20 Compare August 27, 2024 13:04
@stevenbal
Copy link
Contributor Author

Currently looks like this:
image

@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch from 5e67b5b to 17f010b Compare September 17, 2024 10:35
@stevenbal stevenbal changed the title 🚧 [#4608] initial modal work ✨ [#4608] Modal for Objects API prefill options Sep 23, 2024
@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch 3 times, most recently from c9901b2 to 5affccb Compare September 23, 2024 10:42
@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch from 5affccb to 0e6353a Compare September 23, 2024 12:08
@stevenbal stevenbal marked this pull request as ready for review September 23, 2024 12:08
@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch 2 times, most recently from a8f7deb to 30cbead Compare September 23, 2024 12:15
@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch from 30cbead to 6b51149 Compare September 23, 2024 12:37
@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch 2 times, most recently from 3e37de2 to cff46cf Compare September 30, 2024 14:56
@stevenbal stevenbal marked this pull request as draft September 30, 2024 15:00
@stevenbal stevenbal force-pushed the feature/4608-product-prefill-modal branch 3 times, most recently from ae346a9 to 237dae0 Compare October 1, 2024 07:45
@stevenbal stevenbal marked this pull request as ready for review October 1, 2024 07:57
@sergei-maertens sergei-maertens force-pushed the feature/4608-product-prefill-modal branch from e0e3b97 to f8b09c3 Compare October 7, 2024 09:12
@sergei-maertens
Copy link
Member

@stevenbal given your availability and how long this PR has been going on, I've taken some liberty in making the VariableMapping component how I'd like to see it, and made sure to update everything that uses it.

The main takeway is that the JSON serialization/deserialization is now an implementation detail, so you can use whatever value type for the dropdown values, while ensure the labels are something that can be rendered. It's a refinement of your implementation, but a bit more bold, and I made sure to fix all the prop types warnings/violations (those caused me to look into it in more detail to begin with).

I'll continue polishing this so that it can hopefully be merged today or tomorrow :)

@sergei-maertens sergei-maertens force-pushed the feature/4608-product-prefill-modal branch from 1272c0c to 2fec7dc Compare October 7, 2024 19:35
stevenbal and others added 9 commits October 7, 2024 22:05
this is the initial implementation, it is not yet fully functional, since it relies on backend changes that are not merged yet.
It will be connected with the backend in #4693
* make VariableMapping generic by moving it outside of DMN directory
* rename extraData to configurationContext
* add test for plugin configurationContext
* rename prefillAttribute to prefillProperty for Objects API prefill
* move VariableMapping styling to its own file
* define mapping for prefill plugins to components
because the prefill properties endpoint also specifies `targetPath`, which are lists to distinguish between nested values and values with `.` in  them.

Also ensure alreadyMapped works for Objects API prefill mapping
previously these were defined as part of registrations, but since they are now also used by prefill, their location should reflect that they are generic

* ObjectsAPIGroup
* ObjectTypeSelect
* ObjectTypeVersionSelect
previously it was only possible to specify a prefix and the objecttype, objecttypeVersion and objectsApiGroup names were fixed. Now those are configurable and the prefix has been removed
@sergei-maertens sergei-maertens force-pushed the feature/4608-product-prefill-modal branch from 2122125 to e656a09 Compare October 7, 2024 20:05
Now the VariableMapping component interface is determined, we need
to make sure that the DMN configuration form can still properly
use it after making it more generic.
After changing the API of the VariableMapping, the tests and implementation
in the prefill configuration modal needed to be updated to be compatible.
Since there are two columns for source/target in the variable mapping
component, it makes sense to display the direction of assignment
with an arrow.
The hook is actually more broadly usable than in the objects_api, but
for the time being it's only used there.
After moving the ObjectsAPIGroup component to a shared field layer
where the form data structure is unknown at the component level, the
code to reset dependent fields was no longer properly 'generic' and the
approach with a prefix was not the most elegant:

* it assumes the other (dependent) field names are the same in
  registration and prefill (they are, but deliberately, though there's
  no guarantee they will be in the future)
* it assumes a certain structure, but dependent fields may live in
  another namespace or the reset behaviour could require additional
  changes in the form state to be made

Instead, the reset behaviour can now be passed in as a prop, so that
the caller/user of the ObjectsAPIGroup component is in control of
which state exactly gets reset.

This already reflects nicely since the variableMapping reset in the
Legacy Objects API registration configuration didn't make any sense,
it's a V2 option, so now we have tailored reset functions to the
expected data structure.
Renamed and documented the props for more consistency with the rest of
the codebase.
Renamed and documented the props for more consistency with the rest of
the codebase.
Once we start re-using bits and pieces and have plugin-specific code/
configuration, it's better to stick to the one-component-per-file
approach since (some of) the components are now re-usable and semi-
public API.
This way, plugin-specific configuration forms cannot accidentally make
it impossible to change the plugin type again when a mistake is made,
and it reduces the code repetition.
@sergei-maertens sergei-maertens force-pushed the feature/4608-product-prefill-modal branch from 8095b9d to d31b31b Compare October 8, 2024 08:26
Copy link
Member

@sergei-maertens sergei-maertens left a comment

Choose a reason for hiding this comment

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

@stevenbal it might be interesting to go over my commit messages that finetuned this PR!

@sergei-maertens sergei-maertens merged commit 3a310db into master Oct 8, 2024
36 checks passed
@sergei-maertens sergei-maertens deleted the feature/4608-product-prefill-modal branch October 8, 2024 08:44
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.

Implement prefill configuration modal (StoryBook only)
2 participants