Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Closes EMB-716 publicly shared maps in dashboards (#62990)

Sébastienca9ebb9972f3
diff --git a/frontend/src/metabase/visualizations/lib/map.ts b/frontend/src/metabase/visualizations/lib/map.ts
index 9d350fe2352..2eb11955749 100644
--- a/frontend/src/metabase/visualizations/lib/map.ts
+++ b/frontend/src/metabase/visualizations/lib/map.ts
@@ -1,4 +1,5 @@
-import type { Dataset, JsonQuery } from "metabase-types/api";
+import { isUuid } from "metabase/lib/uuid";
+import type { DashboardId, Dataset, JsonQuery } from "metabase-types/api";
interface TileCoordinate {
x: number | string;
@@ -7,7 +8,7 @@ interface TileCoordinate {
interface TileUrlParams {
cardId?: number;
- dashboardId?: number | string;
+ dashboardId?: DashboardId;
dashcardId?: number;
zoom: string | number;
coord: TileCoordinate;
@@ -44,8 +45,8 @@ export function getTileUrl(params: TileUrlParams): string {
return adhocQueryTileUrl(zoom, coord, latField, lonField, datasetQuery);
}
- if (typeof dashboardId === "string") {
- throw Error("dashboardId must be an int");
+ if (typeof dashboardId === "string" && !isUuid(dashboardId)) {
+ throw Error("dashboardId must be an int or a uuid");
}
const isPublicDashboard = uuid;
@@ -159,7 +160,7 @@ function savedQuestionTileUrl(
}
function dashboardTileUrl(
- dashboardId: number,
+ dashboardId: DashboardId,
dashcardId: number,
cardId: number,
zoom: string | number,
diff --git a/frontend/src/metabase/visualizations/lib/map.unit.spec.ts b/frontend/src/metabase/visualizations/lib/map.unit.spec.ts
index 690b894f575..7924e57bb5b 100644
--- a/frontend/src/metabase/visualizations/lib/map.unit.spec.ts
+++ b/frontend/src/metabase/visualizations/lib/map.unit.spec.ts
@@ -179,7 +179,8 @@ describe("map", () => {
describe("public dashboard", () => {
it("should generate url for public dashboard without parameters", () => {
const url = getTileUrl({
- dashboardId: 10,
+ // public dashboards have a uuid instead of an id
+ dashboardId: "621efc8c-9fd9-42db-a39a-1abdbfe23937",
dashcardId: 20,
cardId: 30,
zoom,
@@ -202,7 +203,8 @@ describe("map", () => {
});
const url = getTileUrl({
- dashboardId: 10,
+ // public dashboards have a uuid instead of an id
+ dashboardId: "621efc8c-9fd9-42db-a39a-1abdbfe23937",
dashcardId: 20,
cardId: 30,
zoom,