OpenMetadata/openmetadata-ui-core-components
Sid 440b24c44f
fix(ui): restore cover image preview in COVER_IMAGE_UPLOAD field (#27790)
* fix(ui): restore cover image preview in COVER_IMAGE_UPLOAD field

The AddDomainForm refactor (#26951) switched to the core-components
COVER_IMAGE_UPLOAD field, which only emitted a FileTrigger button and
filename hint — losing the image preview, replace, and remove
affordances that the legacy MUICoverImageUpload provided.

Add a CoverImageUploadField in core-components that renders the
preview (blob URL for File, raw url for backend strings), with hover
Replace and Remove controls. Expose a renderPreview slot so consumers
that need richer UX (e.g. drag-to-reposition) can override the default
preview without further core changes. Authenticated URL resolution
stays consumer-side.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(ui): port UntitledUI FileUploadDropZone, add reposition + dimension validation

Add a `FileUploadDropZone` component to core-components, ported from
UntitledUI's open-source React components — gives us their official
dropzone visuals (FeaturedIcon + "Click to upload" / "or drag and
drop" + format hint, plus drag-and-drop, accept-type filtering, and
size limit handling).

Wire it into `CoverImageUploadField` as the empty state, and expand
the field to restore the missing reposition flow and dimension/size
validation that the legacy MUICoverImageUpload handled:

- Drag-to-reposition (mouse, touch, keyboard) with Save / Cancel /
  Reset Position controls. Repositionable detection uses the image's
  scaled height vs. configurable previewHeight.
- Size validation via the underlying FileUploadDropZone (maxSize in
  bytes, derived from maxSizeMB) with onSizeLimitExceed → consumer
  toast.
- Dimension validation in the wrapper using natural width/height,
  with onValidationError callback for the consumer toast.
- New props: maxSizeMB, maxDimensions, validationMessages,
  onValidationError, repositionable, coverImageLabels, previewHeight.
  All threaded through FieldPropsMap.

`AddDomainForm` now passes the 5MB / 800x400 limits, i18n strings for
all labels and errors, and shows validation toasts via notistack.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(ui): cover image — pre-measure dims, reset position on replace, blob URL useEffect

Three fixes to CoverImageUploadField; the FileUploadDropZone stays as
the pristine UntitledUI port.

- Pre-measure image dimensions inside acceptFile via a measureImage
  helper instead of the prior validate-only pass. The natural width
  and height are written into state alongside the form value, so the
  Reposition button reads the new image's dims on the same render the
  preview swaps in — no flicker through stale state.
- Drop the carry-over of the previous file's percentage offset when
  accepting a replacement; new files start at default position.
- Switch previewSrc from useMemo to useState + useEffect so the
  URL.createObjectURL side effect runs in commit phase, not render.
  Discarded concurrent renders no longer leak unrevoked blob URLs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(ui): cover image — re-enable Reposition on first upload

isImageRepositionable was a useMemo whose recompute keyed off the
image's natural dimensions. On the very first upload, those dimensions
land before the preview <div> mounts, so getScaledImageHeight reads a
null containerRef and returns 0. The button then stayed disabled
because nothing later triggered a recompute.

Track the container width in state via a callback ref. The mount
itself now schedules a re-render; getScaledImageHeight reads from
state instead of poking offsetWidth mid-render. Replace already worked
because the ref was attached by the time dimensions changed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(ui): cover image — don't recreate blob URL on position-only changes

The previewSrc useEffect depended on the whole value object. Saving a
reposition mints a new value with the same File but a different
position, so the effect was revoking and re-minting a blob URL for
the same File on every save — wasted work plus a brief <img> flicker.

Depend on stable file/url primitives extracted from value; position
changes leave both untouched, so the effect no longer runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(ui): apply organize-imports to AddDomainForm

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(ui): apply core-components eslint + prettier fixes

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Siddhant <siddhant@MacBook-Pro-621.local>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 17:45:43 +05:30
..
src/main/resources/ui fix(ui): restore cover image preview in COVER_IMAGE_UPLOAD field (#27790) 2026-04-29 17:45:43 +05:30
CLAUDE.md chore(ui): remove multiple tailwind references (#26316) 2026-03-09 12:28:51 +05:30
pom.xml preparing 1.12 branch (#24870) 2025-12-17 18:36:03 +05:30