Skip to content

Preview data type and content type imports with the real property editors - #1166

Merged
KevinJump merged 14 commits into
v17/mainfrom
v17/feature/item-preview
Nov 2, 2026
Merged

KevinJump merged 14 commits into
v17/mainfrom
v17/feature/item-preview

Conversation

@KevinJump

@KevinJump KevinJump commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Adds a Preview tab to the uSync change details modal. It shows the site's current version of an item and the incoming one from the uSync files side by side, rendered with the real backoffice property editors.

  • Data types: editor preview plus configuration, with changed config values highlighted.
  • Document, media and member types: laid out like the backoffice editor (composition tabs and groups merged in), every property rendered by its real editor, with added, removed and changed tabs, groups and properties highlighted, plus changes to the type's own fields and compositions.

Inspired by Moriyama's umbraco-pr-preview.

How it works

  • Dry run, not a new parser. The incoming item is built by the existing serializer with SerializerFlags.DoNotSave. Folders are looked up but never created or re-keyed, and editor-rename tracking is skipped.
  • Belt and braces. ISyncPreviewService runs the dry run inside a scope that is never completed, with notifications suppressed, so anything that slips through is rolled back.
  • Umbraco's own shapes. Both sides are mapped with Umbraco's own response model mappers (DataTypeResponseModel, DocumentTypeResponseModel, …). For content types the response also carries every composition either side uses and the data types their properties use.
  • Items not in the site yet. When a new property uses a data type, or a type is composed of a composition, that only exists in the uSync files, the dry run builds it from the files too (via an additive SyncSerializerOptions.PendingItemResolver, only set when previewing), so the property keeps its real editor and new data types and compositions are tagged as new.
  • Diff by key, client side. Content type changes are worked out by comparing the two models by key, so the trackers and the existing Changes tab are untouched.
  • New endpoint: GET /umbraco/usync/api/v1/Preview?handler=&key= (404 when the handler doesn't support previews; the modal then looks as it did before).

No breaking changes

Everything is additive:

  • SyncSerializerOptions.DoNotSave (was commented out)
  • FindOrCreateAsync(node, options) and FindFolderAsync(key, path, createIfMissing) overloads; the existing methods are unchanged and still used for imports
  • DeserializeBaseAsync and CleanFolderAsync gain options-aware overloads on the content type serializers; the existing ones behave as before
  • ISyncHandler.GetPreviewAsync with a default that returns null; the data type, content type, media type and member type handlers opt in
  • New ISyncPreviewService, controller, response model, client component; the regenerated API client only gains types

Testing

  • New DataTypePreviewTests (integration): dry run changes the item in memory only, a new item in a missing folder creates neither, a normal import still creates the folder, the handler preview returns both sides, a handler without support returns null.
  • New ContentTypePreviewTests (integration): dry run of an existing type changes it in memory only, a new type in a missing folder creates neither, the handler preview returns both sides.
  • New Playwright spec (usync-item-preview.spec.ts): writes a new data type and a document type using it into the test site, runs a report and checks both previews render the real editors.
  • Full suite: 194/194 passing; E2E 7/7.
  • Checked in uSyncSource.Site: a changed dropdown, a brand-new data type, and a document type with a new tab, group and property, a changed icon and a removed composition all preview correctly, and the database was unchanged afterwards.

Notes

  • New labels are translated into da, de, es, fr and nl; worth a native-speaker check.

Known limits

  • Properties that disappear because a composition is removed aren't flagged one by one; the Compositions list is highlighted instead.

🤖 Generated with Claude Code

The details modal gets a Preview tab that shows the current data type and
the incoming one from the uSync files side by side, rendered with the
real backoffice property editor and with changed config highlighted.

The incoming item is built by the serializer itself as a dry run: the
DoNotSave flag is now honoured when finding folders (they are looked up,
never created or re-keyed), and the preview runs inside a scope that is
never completed, so nothing can be written. Both sides are mapped with
Umbraco's own DataTypeResponseModel mapper.

All changes are additive: new overloads for FindOrCreateAsync and
FindFolderAsync, a default (null) ISyncHandler.GetPreviewAsync that only
the DataTypeHandler opts into, a new ISyncPreviewService and a
GET Preview endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the release/17.5.2 uSync 17.5.2 release label Oct 28, 2026
The Preview tab now covers content types. Both sides are laid out the
way the backoffice editor shows them (composition tabs and groups merged
in by name), every property is rendered by its real property editor, and
added, removed and changed tabs, groups and properties are highlighted,
along with changes to the type's own fields and compositions.

The content type serializers now honour DoNotSave for folders too:
DeserializeBaseAsync and CleanFolderAsync gain options-aware overloads,
FindOrCreateAsync uses the lookup-only folder path in a dry run, and the
existing signatures behave as before. The content, media and member type
handlers opt in to previews (with OnePass so compositions and structure
are applied).

The preview endpoint returns Umbraco's own response models for each
side, for every composition either side uses, and for the data types
their properties use. The diff is done client side by key, so the
trackers and the Changes tab are untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KevinJump KevinJump changed the title Preview data type imports with the real property editor Preview data type and content type imports with the real property editors Oct 28, 2026
KevinJump and others added 4 commits October 28, 2026 19:01
A dry run of a content type could only see data types already in the
site, so a new property using a new data type was dropped from the
incoming preview (or matched to another data type by name).

SyncSerializerOptions gets an additive PendingItemResolver, set only
when previewing. The content type serializer asks it for a property's
data type after the database lookup by key fails, and links an unsaved
data type by key. Normal imports are unchanged.

The preview service supplies a resolver that dry-runs the item from the
uSync files (cached per preview, guarded against loops) and returns
what it built with the preview, so the response includes those data
types and lists them in newDataTypes. The UI tags such properties as
using a new data type.

Adds a Playwright spec that writes a new data type and a document type
using it into the test site's uSync folder, runs a report and checks
both previews render their real editors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The content type serializers' composition lookup now asks the preview's
pending item resolver after the database lookup by key fails (and
before the alias fallback), through an additive options-aware overload
of DeserializeCompositionsAsync. A new type composed of a new
composition now previews with the composition's tabs, groups and
properties merged in.

The preview response lists those compositions in newCompositions and
the UI tags them as new.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the new item preview labels to the Danish, German, Spanish, French
and Dutch language files (they fell back to English before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- the current and incoming sides share rows (subgrid), so tab bars,
  groups and config boxes line up; below 760px they stack full width
- changed fields get a soft highlight instead of a heavy outline, and
  changed rows an inset bar and tint, so nothing shifts sideways
- properties inside an added or removed group or tab aren't marked one
  by one
- tighter property spacing (umb-property's workspace padding reduced in
  the preview), properties run edge to edge with dividers
- the tab status dot sits on the label's line
- the config table's alias column fits the longest alias, with matching
  font sizes
- side captions, smaller type aliases, green "new data type" tags

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KevinJump
KevinJump marked this pull request as ready for review October 28, 2026 22:33
- the content and media serializers stop before saving or publishing
  when run with DoNotSave, and a dry run doesn't clear document url
  caches on a key change
- the content and media handlers build previews, and the preview keeps
  the uSync file it was built from
- the preview API maps both sides with Umbraco's own document and media
  models, plus the item's type, compositions and data types, and the
  parent, sort order, template and published state (the incoming side
  read from the file)
- a new usync-content-preview shows both sides laid out like the
  editor, every value in its real property editor, opening on the
  first tab with changes; changed, added and removed values are marked,
  with a language switch for variant content and an "only show changes"
  toggle

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KevinJump and others added 5 commits October 29, 2026 08:02
Put the only-changes toggle on the incoming headline row, drop the
"No value" note that pushed the sides out of line, and keep stacked
mode full width with left-aligned headlines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The incoming trashed state is now read from the file (the import sets it
in the second pass, which a preview doesn't run), sort order respects
IgnoreSortOrder, and published state only compares the cultures uSync is
set to sync. The dry run's serializer options are kept on SyncItemPreview
so the preview can follow the same settings as the import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preview content and media imports with the real property editors
@KevinJump KevinJump self-assigned this Oct 29, 2026
@KevinJump KevinJump added release/17.6.0 and removed release/17.5.2 uSync 17.5.2 release labels Oct 29, 2026
KevinJump and others added 2 commits October 30, 2026 14:01
The visual preview is now the default, left-hand tab and is called
Changes; the old changes list becomes Diff. Both tabs have icons and sit
in a bar so they stand apart from the page. A choice of Diff sticks while
stepping through items, and a loader shows while the preview loads.

The headline gets a second line with the item type and change, e.g.
"Content type · Update".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Previews are now mapped by ISyncPreviewMapper classes, found by the type
loader into a weighted collection (like the trackers), and picked by item
type. The preview service runs the mapper inside the preview scope, so
the controller no longer knows about any item types.

The response is a common envelope with the mapper's model in Preview.
In the backoffice, a 'usync-item-preview' element is registered for each
entity type and shown through an extension slot, so packages (Forms,
Commerce etc.) can add previews for their own items. The core previews
are registered the same way and now load lazily.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant