greg-om opened a new pull request, #45640:
URL: https://github.com/apache/superset/pull/45640

   ImageLoader fetched thumbnails with a bare fetch, so root-relative 
thumbnail_url paths didn't prepend SUPERSET_APP_ROOT.  Moved the ListViewCard 
story images to imgFallbackURL since Storybook has no configured client.
   
   ### SUMMARY
   
   When Superset is served under a subdirectory i.e. 
(`SUPERSET_APP_ROOT=/analytics`), thumbnails on the chart list, the dashboard 
list and the dashboard editor's "add chart" panel are requested without the 
prefix: the page asks for `/api/v1/chart/123/thumbnail/<digest>/` instead of 
`/analytics/api/v1/chart/123/thumbnail/<digest>/`.
   
   **Root cause.** `ImageLoader` 
(`packages/superset-ui-core/src/components/ListViewCard/ImageLoader.tsx`) loads 
images with a bare `fetch(src)`. The backend's `thumbnail_url` is a 
root-relative API path without the app root, which matches the frontend 
convention since #39925, so the prefix has to be added client side. A bare 
`fetch` never goes through `SupersetClient.getUrl`, so it never gets it.
   
   **Fix.** `ImageLoader` requests `src` through `SupersetClient.get({ 
endpoint: src, parseMethod: 'raw' })`, the same pattern used in 
`useDownloadScreenshot.ts` and `utils/export.ts`. The client adds the app root, 
the CSRF header and the auth handling. Callers (`ChartCard`, `DashboardCard`, 
`AddSliceCard`) are unchanged.
   
   **Behaviour changes**
   - `ImageLoader`'s `src` must be a Superset endpoint. Absolute external URLs 
are no longer supported; no caller in the app passes one.
   - A 401 on a thumbnail triggers `SupersetClient`'s redirect to login, like 
any other API call.
   - The request waits for `ensureAuth()`, so it starts asynchronously rather 
than during the first effect run.
   
   **Stories and docs.** The `ListViewCard` stories passed picsum URLs as 
`imgURL`. Storybook and the docs portal never configure `SupersetClient`, so 
those stories would throw. The picsum images move to `imgFallbackURL` (a CSS 
background, not fetched) and `imgURL` is empty. 
`docs/developer_docs/components/ui/listviewcard.mdx` is regenerated from the 
stories. Typing an endpoint into the `imgURL` control in Storybook or the docs 
page will still fail, since there is no configured client there.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A. With `SUPERSET_APP_ROOT` set, list cards go from the placeholder image 
to the real thumbnail. Without an app root, nothing changes.
   
   ### TESTING INSTRUCTIONS
   
   Automated:
   ```
   cd superset-frontend
   npm run test -- packages/superset-ui-core/src/components/ListViewCard
   ```
   
   Manual:
   1. Enable the `THUMBNAILS` feature flag and a working thumbnail cache/worker 
setup.
   2. Serve Superset under a subdirectory, e.g. `SUPERSET_APP_ROOT=/analytics`, 
behind a proxy that only routes `/analytics` to Superset.
   3. Open the chart list and dashboard list in card view, and the "add chart" 
panel in dashboard edit mode.
   4. In the network tab, thumbnail requests go to 
`/analytics/api/v1/.../thumbnail/...` and the images render. On `master` they 
go to `/api/v1/...` and fall back to the placeholder.
   5. Without `SUPERSET_APP_ROOT`, thumbnails load as before.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [x] Required feature flags: `THUMBNAILS` (to see thumbnails at all)
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to