Skip to content
Snippets Groups Projects
Unverified Commit 32002457 authored by Dalton's avatar Dalton Committed by GitHub
Browse files

Don't run mapping logic that expects a `dataset_query` when there isn't one (#24536)


* Update hasPermissionsToMap to check for existence of dataset_query

* Add check to mapping-options fn, too

* Add repro for #24536

* Uncomment and enable the repro

Co-authored-by: default avatarNemanja <31325167+nemanjaglumac@users.noreply.github.com>
parent dc7599e8
No related branches found
No related tags found
No related merge requests found
......@@ -98,10 +98,14 @@ function DashCardCardParameterMapper({
const hasPermissionsToMap = useMemo(() => {
if (isVirtual) {
return true;
} else {
const question = new Question(card, metadata);
return question.query().isEditable();
}
if (!card.dataset_query) {
return false;
}
const question = new Question(card, metadata);
return question.query().isEditable();
}, [card, metadata, isVirtual]);
const { buttonVariant, buttonTooltip, buttonText, buttonIcon } =
......
......@@ -63,6 +63,10 @@ export function getParameterMappingOptions(
return tagNames ? tagNames.map(buildTextTagOption) : [];
}
if (!card.dataset_query) {
return [];
}
const question = new Question(card, metadata);
const query = question.query();
const options = [];
......
import { restore, filterWidget, visitDashboard } from "__support__/e2e/helpers";
import {
restore,
filterWidget,
visitDashboard,
editDashboard,
} from "__support__/e2e/helpers";
import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database";
const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
......@@ -17,7 +22,7 @@ describe("issue 20656", () => {
cy.signInAsAdmin();
});
it("should allow a user to visit a dashboard even without a permission to see the dashboard card (metabase#20656)", () => {
it("should allow a user to visit a dashboard even without a permission to see the dashboard card (metabase#20656, metabase#24536)", () => {
cy.createQuestionAndDashboard({
questionDetails: {
query: { "source-table": PRODUCTS_ID, limit: 2 },
......@@ -54,7 +59,19 @@ describe("issue 20656", () => {
// Make sure the filter widget is there
filterWidget();
cy.findByText("Sorry, you don't have permission to see this card.");
// Trying to edit the filter should not show mapping fields and shouldn't break frontend (metabase#24536)
editDashboard();
cy.findByTestId("edit-dashboard-parameters-widget-container")
.find(".Icon-gear")
.click();
cy.findByText("Column to filter on")
.parent()
.within(() => {
cy.icon("key");
});
});
});
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