Commit 440b24c
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>1 parent b68e744 commit 440b24c
6 files changed
Lines changed: 992 additions & 69 deletions
File tree
- openmetadata-ui-core-components/src/main/resources/ui/src/components
- application
- file-upload
- form-field
- fields
- openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm
Lines changed: 242 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
0 commit comments