refactor(catalog): unify InputFile preview through Logo#4863
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4863 +/- ##
=======================================
Coverage 46.51% 46.51%
=======================================
Files 832 832
Lines 34116 34116
Branches 5828 5826 -2
=======================================
Hits 15868 15868
Misses 16243 16243
Partials 2005 2005
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Is this still pending? |
Collapse the two preview render branches in ThemeEditor's InputFile into a single one driven by a nullable preview src. Both the typed URL string and the File-derived blob URL now flow through Logo, which already handles s3://, http(s), and blob: srcs uniformly. Drops the unused preview style class and updates the spec to assert against the (mocked) Logo for the File case.
231ce78 to
abbcfde
Compare
Member
Author
|
@greptileai please re-review |
drernie
approved these changes
May 6, 2026
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.
Summary
InputFileinto a single one driven bypreviewSrc: string | null.blob:URL throughLogo, which already handless3://,http(s), andblob:uniformly.previewstyle class and renamepreviewUrlstate toblobUrl(it now only ever holds blob URLs).Why
Before this change there were two preview JSX branches (
<Logo>for URL strings,<img className={classes.preview}>for blob URLs) gated by overlapping conditions (isUrl,previewUrl,value). They were mutually exclusive in practice but expressed in a way that made it hard to see that at a glance. Single component, single nullable src, no ambiguity.Visual change
The File preview now uses
Logo's sizing (height-only, intrinsic width) instead of a fixed 50×50 box, so non-square logos preserve aspect ratio in the dropzone preview. Same as the URL-preview path, so the two cases now look consistent.Out of scope
meta/errorsregression vs master (URL validation message no longer renders) — separate fix.previewSrcmemo.Test plan
npm run test:only -- ThemeEditor.spec CatalogSettings.spec— 7/7 passnpm run lint— cleans3://URL, confirm preview signs and rendershttps://URL to a real image, confirm preview rendersGreptile Summary
This PR simplifies the logo preview rendering in
InputFileby collapsing two mutually-exclusive JSX branches (<Logo>for URL strings,<img>for blob URLs) into a single<Logo src={previewSrc}>path driven by a nullablepreviewSrcmemo. The rename ofpreviewUrl→blobUrlsharpens intent, and the now-deadpreviewCSS class is removed.previewSrcis derived fromvalue(string) orblobUrl(File-derived blob URL); a singlepreviewSrc ? <Logo> : <Placeholder>replaces three separate conditionals.Logo'scustomCSS class only constrains height, so dropped non-square images now render with intrinsic width instead of being forced into the old 50×50 box.Logoviadata-testid="logo"/data-src, matching the new render path.Confidence Score: 5/5
Safe to merge — the change is a purely structural cleanup of mutually-exclusive conditional branches with no new logic surface and correct blob-URL lifecycle handling.
The refactor replaces three overlapping boolean conditions with a single nullable
previewSrcmemo. The blob-URL creation and revocation lifecycle is preserved unchanged. Thevalue || nullcoercion correctly maps the empty-string case to the placeholder. No new network requests, state shapes, or side-effects are introduced beyond what existed before.No files require special attention.
Important Files Changed
previewSrcmemo; renamespreviewUrlstate toblobUrl; removes unusedpreviewCSS class.data-testidinstead of a rawimgelement; adds a Logo mock that exposesdata-srcfor inspection.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[InputFile renders] --> B{typeof value} B -->|string| C["previewSrc = value || null"] B -->|File| D[useEffect creates blob URL] D --> E["blobUrl state set"] E --> F["previewSrc = blobUrl"] C --> G{previewSrc truthy?} F --> G G -->|yes| H["Logo src={previewSrc}"] G -->|no| I["Placeholder (hide_image icon)"] H --> J{src is s3:// URL?} J -->|yes| K[Sign URL via AWS Signer] J -->|no| L[Use src as-is] K --> M["img rendered"] L --> MReviews (2): Last reviewed commit: "chore: add PR link for #4863 to theme ed..." | Re-trigger Greptile