From e108952e111c2f47ce808bb99382c5f7110affaf Mon Sep 17 00:00:00 2001 From: Aditya Hegde Date: Fri, 22 Mar 2024 14:14:50 +0530 Subject: [PATCH] fix: disable bookmark for anonymous users (#4406) * Disable bookmark for anonymous users * fix: lint --------- Co-authored-by: Alexander Thor --- web-admin/src/features/bookmarks/selectors.ts | 8 +++-- ...=> DashboardBookmarksStateProvider.svelte} | 2 +- .../navigation/TopNavigationBar.svelte | 4 ++- .../[project]/[dashboard]/+page.svelte | 30 ++++++++++++++----- 4 files changed, 32 insertions(+), 12 deletions(-) rename web-admin/src/features/dashboards/{DashboardAdminStateProvider.svelte => DashboardBookmarksStateProvider.svelte} (95%) diff --git a/web-admin/src/features/bookmarks/selectors.ts b/web-admin/src/features/bookmarks/selectors.ts index f3e2cd51455..f0d372311b2 100644 --- a/web-admin/src/features/bookmarks/selectors.ts +++ b/web-admin/src/features/bookmarks/selectors.ts @@ -1,4 +1,5 @@ import { + createAdminServiceGetCurrentUser, createAdminServiceListBookmarks, type V1Bookmark, } from "@rilldata/web-admin/client"; @@ -46,8 +47,9 @@ export function getBookmarks( useProjectId(orgName, projectName), useMetricsView(instanceId, metricsViewName), createQueryServiceMetricsViewSchema(instanceId, metricsViewName), + createAdminServiceGetCurrentUser(), ], - ([projectId, metricsViewResp, schemaResp], set) => + ([projectId, metricsViewResp, schemaResp, userResp], set) => createAdminServiceListBookmarks( { projectId: projectId.data, @@ -60,7 +62,9 @@ export function getBookmarks( !!projectId?.data && !!metricsViewName && !metricsViewResp.isFetching && - !schemaResp.isFetching, + !schemaResp.isFetching && + userResp.isSuccess && + !!userResp.data.user, select: (resp) => { const bookmarks: Bookmarks = { home: undefined, diff --git a/web-admin/src/features/dashboards/DashboardAdminStateProvider.svelte b/web-admin/src/features/dashboards/DashboardBookmarksStateProvider.svelte similarity index 95% rename from web-admin/src/features/dashboards/DashboardAdminStateProvider.svelte rename to web-admin/src/features/dashboards/DashboardBookmarksStateProvider.svelte index d02546cddad..e6670b124ae 100644 --- a/web-admin/src/features/dashboards/DashboardAdminStateProvider.svelte +++ b/web-admin/src/features/dashboards/DashboardBookmarksStateProvider.svelte @@ -21,7 +21,7 @@ metricViewName, ); - const dashboardStoreReady = createDashboardStateSync( + $: dashboardStoreReady = createDashboardStateSync( getStateManagers(), homeBookmark, ); diff --git a/web-admin/src/features/navigation/TopNavigationBar.svelte b/web-admin/src/features/navigation/TopNavigationBar.svelte index cfb1ca29d94..3fbb33d75b0 100644 --- a/web-admin/src/features/navigation/TopNavigationBar.svelte +++ b/web-admin/src/features/navigation/TopNavigationBar.svelte @@ -60,7 +60,9 @@ {/if} {#if onDashboardPage} - + {#if $user.isSuccess && $user.data.user} + + {/if} {/if} {#if $user.isSuccess} diff --git a/web-admin/src/routes/[organization]/[project]/[dashboard]/+page.svelte b/web-admin/src/routes/[organization]/[project]/[dashboard]/+page.svelte index bfe35465756..318df516b48 100644 --- a/web-admin/src/routes/[organization]/[project]/[dashboard]/+page.svelte +++ b/web-admin/src/routes/[organization]/[project]/[dashboard]/+page.svelte @@ -1,10 +1,12 @@