feat(rbac-ui): rework tenant identity surfaces

Polish the role-aware UI surfaces wired up in #1303 so role / tenant
context is discoverable from the main shell rather than buried in a
hover-only switcher or the settings drawer.

UserMenu sidebar trigger:
- Replace username + email with `tenant name / username · role-icon
  role-name` so the active tenant + current role are always visible at
  the bottom of the sidebar; long usernames elide before the role label.
- Single-tenant users keep the old username + email layout.

UserMenu dropdown:
- Promote the tenant switcher to a clickable header row at the top of
  the dropdown (tenant name + swap icon, role caption underneath).
- Drop the standalone "Switch tenant" submenu entry — the header row
  hosts the same hover panel.
- Switcher panel rows now lead the role label with a role icon
  (owner / admin / contributor / viewer) and surface the home tenant
  via a small home dot on the avatar instead of a separate badge, so
  the right-edge "current" badge column lines up across rows.

Settings:
- Add SECTION_MIN_ROLE so settings nav entries are gated by the same
  role matrix the backend enforces (chathistory + ollama + websearch +
  vectorstore + parser + storage + mcp → admin; api → owner; rest →
  viewer). UserMenu quickNav uses the same map.
- Render a role-denied empty state when a user deep-links into a
  section their role can't reach.
- Split account info (id / username / email / created_at) out of the
  owner-only API Info page into a new viewer-accessible UserProfile
  section.

Composable:
- New useRoleLabel composable centralises role → label and role → icon
  mapping (consumed by UserMenu trigger / dropdown / switcher panel).
- useHomeTenant derives the home tenant id from `user.tenant_id` (the
  immutable signup-time field), not `tenant.id` which now reflects the
  active tenant after a switch.

Lists:
- KnowledgeBaseList / AgentList default the sidebar selection to "all"
  for viewers (who typically own nothing) so the empty "Mine" state no
  longer hides the shared content they actually have access to;
  contributor+ keeps "Mine" as the default.

i18n:
- Tenant role labels: 拥有者/贡献者/查看者 → 所有者/编辑/访客 (all four
  locales updated, plus new userProfile / roleDenied / homeBadge keys).

The org-vs-tenant scope question raised during review is intentionally
out of scope here — that needs an RFC before any UI/backend changes.
This commit is contained in:
wizardchen
2026-05-15 17:49:16 +08:00
committed by lyingbug
parent 2c34446425
commit e7f9a6580a
11 changed files with 780 additions and 134 deletions
+13
View File
@@ -518,6 +518,10 @@ export default {
workspace: "공간 및 권한",
system: "시스템 정보",
},
roleDenied: {
title: "권한 없음",
desc: "현재 역할로는 이 설정 페이지에 접근할 수 없습니다. 이 테넌트의 관리자에게 필요한 역할을 요청하세요.",
},
weknoraCloud: {
title: 'WeKnora Cloud',
description: 'WeKnora Cloud APPID 및 APPSECRET 자격 증명을 설정합니다. 자격 증명은 모델 서비스와 문서 파싱 엔진에 사용됩니다.',
@@ -1536,8 +1540,13 @@ export default {
switcher: {
menuLabel: "테넌트 전환",
currentBadge: "현재",
homeBadge: "Home",
homeTooltip: "기본 테넌트",
empty: "현재 하나의 테넌트에만 속해 있습니다",
},
currentChip: {
home: "기본 테넌트",
},
sectionDescription: "테넌트의 상세 설정 정보 보기",
apiDocument: "API 문서",
name: "테넌트 이름",
@@ -4375,6 +4384,10 @@ export default {
confirmRemoveBody:
"저장된 credential이 영구적으로 삭제되며, 이를 사용하는 통합은 새 값을 구성할 때까지 동작하지 않습니다.",
},
userProfile: {
title: "사용자 정보",
description: "계정 기본 정보(사용자 ID, 사용자 이름, 이메일, 가입 시각)를 확인합니다.",
},
tenantMember: {
title: "멤버 관리",
sectionDescription: "테넌트에 동료를 초대하고 역할을 관리합니다. 소유자만 멤버를 추가하거나 제거할 수 있습니다.",