Repository navigation
fix(dashboard): add explicit user/admin dashboard switching for admins - #6757
Iamliuxiaozhen wants to merge 1 commit into
Conversation
WalkthroughThe PR adds multi-parent sidebar navigation, role-aware dashboard links, translations for dashboard labels, and an ChangesDashboard navigation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
web/src/components/layout/config/system-settings.config.ts (1)
100-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDerive
parentfromparentLinksto avoid duplicated data.
parentand the first entry ofparentLinkshold the sametoandlabelvalues. Keep one source of truth. DeriveparentfromparentLinks[0]so a future edit to the Admin Dashboard entry cannot drift out of sync withparent.♻️ Proposed fix to derive `parent` from `parentLinks`
+const ADMIN_DASHBOARD_PARENT: SidebarViewParent = { + to: '/admin/dashboard', + label: 'Admin Dashboard', +} + export const SYSTEM_SETTINGS_VIEW: SidebarView = { id: 'system-settings', pathPattern: /^\/system-settings(\/|$)/, - parent: { - to: '/admin/dashboard', - label: 'Admin Dashboard', - }, + parent: ADMIN_DASHBOARD_PARENT, parentLinks: [ - { - to: '/admin/dashboard', - label: 'Admin Dashboard', - }, + ADMIN_DASHBOARD_PARENT, { to: '/dashboard', label: 'User Dashboard', }, ],🤖 Prompt for 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. In `@web/src/components/layout/config/system-settings.config.ts` around lines 100 - 116, Update SYSTEM_SETTINGS_VIEW so parent is derived from the first entry of parentLinks instead of defining duplicate to and label values. Preserve the Admin Dashboard entry as parentLinks[0] and ensure parent continues to reference that same configuration.
🤖 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 `@web/src/i18n/locales/zh-TW.json`:
- Line 238: Update the `Admin Dashboard` and `User Dashboard` translations in
the zh-TW locale to use the established dashboard terminology and consistent
`User` translation, matching the existing `用戶儀表板` wording and the locale’s
preferred `儀表板` or `看板` label.
---
Nitpick comments:
In `@web/src/components/layout/config/system-settings.config.ts`:
- Around line 100-116: Update SYSTEM_SETTINGS_VIEW so parent is derived from the
first entry of parentLinks instead of defining duplicate to and label values.
Preserve the Admin Dashboard entry as parentLinks[0] and ensure parent continues
to reference that same configuration.
🪄 Autofix
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: CHILL
Plan: Pro Plus
Run ID: 8c895f15-08d7-4c64-ad7c-bddd781414f2
📒 Files selected for processing (14)
web/src/components/layout/components/sidebar-view-header.tsxweb/src/components/layout/config/system-settings.config.tsweb/src/components/layout/types.tsweb/src/hooks/use-top-nav-links.tsweb/src/i18n/locales/en.jsonweb/src/i18n/locales/fr.jsonweb/src/i18n/locales/ja.jsonweb/src/i18n/locales/ru.jsonweb/src/i18n/locales/vi.jsonweb/src/i18n/locales/zh-TW.jsonweb/src/i18n/locales/zh.jsonweb/src/i18n/static-keys.tsweb/src/lib/legacy-route.test.tsweb/src/lib/legacy-route.ts
| "Admin access required": "需要管理員權限", | ||
| "Admin area": "管理員區域", | ||
| "Admin Channel Permissions": "管理員渠道權限", | ||
| "Admin Dashboard": "管理員面板", |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use consistent Traditional Chinese dashboard labels.
At Line [238], Admin Dashboard uses 面板, while this locale uses 儀表板 or 看板 for dashboard labels. At Line [4981], User Dashboard changes User from the usual 用戶 to 使用者; the existing User dashboard and quota controls. entry uses 用戶儀表板. Align these translations with the existing terminology.
Suggested values
- "Admin Dashboard": "管理員面板",
+ "Admin Dashboard": "管理員儀表板",
...
- "User Dashboard": "使用者面板",
+ "User Dashboard": "用戶儀表板",Also applies to: 4981-4981
🤖 Prompt for 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.
In `@web/src/i18n/locales/zh-TW.json` at line 238, Update the `Admin Dashboard`
and `User Dashboard` translations in the zh-TW locale to use the established
dashboard terminology and consistent `User` translation, matching the existing
`用戶儀表板` wording and the locale’s preferred `儀表板` or `看板` label.
51fdfc5 to
2b6f1df
Compare
提交说明 / PR Notice
为了修复在管理员用户下无法通过UI显式回到自身用户面板
📝 变更描述 / Description
修复管理员账号同时作为普通用户使用时,无法通过 UI 显式切换到用户面板的问题。
之前管理员进入系统后,侧边栏中的入口只展示当前视角对应的面板入口。当管理员需要使用用户侧功能时,没有明显的入口返回用户面板,只能通过手动访问路径进入。
本次修改支持管理员用户在 UI 中直接切换:
同时调整侧边栏父级导航配置,使一个页面可以支持多个导航入口,并保持普通用户原有的导航逻辑不变。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
none
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(未补充或稍后补充)
Summary by CodeRabbit
New Features
Bug Fixes
/admin/dashboardroute, redirecting it to the appropriate channels view while preserving query parameters and URL fragments.