From 0126cbe87bc4f9a662677f175cb7f505779db7fb Mon Sep 17 00:00:00 2001 From: Eric P Green Date: Wed, 13 Sep 2023 10:50:35 -0400 Subject: [PATCH] Move code to `features/view-as-user` --- web-admin/src/components/authentication/UserButton.svelte | 2 +- web-admin/src/components/navigation/TopNavigationBar.svelte | 4 ++-- .../view-as-user}/ViewAsUserChip.svelte | 2 +- .../view-as-user}/ViewAsUserMenuItem.svelte | 0 .../view-as-user}/ViewAsUserPopover.svelte | 2 +- .../view-as-user/clearViewedAsUserAfterNavigate.ts} | 4 ++-- .../view-as-user}/viewAsUserStore.ts | 0 web-admin/src/routes/+layout.svelte | 4 ++-- web-admin/src/routes/[organization]/[project]/+layout.svelte | 2 +- .../dashboards/granular-access-policies/updateMimickedJWT.ts | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) rename web-admin/src/{components/authentication => features/view-as-user}/ViewAsUserChip.svelte (97%) rename web-admin/src/{components/authentication => features/view-as-user}/ViewAsUserMenuItem.svelte (100%) rename web-admin/src/{components/authentication => features/view-as-user}/ViewAsUserPopover.svelte (97%) rename web-admin/src/{components/authentication/clearMimickedUserAfterNavigate.ts => features/view-as-user/clearViewedAsUserAfterNavigate.ts} (89%) rename web-admin/src/{components/authentication => features/view-as-user}/viewAsUserStore.ts (100%) diff --git a/web-admin/src/components/authentication/UserButton.svelte b/web-admin/src/components/authentication/UserButton.svelte index eb173fa7ee9..bc86f9ecb2b 100644 --- a/web-admin/src/components/authentication/UserButton.svelte +++ b/web-admin/src/components/authentication/UserButton.svelte @@ -11,8 +11,8 @@ import { createPopperActions } from "svelte-popperjs"; import { createAdminServiceGetCurrentUser } from "../../client"; import { ADMIN_URL } from "../../client/http-client"; + import ViewAsUserPopover from "../../features/view-as-user/ViewAsUserPopover.svelte"; import ProjectAccessControls from "../projects/ProjectAccessControls.svelte"; - import ViewAsUserPopover from "./ViewAsUserPopover.svelte"; const user = createAdminServiceGetCurrentUser(); diff --git a/web-admin/src/components/navigation/TopNavigationBar.svelte b/web-admin/src/components/navigation/TopNavigationBar.svelte index ed3eecdee9a..3e3d804d54b 100644 --- a/web-admin/src/components/navigation/TopNavigationBar.svelte +++ b/web-admin/src/components/navigation/TopNavigationBar.svelte @@ -4,10 +4,10 @@ import Tooltip from "@rilldata/web-common/components/tooltip/Tooltip.svelte"; import TooltipContent from "@rilldata/web-common/components/tooltip/TooltipContent.svelte"; import { createAdminServiceGetCurrentUser } from "../../client"; + import ViewAsUserChip from "../../features/view-as-user/ViewAsUserChip.svelte"; + import { viewAsUserStore } from "../../features/view-as-user/viewAsUserStore"; import SignIn from "../authentication/SignIn.svelte"; import UserButton from "../authentication/UserButton.svelte"; - import ViewAsUserChip from "../authentication/ViewAsUserChip.svelte"; - import { viewAsUserStore } from "../authentication/viewAsUserStore"; import { isErrorStoreEmpty } from "../errors/error-store"; import Breadcrumbs from "./Breadcrumbs.svelte"; diff --git a/web-admin/src/components/authentication/ViewAsUserChip.svelte b/web-admin/src/features/view-as-user/ViewAsUserChip.svelte similarity index 97% rename from web-admin/src/components/authentication/ViewAsUserChip.svelte rename to web-admin/src/features/view-as-user/ViewAsUserChip.svelte index e34932f586b..9b80342be87 100644 --- a/web-admin/src/components/authentication/ViewAsUserChip.svelte +++ b/web-admin/src/features/view-as-user/ViewAsUserChip.svelte @@ -11,7 +11,7 @@ import { updateMimickedJWT } from "@rilldata/web-common/features/dashboards/granular-access-policies/updateMimickedJWT"; import { useQueryClient } from "@tanstack/svelte-query"; import { createPopperActions } from "svelte-popperjs"; - import { errorStore } from "../errors/error-store"; + import { errorStore } from "../../components/errors/error-store"; import ViewAsUserPopover from "./ViewAsUserPopover.svelte"; import { viewAsUserStore } from "./viewAsUserStore"; diff --git a/web-admin/src/components/authentication/ViewAsUserMenuItem.svelte b/web-admin/src/features/view-as-user/ViewAsUserMenuItem.svelte similarity index 100% rename from web-admin/src/components/authentication/ViewAsUserMenuItem.svelte rename to web-admin/src/features/view-as-user/ViewAsUserMenuItem.svelte diff --git a/web-admin/src/components/authentication/ViewAsUserPopover.svelte b/web-admin/src/features/view-as-user/ViewAsUserPopover.svelte similarity index 97% rename from web-admin/src/components/authentication/ViewAsUserPopover.svelte rename to web-admin/src/features/view-as-user/ViewAsUserPopover.svelte index 23457fad8cb..14cd4a1fa97 100644 --- a/web-admin/src/components/authentication/ViewAsUserPopover.svelte +++ b/web-admin/src/features/view-as-user/ViewAsUserPopover.svelte @@ -8,7 +8,7 @@ import { matchSorter } from "match-sorter"; import { createEventDispatcher } from "svelte"; import { createAdminServiceSearchProjectUsers, V1User } from "../../client"; - import { errorStore } from "../errors/error-store"; + import { errorStore } from "../../components/errors/error-store"; import { viewAsUserStore } from "./viewAsUserStore"; export let organization: string; diff --git a/web-admin/src/components/authentication/clearMimickedUserAfterNavigate.ts b/web-admin/src/features/view-as-user/clearViewedAsUserAfterNavigate.ts similarity index 89% rename from web-admin/src/components/authentication/clearMimickedUserAfterNavigate.ts rename to web-admin/src/features/view-as-user/clearViewedAsUserAfterNavigate.ts index cfb0ae02024..ea8f55c9c65 100644 --- a/web-admin/src/components/authentication/clearMimickedUserAfterNavigate.ts +++ b/web-admin/src/features/view-as-user/clearViewedAsUserAfterNavigate.ts @@ -7,9 +7,9 @@ import { get } from "svelte/store"; import { viewAsUserStore } from "./viewAsUserStore"; /** - * Remove the mimicked user (if any) when navigating away from the Dashboard page + * Remove the viewed as user (if any) when navigating away from the Dashboard page */ -export function clearMimickedUserAfterNavigate(queryClient: QueryClient) { +export function clearViewedAsUserAfterNavigate(queryClient: QueryClient) { afterNavigate((nav) => { // Only applies if mimicking a user on the Dashboard page if (!get(viewAsUserStore) || !nav.from?.params?.dashboard) return; diff --git a/web-admin/src/components/authentication/viewAsUserStore.ts b/web-admin/src/features/view-as-user/viewAsUserStore.ts similarity index 100% rename from web-admin/src/components/authentication/viewAsUserStore.ts rename to web-admin/src/features/view-as-user/viewAsUserStore.ts diff --git a/web-admin/src/routes/+layout.svelte b/web-admin/src/routes/+layout.svelte index 14e0e82b123..f4e06f14a98 100644 --- a/web-admin/src/routes/+layout.svelte +++ b/web-admin/src/routes/+layout.svelte @@ -11,10 +11,10 @@ QueryClient, QueryClientProvider, } from "@tanstack/svelte-query"; - import { clearMimickedUserAfterNavigate } from "../components/authentication/clearMimickedUserAfterNavigate"; import { globalErrorCallback } from "../components/errors/error-utils"; import ErrorBoundary from "../components/errors/ErrorBoundary.svelte"; import TopNavigationBar from "../components/navigation/TopNavigationBar.svelte"; + import { clearViewedAsUserAfterNavigate } from "../features/view-as-user/clearViewedAsUserAfterNavigate"; const queryClient = new QueryClient({ queryCache: new QueryCache({ @@ -39,7 +39,7 @@ }); beforeNavigate(retainFeaturesFlags); - clearMimickedUserAfterNavigate(queryClient); + clearViewedAsUserAfterNavigate(queryClient); diff --git a/web-admin/src/routes/[organization]/[project]/+layout.svelte b/web-admin/src/routes/[organization]/[project]/+layout.svelte index b26ae8f2104..53fda2d656d 100644 --- a/web-admin/src/routes/[organization]/[project]/+layout.svelte +++ b/web-admin/src/routes/[organization]/[project]/+layout.svelte @@ -3,8 +3,8 @@ import { page } from "$app/stores"; import RuntimeProvider from "@rilldata/web-common/runtime-client/RuntimeProvider.svelte"; import { createAdminServiceGetDeploymentCredentials } from "../../../client"; - import { viewAsUserStore } from "../../../components/authentication/viewAsUserStore"; import { useProjectRuntime } from "../../../components/projects/selectors"; + import { viewAsUserStore } from "../../../features/view-as-user/viewAsUserStore"; $: projRuntime = useProjectRuntime( $page.params.organization, diff --git a/web-common/src/features/dashboards/granular-access-policies/updateMimickedJWT.ts b/web-common/src/features/dashboards/granular-access-policies/updateMimickedJWT.ts index 1c42240826a..81ab7e68083 100644 --- a/web-common/src/features/dashboards/granular-access-policies/updateMimickedJWT.ts +++ b/web-common/src/features/dashboards/granular-access-policies/updateMimickedJWT.ts @@ -5,7 +5,7 @@ import { V1GetProjectResponse, type V1User, } from "@rilldata/web-admin/client"; -import { viewAsUserStore } from "@rilldata/web-admin/components/authentication/viewAsUserStore"; +import { viewAsUserStore } from "@rilldata/web-admin/features/view-as-user/viewAsUserStore"; import { invalidateAllMetricsViews } from "@rilldata/web-common/runtime-client/invalidation"; import { runtime } from "@rilldata/web-common/runtime-client/runtime-store"; import type { QueryClient } from "@tanstack/svelte-query";