Skip to content

fix(dashboard): add explicit user/admin dashboard switching for admins - #6757

Closed
Iamliuxiaozhen wants to merge 1 commit into
QuantumNous:mainfrom
oliver-ForkHub:fix/admin-panel-and-user-panel-switch
Closed

Iamliuxiaozhen wants to merge 1 commit into
QuantumNous:mainfrom
oliver-ForkHub:fix/admin-panel-and-user-panel-switch

Conversation

@Iamliuxiaozhen

@Iamliuxiaozhen Iamliuxiaozhen commented Aug 10, 2026 •

Copy link
Copy Markdown

提交说明 / PR Notice

为了修复在管理员用户下无法通过UI显式回到自身用户面板

📝 变更描述 / Description

修复管理员账号同时作为普通用户使用时,无法通过 UI 显式切换到用户面板的问题。

之前管理员进入系统后,侧边栏中的入口只展示当前视角对应的面板入口。当管理员需要使用用户侧功能时,没有明显的入口返回用户面板,只能通过手动访问路径进入。

本次修改支持管理员用户在 UI 中直接切换:

  • 管理员面板(Admin Dashboard)
  • 用户面板(User Dashboard)

同时调整侧边栏父级导航配置,使一个页面可以支持多个导航入口,并保持普通用户原有的导航逻辑不变。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

none

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地完成手动验证,确认管理员用户可以正常切换管理员面板和用户面板。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(未补充或稍后补充)

Summary by CodeRabbit

  • New Features

    • Admin users can now switch between User Dashboard and Admin Dashboard from navigation menus.
    • Sidebar headers support multiple parent navigation links.
    • Added localized labels for dashboard navigation in supported languages.
  • Bug Fixes

    • Added support for the /admin/dashboard route, redirecting it to the appropriate channels view while preserving query parameters and URL fragments.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR adds multi-parent sidebar navigation, role-aware dashboard links, translations for dashboard labels, and an /admin/dashboard route alias that resolves to /channels while preserving URL parameters.

Changes

Dashboard navigation

Layer / File(s) Summary
Multi-parent sidebar navigation
web/src/components/layout/types.ts, web/src/components/layout/components/sidebar-view-header.tsx, web/src/components/layout/config/system-settings.config.ts
SidebarView supports parentLinks. The sidebar renders each configured link. System settings adds Admin Dashboard and User Dashboard destinations.
Role-aware top navigation and labels
web/src/hooks/use-top-nav-links.ts, web/src/i18n/locales/*, web/src/i18n/static-keys.ts
Administrators receive Admin Dashboard and User Dashboard links. Other users retain the Console link. The new labels are localized and registered as static keys.
Admin dashboard route alias
web/src/lib/legacy-route.ts, web/src/lib/legacy-route.test.ts
/admin/dashboard maps to /channels. Tests cover preservation of query parameters and hash fragments.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Poem

A rabbit hops through links so bright,
Admin and User dashboards in sight.
Sidebars branch with paths anew,
Old routes guide to channels too.
Translated labels softly glow—
Navigation now knows where to go.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: explicit switching between user and admin dashboards for administrators.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/src/components/layout/config/system-settings.config.ts (1)

100-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive parent from parentLinks to avoid duplicated data.

parent and the first entry of parentLinks hold the same to and label values. Keep one source of truth. Derive parent from parentLinks[0] so a future edit to the Admin Dashboard entry cannot drift out of sync with parent.

♻️ 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9c97e78 and e48eb39.

📒 Files selected for processing (14)
  • web/src/components/layout/components/sidebar-view-header.tsx
  • web/src/components/layout/config/system-settings.config.ts
  • web/src/components/layout/types.ts
  • web/src/hooks/use-top-nav-links.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/zh.json
  • web/src/i18n/static-keys.ts
  • web/src/lib/legacy-route.test.ts
  • web/src/lib/legacy-route.ts

"Admin access required": "需要管理員權限",
"Admin area": "管理員區域",
"Admin Channel Permissions": "管理員渠道權限",
"Admin Dashboard": "管理員面板",

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.

📐 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.

@Calcium-Ion
Calcium-Ion force-pushed the main branch 2 times, most recently from 51fdfc5 to 2b6f1df Compare August 30, 2026 15:03
@seefs001 seefs001 closed this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants