Conversation
- 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>
|
Cursor Agent can help with this pull request. Just |
- Enhanced viewAsUserStore to track project context: - Added ViewAsUserState interface with user and projectContext fields - Added setViewAsUser() and clearViewAsUser() helper functions - Added isViewAsValidForProject() to validate view-as state - Maintained backward compatibility with derived viewAsUserStore - Updated TopNavigationBar to handle view-as scope: - Auto-clears view-as when navigating to project where it's not valid - Only shows ViewAsUserChip when valid for current context - Passes isOrgAdmin flag to child components - Updated AvatarButton to accept isOrgAdmin prop and pass to popover - Updated ViewAsUserPopover with isOrgLevel prop to determine scope - Updated ViewAsUserChip to use new store functions Org-level admins can view-as across all projects in the org. Project-level admins can only view-as within their specific project. Resolves PM-103 Co-authored-by: eric.okuma <eric.okuma@rilldata.com>
- Changed ViewAsUserState to use sourceProject + isOrgLevel instead of projectContext: null for org-level - sourceProject always stores where view-as was activated (for user query) - isOrgLevel boolean determines if view-as persists across projects - Fixed ViewAsUserChip to use sourceProject for user dropdown query - Added enabled check to user search query to prevent empty requests - Simplified TopNavigationBar clearing logic This fixes the issue where the dropdown showed empty user list when navigating to org level, because we lost track of which project's users to query. Co-authored-by: eric.okuma <eric.okuma@rilldata.com>
- Created ViewAsUserOrgPopover component with two-step flow: 1. First select a project from the organization 2. Then select a user from that project - Updated AvatarButton to show View As option at org level for org admins - The org-level view-as is always set with isOrgLevel=true so it persists across projects This allows org admins to test security policies without first navigating to a specific project. Co-authored-by: eric.okuma <eric.okuma@rilldata.com>
- Updated ViewAsUserOrgPopover to use createAdminServiceListOrganizationMemberUsers API instead of requiring project selection first - Shows all organization members directly in the dropdown - Maps V1OrganizationMemberUser to V1User format for consistency - Updated ViewAsUserChip to use org popover when at org level or when view-as was activated at org level - Uses '__org_level__' as sourceProject marker for org-level activations Co-authored-by: eric.okuma <eric.okuma@rilldata.com>
Co-authored-by: eric.okuma <eric.okuma@rilldata.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on March 4
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| from.params.project !== to.params.project; | ||
| if (changedProject) { | ||
| clearViewAsUser(); | ||
| } |
There was a problem hiding this comment.
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)
The onNavigate callback in the explore page was unconditionally clearing the view-as state when the project changed, ignoring the isOrgLevel flag. Now it checks if the view-as state is org-level before clearing: - Project-scoped view-as: cleared when navigating to different project - Org-level view-as: preserved when navigating between projects Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
When viewing as another user, hide admin-only features to simulate what the impersonated user would see: - ProjectTabs: Hide Status and Settings tabs - TopNavigationBar: Hide Share Project button This provides a more accurate simulation of the impersonated user's experience, not just their data access. Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
When View As is active, fetch the impersonated user's project membership to get their role (admin/editor/viewer), then use that role to compute their effective UI permissions. Changes: - Added getViewAsUserPermissions.ts with role-to-permissions mapping - Updated project layout to fetch view-as user's role and compute effective permissions for ProjectTabs - Updated TopNavigationBar to fetch view-as user's role and compute effective permissions for Share button visibility - Removed hard-coded permission hiding in favor of role-based permissions This ensures that when viewing as an admin, admin features are still visible, but when viewing as a viewer, admin features are hidden. Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
When View As is active, also fetch the impersonated user's org membership to get their org role, and use that to compute effective org permissions. Changes: - Added orgRoleToPermissions() and getEffectiveOrgPermissions() to map org roles (admin/editor/viewer) to org permissions - Updated root layout to fetch view-as user's org role and compute effective org permissions - OrganizationTabs now uses effective org permissions (Users/Settings tabs hidden for viewers) - TopNavigationBar receives effective org permissions - BillingBannerManager also receives effective org permissions This ensures that when viewing as an org-level viewer: - Org Users tab is hidden - Org Settings tab is hidden - Project-level admin features are also hidden based on their project role Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>


Extends the "View As" functionality to all project-level pages, including Project Home (PM-103).
The "View As" option is now available from the avatar dropdown on any project page, not just dashboard-specific pages. The selected user state will persist when navigating between pages within the same project, providing a consistent impersonation experience. This leverages the existing project-level runtime credential switching infrastructure.
Checklist:
Linear Issue: PM-103
Note
Medium Risk
Touches global navigation/state for impersonation and changes when credentials are cleared/persisted across routes, which can cause confusing access context if edge cases are missed, but it’s limited to UI/state management with explicit validity checks.
Overview
Extends "View As" impersonation to be available from the avatar menu on any project page (not just dashboards) and makes the active state persist while navigating within the same project.
Refactors
viewAsUserStoreto track{ user, sourceProject, isOrgLevel }, addsclearViewAsUser/isViewAsValidForProject, and updates navigation/chip rendering to clear or hide invalid project-scoped impersonations; org admins can also start an org-level view-as from org pages via a newViewAsUserOrgPopoverthat lists org members.Written by Cursor Bugbot for commit 02243ff. This will update automatically on new commits. Configure here.