Skip to content

Commit 4579654

Browse files
committed
fix: yaml defaults not loaded in embed (#7301)
* Fix yaml defaults not loaded in embed * Update comment
1 parent 92061af commit 4579654

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

web-common/src/features/dashboards/state-managers/loaders/DashboardStateDataLoader.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getMostRecentPartialExploreState } from "@rilldata/web-common/features/
1010
import { getExploreStateFromYAMLConfig } from "@rilldata/web-common/features/dashboards/stores/get-explore-state-from-yaml-config";
1111
import { getRillDefaultExploreState } from "@rilldata/web-common/features/dashboards/stores/get-rill-default-explore-state";
1212
import type { MetricsExplorerEntity } from "@rilldata/web-common/features/dashboards/stores/metrics-explorer-entity";
13+
import { cleanEmbedUrlParams } from "@rilldata/web-common/features/dashboards/url-state/clean-url-params";
1314
import { convertURLSearchParamsToExploreState } from "@rilldata/web-common/features/dashboards/url-state/convertURLSearchParamsToExploreState";
1415
import { useExploreValidSpec } from "@rilldata/web-common/features/explores/selectors";
1516
import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryClient";
@@ -241,6 +242,8 @@ export class DashboardStateDataLoader {
241242
rillDefaultExploreState: MetricsExplorerEntity;
242243
backButtonUsed: boolean;
243244
}) {
245+
urlSearchParams = cleanEmbedUrlParams(urlSearchParams);
246+
244247
const skipSessionStorage = backButtonUsed;
245248
const exploreStateFromSessionStorage = skipSessionStorage
246249
? null

web-common/src/features/dashboards/url-state/clean-url-params.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,23 @@ export function cleanUrlParams(
4040
});
4141
return cleanedParams;
4242
}
43+
44+
/**
45+
* Temporary fix to clean non-dashboard parameters from embed URLs.
46+
* When URL parameters exist, they are loaded exclusively from the URL, bypassing dashboard yaml defaults.
47+
* Since non-dashboard parameters are already removed in DashboardStateSync during URL state sync, we remove them here preemptively.
48+
*
49+
* TODO: Implement permanent solution for embed URLs, possibly by ignoring non-dashboard parameters in DashboardStateSync.
50+
*/
51+
export function cleanEmbedUrlParams(searchParams: URLSearchParams) {
52+
const cleanedParams = new URLSearchParams(searchParams);
53+
[
54+
"access_token",
55+
"instance_id",
56+
"kind",
57+
"resource",
58+
"runtime_host",
59+
"type",
60+
].forEach((p) => cleanedParams.delete(p));
61+
return cleanedParams;
62+
}

web-common/src/features/dashboards/url-state/get-cleaned-url-params-for-goto.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)