-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dashboard parameter values in embed preview not working #37972
Fix dashboard parameter values in embed preview not working #37972
Conversation
|
692f5c3
to
2ca1202
Compare
2ca1202
to
e2f07d8
Compare
query: { "source-table": PRODUCTS_ID }, | ||
}; | ||
|
||
const filter3 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I declare filter3
first because I want to use filter2
's id in filter
, and I don't want to hardcode that, so I need to declare filter2
before filter1
, and I figure I should put filter3
first for consistency.
@@ -276,7 +277,7 @@ export const fetchDashboard = createAsyncThunk( | |||
return { | |||
entities, | |||
dashboard: result, | |||
dashboardId: dashId, | |||
dashboardId: result.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken a look at all the dashboard types above.
embed
: Embedded dashboardtransient
: x-ray dashboardinline
: I don't think this is used anymore. Asked a question in Slack.- and a normal dashboard.
All have result.id === dashId
except the embed dashboard since I change that to IS_EMBED_PREVIEW ? result.id : dashId
in this PR. I don't want to repeat the same condition again, so I figure using result.id
would make more sense.
@@ -196,7 +197,7 @@ export const fetchDashboard = createAsyncThunk( | |||
); | |||
result = { | |||
...result, | |||
id: dashId, | |||
id: IS_EMBED_PREVIEW ? result.id : dashId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is essentially the fix. Previously dashId
in this case (dashboardType === "embed"
) would be a UUID, and that makes calling the parameter values API with the dashboard as a UUID
But that means we'd be calling /api/dashboard/:uuid
which is wrong, we're supposed to call /api/dashboard/:dashboard-id
instead. The thing is that in embed preview we don't call /api/embed/*
endpoints because it's possible for the resource to not have been embedded yet, calling /api/embed/*
in that case will not return anything.
You can see that we have a logic that changes the dashboard and question parameter values endpoints to have /api/embed
prefix for embedding, but we don't do that in embed preview
metabase/frontend/src/metabase/services.js
Lines 531 to 540 in e2f07d8
export function setEmbedQuestionEndpoints(token) { | |
if (!IS_EMBED_PREVIEW) { | |
setCardEndpoints("/api/embed/card/:token", { token }); | |
} | |
} | |
export function setEmbedDashboardEndpoints() { | |
if (!IS_EMBED_PREVIEW) { | |
setDashboardEndpoints("/api/embed"); | |
} | |
} |
const lockedParameters = getLockedPreviewParameters( | ||
resourceParameters, | ||
embeddingParams, | ||
); | ||
|
||
const iframeUrl = useMemo(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the problem where the iframe is rendered twice.
@WiNloSt Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
* Fix dashboard parameter values in embed preview not working * Fix iframe rerendering unnecessarily * Add E2E reproduction test * Prevent iframe from rerendering unnecessarily
…38120) * Fix dashboard parameter values in embed preview not working * Fix iframe rerendering unnecessarily * Add E2E reproduction test * Prevent iframe from rerendering unnecessarily Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
* Fix dashboard parameter values in embed preview not working * Fix iframe rerendering unnecessarily * Add E2E reproduction test * Prevent iframe from rerendering unnecessarily
Closes #37914
Description
When we preview embed, we have some conditional logics that make sure the preview works e.g. we want to always allow previewing the dashboard even without publishing it first.
This has a consequence on the dashboard values that makes it calls an unavailable API. It calls the dashboard value with UUID instead of the number ID.
How to verify
Follow the reproduce steps from #37914, and make sure the dashboard preview and embedded dashboard parameters behaviors are the same.
Demo
Upload a demo video or before/after screenshots if sensible or remove the section
Checklist