Skip to content
Snippets Groups Projects
Unverified Commit 552cf921 authored by Uladzimir Havenchyk's avatar Uladzimir Havenchyk Committed by GitHub
Browse files

fix: respect click behavior on public dashboards (#50067)

* fix: pass noop as navigateToNewCardFromDashboard from public or embedded dashboard

* add e2e test

* rework a fix
parent c8aa0a54
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,12 @@ import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
assertDashboardFixedWidth,
assertDashboardFullWidth,
createDashboardWithQuestions,
createPublicDashboardLink,
dashboardParametersContainer,
describeEE,
filterWidget,
getDashboardCard,
goToTab,
openNewPublicLinkDropdown,
openSharingMenu,
......@@ -17,7 +19,7 @@ import {
visitPublicDashboard,
} from "e2e/support/helpers";
const { PRODUCTS } = SAMPLE_DATABASE;
const { PRODUCTS, ORDERS_ID } = SAMPLE_DATABASE;
const questionDetails = {
name: "sql param",
......@@ -286,6 +288,54 @@ describe("scenarios > public > dashboard", () => {
cy.findByText("Registerkarte als PDF exportieren").should("be.visible");
cy.url().should("include", "locale=de");
});
it("should respect click behavior", () => {
createDashboardWithQuestions({
dashboardName: "test click behavior",
questions: [
{
name: "orders",
query: {
"source-table": ORDERS_ID,
limit: 5,
},
},
],
cards: [
{
visualization_settings: {
column_settings: {
'["name","TOTAL"]': {
click_behavior: {
type: "link",
linkType: "url",
linkTemplate: "https://metabase.com",
},
},
},
},
},
],
}).then(({ dashboard }) => {
visitPublicDashboard(dashboard.id);
});
// This is a hacky way to intercept the link click we create an a element
// with href on fly and remove it afterwards in lib/dom.js
cy.window().then(win => {
cy.spy(win.document.body, "appendChild").as("appendChild");
});
getDashboardCard().findByText("39.72").click();
cy.get("@appendChild").then(appendChild => {
// last call is a link
const element = appendChild.lastCall.args[0];
expect(element.tagName).to.eq("A");
expect(element.href).to.eq("https://metabase.com/");
});
});
});
describeEE("scenarios [EE] > public > dashboard", () => {
......
......@@ -139,7 +139,7 @@ type OwnProps = {
mode?: QueryClickActionsMode | Mode;
// public dashboard passes it explicitly
width?: number;
// public dashboard passes it as noop
// public or embedded dashboard passes it as noop
navigateToNewCardFromDashboard?: (
opts: NavigateToNewCardFromDashboardOpts,
) => void;
......
......@@ -245,10 +245,6 @@ class Visualization extends PureComponent {
}
visualizationIsClickable = clicked => {
const { onChangeCardAndRun } = this.props;
if (!onChangeCardAndRun) {
return false;
}
try {
return this.getClickActions(clicked).length > 0;
} catch (e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment