Content Value Transformation: Clean out values when property-type variation transforms#21557
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the content value transformation logic to handle property variation changes more robustly. The main change replaces a single-value transformation approach with batch processing that groups values by property alias for more efficient handling of invariant ↔ variant transitions.
Changes:
- Replaced
#transformValueForVariationChangemethod with#transformValuesForVariationChangesfor batch processing - When transitioning from variant to invariant, the code now consolidates values by keeping only the default language (or first available culture) and discarding other cultures
- When transitioning from invariant to variant, all values are assigned the default language culture
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| content-detail-workspace-type-transform.controller.ts | Refactored transformation method to process all values in batch, added grouping by alias, and implemented consolidation logic for variant→invariant transitions |
| content-detail-workspace-type-transform.controller.test.ts | Updated existing test to reflect new behavior (only keeping default language value) and added 6 comprehensive new test cases covering edge cases like fallback culture selection, multiple properties, and segment preservation |
...src/packages/content/content/workspace/content-detail-workspace-type-transform.controller.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Code looks good, and this appears to work as expected for me. I tested with an invariant document, populated some properties, then opened an infinite editor window to change it to variant (with some properties shared and some variant). Then repeated in the other direction. In all cases a sensible update was made to the content so property values weren't lost.
The only issue I found - which I guess isn't intended to be fixed in this PR - is that if you change from invariant to variant or vice versa, the URL to the document changes, and so when you close the infinite editor window, you the underlying document is gone - you have a "not found" displayed and if you try to navigate away you get the dirty changes prompt.
This happens because the URL to the invariant document was /umbraco/section/content/workspace/document/edit/{id}/invariant but after changing to variant it becomes /umbraco/section/content/workspace/document/edit/{id}/en-US. So you have to navigate away, click to "discard changes" and come back to be able to see the updated properties and continue working with the document.
|
@AndyButland, well spotted, I also discovered that, and have it noted. |
Improves value transformation when property variation settings (such as varyByCulture) change while a content workspace is open. The main focus is on handling transitions between invariant and variant property types more robustly and efficiently.
Key improvements to value transformation logic:
#transformValueForVariationChange) with a new batch-processing method (#transformValuesForVariationChanges)This is an addition and refactor of the work done in: #21293