Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: extend View As functionality to project home page
- Modified AvatarButton.svelte to show 'View As' option on all project pages,
  not just dashboard pages (removed dashboard param requirement)
- Updated navigation behavior to preserve 'View As' state when navigating
  within the same project, only clearing when switching projects
- Alerts/Reports links in avatar menu now only show when on a dashboard page

Resolves PM-103

Co-authored-by: eric.okuma <eric.okuma@rilldata.com>
  • Loading branch information
cursoragent and ericokuma committed Jan 30, 2026
commit 3fc067890a4d06ff3ec9b9d78e50dd088f5e34f9
24 changes: 13 additions & 11 deletions web-admin/src/features/authentication/AvatarButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
{#if params.organization && params.project && params.dashboard}
{#if params.organization && params.project}
<ProjectAccessControls
organization={params.organization}
project={params.project}
Expand Down Expand Up @@ -71,16 +71,18 @@
</DropdownMenu.Sub>
</svelte:fragment>
</ProjectAccessControls>
<DropdownMenu.Item
href={`/${params.organization}/${params.project}/-/alerts`}
>
Alerts
</DropdownMenu.Item>
<DropdownMenu.Item
href={`/${params.organization}/${params.project}/-/reports`}
>
Reports
</DropdownMenu.Item>
{#if params.dashboard}
<DropdownMenu.Item
href={`/${params.organization}/${params.project}/-/alerts`}
>
Alerts
</DropdownMenu.Item>
<DropdownMenu.Item
href={`/${params.organization}/${params.project}/-/reports`}
>
Reports
</DropdownMenu.Item>
{/if}
{/if}

<ThemeToggle />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@
);

onNavigate(({ from, to }) => {
viewAsUserStore.set(null);
// Only clear "View As" state when navigating outside of the current project
const changedProject =
!from ||
!to ||
from.params.organization !== to.params.organization ||
from.params.project !== to.params.project;
if (changedProject) {
viewAsUserStore.set(null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This navigation guard should move to the project layout (+layout.svelte) so it covers all project pages — home, settings, status, etc. With View As now available on the home page, activating it there and navigating to a different project won't trigger this guard since the dashboard page is never mounted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This navigation guard should move to the project layout (+layout.svelte) so it covers all project pages — home, settings, status, etc. With View As now available on the home page, activating it there and navigating to a different project won't trigger this guard since the dashboard page is never mounted.

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

onNavigate clears org-level view-as on project change

High Severity

The onNavigate callback in the explore page calls clearViewAsUser() unconditionally when the project changes, without checking whether the view-as state has isOrgLevel: true. This contradicts the design in isViewAsValidForProject (which returns true for org-level) and the TopNavigationBar reactive block (which skips clearing when isOrgLevel is true). When an org admin navigates from one project's dashboard to another, the org-level view-as state is incorrectly wiped out.

Additional Locations (2)

Fix in Cursor Fix in Web

errorStore.reset();

const changedDashboard =
Expand Down
Loading