-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: session storage retrieval for url messes with the url history (#…
…6238) * Use history API to redirect URL * Fix issues with cloud * Fix tests * Fix race condition in reactive statement * Disable TTD for no timeseries dashboards * Update rill-dev * Update token and emebd * Remove console.log * Reset expore state when metrics view is changed * Move all state loading decision to DashboardURLStateSync * Fix race condition on cloud * Update tests * Intercept url in beforeNavigate * Use goto with replaceState instead of beforeNavigate * Fix missing home bookmark while siwtching using breadcrumbs * Fix CI * Rename initState before Sync component * Add schema requests * Fix misc issues * Fix explore preview to not retain state from visual editor * Fix timeranges with invalid comparison * Use token id as key
- Loading branch information
1 parent
8e7bca1
commit e5ffc5d
Showing
45 changed files
with
808 additions
and
764 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 10 additions & 50 deletions
60
web-admin/src/routes/[organization]/[project]/-/share/[token]/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,17 @@ | ||
import { getDashboardStateFromUrl } from "@rilldata/web-common/features/dashboards/proto-state/fromProto"; | ||
import { metricsExplorerStore } from "@rilldata/web-common/features/dashboards/stores/dashboard-stores"; | ||
import type { MetricsExplorerEntity } from "@rilldata/web-common/features/dashboards/stores/metrics-explorer-entity"; | ||
import { convertExploreStateToURLSearchParams } from "@rilldata/web-common/features/dashboards/url-state/convertExploreStateToURLSearchParams"; | ||
import { convertURLToExploreState } from "@rilldata/web-common/features/dashboards/url-state/convertPresetToExploreState"; | ||
import { redirect } from "@sveltejs/kit"; | ||
import { get } from "svelte/store"; | ||
import { getExploreStates } from "@rilldata/web-common/features/explores/selectors"; | ||
|
||
export const load = async ({ url, parent }) => { | ||
const { explore, metricsView, defaultExplorePreset, token } = await parent(); | ||
const exploreName = token.resourceName; | ||
const exploreName = token?.resourceName; | ||
const metricsViewSpec = metricsView.metricsView?.state?.validSpec; | ||
const exploreSpec = explore.explore?.state?.validSpec; | ||
|
||
// On the first dashboard load, if there are no URL params, append the token's state (in human-readable format) to the URL. | ||
if ( | ||
token.state && | ||
![...url.searchParams.keys()].length && | ||
!(exploreName in get(metricsExplorerStore).entities) | ||
) { | ||
const exploreState = getDashboardStateFromUrl( | ||
token.state, | ||
metricsViewSpec, | ||
exploreSpec, | ||
{}, // TODO | ||
); | ||
const newUrl = new URL(url); | ||
newUrl.search = convertExploreStateToURLSearchParams( | ||
exploreState as MetricsExplorerEntity, | ||
exploreSpec, | ||
defaultExplorePreset, | ||
); | ||
throw redirect(307, `${newUrl.pathname}${newUrl.search}`); | ||
} | ||
|
||
// Get Explore state from URL params | ||
let partialExploreState: Partial<MetricsExplorerEntity> = {}; | ||
const errors: Error[] = []; | ||
if (metricsViewSpec && exploreSpec) { | ||
const { | ||
partialExploreState: partialExploreStateFromUrl, | ||
errors: errorsFromConvert, | ||
} = convertURLToExploreState( | ||
url.searchParams, | ||
metricsViewSpec, | ||
exploreSpec, | ||
defaultExplorePreset, | ||
); | ||
partialExploreState = partialExploreStateFromUrl; | ||
errors.push(...errorsFromConvert); | ||
} | ||
|
||
return { | ||
partialExploreState, | ||
errors, | ||
}; | ||
return getExploreStates( | ||
exploreName, | ||
`${token.id}__`, | ||
url.searchParams, | ||
metricsViewSpec, | ||
exploreSpec, | ||
defaultExplorePreset, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
e5ffc5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://ui.rilldata.in as production
🚀 Deployed on https://6761efc19c5b2344d0778dcc--rill-ui-dev.netlify.app