diff --git a/web-admin/src/features/bookmarks/BookmarksDropdownMenuContent.svelte b/web-admin/src/features/bookmarks/BookmarksDropdownMenuContent.svelte index e0cfbe739a5..7d738ab2a65 100644 --- a/web-admin/src/features/bookmarks/BookmarksDropdownMenuContent.svelte +++ b/web-admin/src/features/bookmarks/BookmarksDropdownMenuContent.svelte @@ -80,6 +80,7 @@ $schemaResp.data?.schema, $exploreState, defaultExplorePreset, + $metricsViewTimeRange.data?.timeRangeSummary, ); $: filteredBookmarks = searchBookmarks(categorizedBookmarks, searchText); diff --git a/web-admin/src/features/bookmarks/selectors.ts b/web-admin/src/features/bookmarks/selectors.ts index 026c7627edc..cdba5a8f2ba 100644 --- a/web-admin/src/features/bookmarks/selectors.ts +++ b/web-admin/src/features/bookmarks/selectors.ts @@ -8,7 +8,10 @@ import { getDashboardStateFromUrl } from "@rilldata/web-common/features/dashboar import { useMetricsViewTimeRange } from "@rilldata/web-common/features/dashboards/selectors"; import { useExploreState } from "@rilldata/web-common/features/dashboards/stores/dashboard-stores"; import type { MetricsExplorerEntity } from "@rilldata/web-common/features/dashboards/stores/metrics-explorer-entity"; -import { timeControlStateSelector } from "@rilldata/web-common/features/dashboards/time-controls/time-control-store"; +import { + getTimeControlState, + timeControlStateSelector, +} from "@rilldata/web-common/features/dashboards/time-controls/time-control-store"; import { convertExploreStateToURLSearchParams } from "@rilldata/web-common/features/dashboards/url-state/convertExploreStateToURLSearchParams"; import { ResourceKind } from "@rilldata/web-common/features/entity-management/resource-selectors"; import { useExploreValidSpec } from "@rilldata/web-common/features/explores/selectors"; @@ -20,6 +23,7 @@ import { type V1ExploreSpec, type V1MetricsViewSpec, type V1StructType, + type V1TimeRangeSummary, } from "@rilldata/web-common/runtime-client"; import type { QueryClient } from "@tanstack/query-core"; import { derived, get, type Readable } from "svelte/store"; @@ -61,6 +65,7 @@ export function categorizeBookmarks( schema: V1StructType | undefined, exploreState: MetricsExplorerEntity, defaultExplorePreset: V1ExplorePreset, + timeRangeSummary: V1TimeRangeSummary | undefined, ) { const bookmarks: Bookmarks = { home: undefined, @@ -76,6 +81,7 @@ export function categorizeBookmarks( schema ?? {}, exploreState, defaultExplorePreset, + timeRangeSummary, ); if (isHomeBookmark(bookmarkResource)) { bookmarks.home = bookmark; @@ -143,6 +149,7 @@ export function convertBookmarkToUrlSearchParams( schema: V1StructType, exploreState: MetricsExplorerEntity | undefined, defaultExplorePreset: V1ExplorePreset, + timeRangeSummary: V1TimeRangeSummary | undefined, ) { const exploreStateFromBookmark = getDashboardStateFromUrl( bookmarkResource.data ?? "", @@ -150,13 +157,19 @@ export function convertBookmarkToUrlSearchParams( exploreSpec, schema, ); + const finalExploreState = { + ...(exploreState ?? {}), + ...exploreStateFromBookmark, + } as MetricsExplorerEntity; return convertExploreStateToURLSearchParams( - { - ...(exploreState ?? {}), - ...exploreStateFromBookmark, - } as MetricsExplorerEntity, + finalExploreState, exploreSpec, - undefined, // TODO + getTimeControlState( + metricsViewSpec, + exploreSpec, + timeRangeSummary, + finalExploreState, + ), defaultExplorePreset, ); } @@ -168,6 +181,7 @@ function parseBookmark( schema: V1StructType, exploreState: MetricsExplorerEntity, defaultExplorePreset: V1ExplorePreset, + timeRangeSummary: V1TimeRangeSummary | undefined, ): BookmarkEntry { const url = new URL(get(page).url); url.search = convertBookmarkToUrlSearchParams( @@ -177,6 +191,7 @@ function parseBookmark( schema, exploreState, defaultExplorePreset, + timeRangeSummary, ); return { resource: bookmarkResource,