feat(sidebar): hide unauthorized settings buttons in the sidebar for non-admins#596
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughSettings access is gated by role and permission: WorkspaceHomeView computes a role-based settingsPath; WorkspaceSettingsView conditionally renders admin-only nav items (General, Danger zone); WorkspaceSettingsRoute hoists the "settings:manage" permission and chooses the default settings tab from permissions/role. ChangesRole-based settings access control
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
LGTM. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for contributing to Dembrane ECHO! Before we consider your Pull Request, we ask that you sign our Contributor License Agreement (CLA). This is only required for your first Pull Request. Please review the CLA, and sign it by adding your GitHub username to the contributors.yml file. Thanks! |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@echo/frontend/src/features/sidebar/views/workspace/WorkspaceHomeView.tsx`:
- Around line 35-39: The sidebar computes settingsPath but the Settings nav link
is still hardcoded to "/settings/general"; update the Settings nav target to use
the computed settingsPath (replace the hardcoded string used where the nav item
is rendered, e.g., the link or NavItem that currently points to
"/settings/general") so admins go to general and non-admins to billing or
members based on isAdmin/isBilling logic in WorkspaceHomeView and the
settingsPath constant.
In `@echo/frontend/src/routes/workspaces/WorkspaceSettingsRoute.tsx`:
- Around line 467-473: The current default-tab computation and redirect run
before `settings` is loaded causing wrong tab lock-in; update
`WorkspaceSettingsRoute` to defer computing `canEditSettings`/`defaultTab` and
performing the redirect until `settings` is non-null (or a loading flag is
false). Specifically, guard or delay the logic that reads
`settings?.my_policies` and `settings?.my_role` (the `canEditSettings` and
`defaultTab` calculations) and the subsequent redirect code block (the code
around lines handling tab selection/redirect) so it only executes when
`settings` is available, leaving the route idle or showing a loader until then.
Ensure `defaultTab: TabValue` is derived from `settings` inside that guarded
branch to avoid landing billing/admin users on `members` prematurely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 54218718-1636-4600-a922-e623356f7b8d
📒 Files selected for processing (3)
echo/frontend/src/features/sidebar/views/workspace/WorkspaceHomeView.tsxecho/frontend/src/features/sidebar/views/workspace/WorkspaceSettingsView.tsxecho/frontend/src/routes/workspaces/WorkspaceSettingsRoute.tsx
What this changes
canEditSettingsvariable declaration inWorkspaceSettingsRoute.tsxand simplified default tab resolution.Confidence: High. Safe, client-side, UI-only change using the established
isAdminRoleand role-policies logic.Summary by CodeRabbit
New Features
Improvements