-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition in reactive statement
- Loading branch information
1 parent
66d545a
commit 6250069
Showing
19 changed files
with
269 additions
and
286 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
50 changes: 18 additions & 32 deletions
50
web-admin/src/routes/[organization]/[project]/explore/[dashboard]/+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,49 +1,35 @@ | ||
import { convertBookmarkToUrlSearchParams } from "@rilldata/web-admin/features/bookmarks/selectors"; | ||
import { metricsExplorerStore } from "@rilldata/web-common/features/dashboards/stores/dashboard-stores"; | ||
import { convertURLToExploreState } from "@rilldata/web-common/features/dashboards/url-state/convertPresetToExploreState"; | ||
import { redirect } from "@sveltejs/kit"; | ||
import { get } from "svelte/store"; | ||
import { getUpdatedUrlForExploreState } from "@rilldata/web-common/features/dashboards/url-state/getUpdatedUrlForExploreState"; | ||
|
||
export const load = async ({ url, parent, params }) => { | ||
const { explore, metricsView, defaultExplorePreset, homeBookmark } = | ||
await parent(); | ||
const { explore, metricsView, defaultExplorePreset } = await parent(); | ||
const { organization, project, dashboard: exploreName } = params; | ||
const metricsViewSpec = metricsView.metricsView?.state?.validSpec; | ||
const exploreSpec = explore.explore?.state?.validSpec; | ||
|
||
// On the first dashboard load, if there are no URL params, redirect to the "Home" bookmark. | ||
if ( | ||
homeBookmark && | ||
![...url.searchParams.keys()].length && | ||
!(exploreName in get(metricsExplorerStore).entities) | ||
) { | ||
const newUrl = new URL(url); | ||
newUrl.search = convertBookmarkToUrlSearchParams( | ||
homeBookmark, | ||
const { partialExploreState, loadedOutsideOfURL, errors } = | ||
convertURLToExploreState( | ||
exploreName, | ||
`__${organization}__${project}`, | ||
url.searchParams, | ||
metricsViewSpec, | ||
exploreSpec, | ||
{}, // TODO | ||
undefined, | ||
defaultExplorePreset, | ||
); | ||
const urlSearchForPartial = loadedOutsideOfURL | ||
? getUpdatedUrlForExploreState( | ||
exploreSpec, | ||
defaultExplorePreset, | ||
partialExploreState, | ||
url.searchParams, | ||
) | ||
: url.searchParams.toString(); | ||
|
||
if (newUrl.search !== url.search) { | ||
throw redirect(307, `${newUrl.pathname}${newUrl.search}`); | ||
} | ||
} | ||
|
||
const { partialExploreState, loaded, errors } = convertURLToExploreState( | ||
exploreName, | ||
`__${organization}__${project}`, | ||
url.searchParams, | ||
metricsViewSpec, | ||
exploreSpec, | ||
defaultExplorePreset, | ||
); | ||
|
||
console.log(exploreName, urlSearchForPartial); | ||
return { | ||
partialExploreState, | ||
loaded, | ||
urlSearchForPartial, | ||
errors, | ||
exploreName, | ||
}; | ||
}; |
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
20 changes: 0 additions & 20 deletions
20
web-common/src/features/dashboards/stores/DashboardStateProvider.svelte
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.