feat(form-builder): free field reordering via field_order#8125
Open
Kelsey-Ethyca wants to merge 4 commits intodemo/aprilfrom
Open
feat(form-builder): free field reordering via field_order#8125Kelsey-Ethyca wants to merge 4 commits intodemo/aprilfrom
Kelsey-Ethyca wants to merge 4 commits intodemo/aprilfrom
Conversation
Adds an optional `field_order: string[]` to PrivacyRequestOption so any custom field can render between identity fields (e.g. a "reason" input between Email and Phone). Previously the privacy center hardcoded the sequence to name → email → phone → customs, so the form builder's drag-and-drop ordering couldn't survive the round-trip back to the legacy two-bucket shape (`identity_inputs` + `custom_privacy_request_fields`). The form builder now emits `field_order` reflecting its children list, the public privacy-center renderer iterates that list strictly when present, and the existing `custom_privacy_request_field_order` is kept as a backwards-compatible read fallback (deprecated). No DB migration — the new field is additive on the JSONB blob. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## demo/april #8125 +/- ##
=============================================
Coverage ? 84.95%
=============================================
Files ? 636
Lines ? 41586
Branches ? 4836
=============================================
Hits ? 35330
Misses ? 5157
Partials ? 1099 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Rename test helper `describe_` to `stringifyField` and lift its declaration above first use (eslint: no-use-before-define, naming-convention, no-underscore-dangle). - Apply `ruff format` to the schema module and tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Replace `_legacyOrder` destructure (eslint naming-convention rejects leading underscores) with a `delete` on a shallow copy of the action. - Apply prettier auto-fix to `synthesize.ts` and `mapper.test.ts`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Single-statement collapse caught by `prettier --check` in admin-ui Clients-Unit. Auto-applied via `prettier --write`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket ENG-3652
Description Of Changes
Lets the privacy center form builder freely reorder identity and custom fields — including interleaving (e.g. a "reason" input between Email and Phone). The legacy persisted shape splits an action's fields into two top-level buckets (
identity_inputsandcustom_privacy_request_fields), so the public renderer hardcoded a fixed sequence (name → email → phone → customs) and the form builder's drag-and-drop order was lost on save.This adds a single optional
field_order: string[]onPrivacyRequestOption. When present, the privacy center renders strictly in that order, looking each key up in either bucket. When absent, the legacy hardcoded sequence still applies — every existing customer config keeps working with no migration.custom_privacy_request_field_orderis now deprecated. It's still read as a fallback for legacy configs, but new writes from the form builder usefield_order. The fidesplus storage normalizer (separate PR) skips writing the legacy key whenfield_orderis already present.Pairs with a fidesplus PR for the storage-side normalization update + integration test.
Code Changes
field_order: Optional[List[str]]added toPrivacyRequestOptionwith a Pydantic validator (rejects duplicates and unknown keys; allows partial coverage with a documented fall-through to legacy ordering)reorder_custom_privacy_request_fieldsupdated to preferfield_orderover the deprecatedcustom_privacy_request_field_orderfieldOrderinMapResult, walking the spec's children listfieldOrderargument and renders elements in that sequence (falls back to the canonical name → email → phone → customs order otherwise)FormBuilderPageand the[actionPolicyKey].tsxsave route plumbfieldOrderthrough; on save we explicitly drop the deprecatedcustom_privacy_request_field_orderkey so it can't shadow the new source of truthPrivacyRequestForm) refactored to a single ordered loop driven byOrderedField[]from a new pure helper (buildOrderedFields); per-field validation, hidden filtering,isFieldVisibleall preservedmapSpecToPcShape(3 cases),synthesizeSpecFromPcShape(5 cases),buildOrderedFields(9 cases), Pydantic validator (7 cases), and the reorder helper (2 cases for the deprecation precedence)field_orderis sent in the property PUT body when a custom field sits between identity fieldsSteps to Confirm
demo/april(nofield_orderin its config), verify it loads in the new admin UI with the legacy order and saves cleanly withfield_orderpresent after savePre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works🤖 Generated with Claude Code