Skip to content

Commit

Permalink
fix: disable bookmark for anonymous users (#4406)
Browse files Browse the repository at this point in the history
* Disable bookmark for anonymous users

* fix: lint

---------

Co-authored-by: Alexander Thor <alec.karlsson@gmail.com>
  • Loading branch information
2 people authored and nishantmonu51 committed Mar 22, 2024
1 parent e0bf2be commit e108952
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
8 changes: 6 additions & 2 deletions web-admin/src/features/bookmarks/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
createAdminServiceGetCurrentUser,
createAdminServiceListBookmarks,
type V1Bookmark,
} from "@rilldata/web-admin/client";
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
metricViewName,
);
const dashboardStoreReady = createDashboardStateSync(
$: dashboardStoreReady = createDashboardStateSync(
getStateManagers(),
homeBookmark,
);
Expand Down
4 changes: 3 additions & 1 deletion web-admin/src/features/navigation/TopNavigationBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
{/if}
{#if onDashboardPage}
<LastRefreshedDate {dashboard} />
<Bookmarks />
{#if $user.isSuccess && $user.data.user}
<Bookmarks />
{/if}
<ShareDashboardButton />
{/if}
{#if $user.isSuccess}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script lang="ts">
import { page } from "$app/stores";
import {
createAdminServiceGetCurrentUser,
createAdminServiceGetProject,
V1DeploymentStatus,
} from "@rilldata/web-admin/client";
import DashboardAdminStateProvider from "@rilldata/web-admin/features/dashboards/DashboardAdminStateProvider.svelte";
import DashboardBookmarksStateProvider from "@rilldata/web-admin/features/dashboards/DashboardBookmarksStateProvider.svelte";
import DashboardStateProvider from "@rilldata/web-common/features/dashboards/stores/DashboardStateProvider.svelte";
import { getDashboardsForProject } from "@rilldata/web-admin/features/dashboards/listing/selectors";
import { invalidateDashboardsQueries } from "@rilldata/web-admin/features/projects/invalidations";
import ProjectErrored from "@rilldata/web-admin/features/projects/ProjectErrored.svelte";
Expand All @@ -29,6 +31,8 @@
$: projectName = $page.params.project;
$: dashboardName = $page.params.dashboard;
const user = createAdminServiceGetCurrentUser();
$: project = createAdminServiceGetProject(orgName, projectName);
$: projectDeploymentStatus = useProjectDeploymentStatus(orgName, projectName); // polls
Expand Down Expand Up @@ -102,13 +106,23 @@
{:else}
{#key dashboardName}
<StateManagersProvider metricsViewName={dashboardName}>
<DashboardAdminStateProvider metricViewName={dashboardName}>
<DashboardURLStateProvider metricViewName={dashboardName}>
<DashboardThemeProvider>
<Dashboard metricViewName={dashboardName} leftMargin={"48px"} />
</DashboardThemeProvider>
</DashboardURLStateProvider>
</DashboardAdminStateProvider>
{#if $user.isSuccess && $user.data.user}
<DashboardBookmarksStateProvider metricViewName={dashboardName}>
<DashboardURLStateProvider metricViewName={dashboardName}>
<DashboardThemeProvider>
<Dashboard metricViewName={dashboardName} leftMargin={"48px"} />
</DashboardThemeProvider>
</DashboardURLStateProvider>
</DashboardBookmarksStateProvider>
{:else}
<DashboardStateProvider metricViewName={dashboardName}>
<DashboardURLStateProvider metricViewName={dashboardName}>
<DashboardThemeProvider>
<Dashboard metricViewName={dashboardName} leftMargin={"48px"} />
</DashboardThemeProvider>
</DashboardURLStateProvider>
</DashboardStateProvider>
{/if}
</StateManagersProvider>
{/key}
{/if}
Expand Down

1 comment on commit e108952

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.