fix(rbac): polish tenant member UI; add /leave endpoint
Self-review of PR 3's TenantMembers.vue surfaced a handful of real bugs
and a few rough edges. This commit fixes them and adds the self-leave
endpoint that PR 3's design called out as a follow-up.
Frontend bug fixes
- Read err.status (not err.response.status). The axios interceptor in
utils/request.ts already flattens errors into { status, message,
... }, so the original branch-by-status code never matched and every
4xx fell through to the generic toast. Fixes 404/409 surfacing as
"userNotFound" / "alreadyMember" / "lastOwner" instead of "Something
went wrong".
- t-dialog @confirm replaces :on-confirm so the dialog stays open on
validation failure and on API error. Users can fix and retry without
retyping the email.
- Drop the t-select revert hack; with :model-value the rendered value
is already source-of-truth-on-row.role, so no setTimeout dance is
needed.
- Don't toast "no active tenant" on cold mount; watch the activeTenantId
ref and load once the auth store hydrates.
Frontend UX additions
- Empty state via t-empty (also covers the search-no-results case).
- Compact role-permissions matrix above the table, mirroring
OrganizationSettingsModal so Owners can see what each role grants
before promoting/inviting.
- Search box filtering by username/email (client-side, sufficient for
expected per-tenant member counts).
- "Leave Tenant" button — visible to any active member except the
last-Owner case (server still enforces).
Backend
- New POST /tenants/:id/leave route. Calls TenantMemberService.RemoveMember
with the caller's own user id so non-Owners can quit on their own.
Gated Viewer+ in the matrix; the existing last-Owner invariant in the
service still rejects last-Owner self-leave with 409.
- 3 new handler tests cover the happy path, the last-Owner 409 path,
and the missing-caller-id 401 path (defensive — auth middleware
always attaches a user, but the test pins the contract).
i18n
- Add tenantMember.permissions / search / leave / empty strings in all
four locales (en/zh/ko/ru).
This commit is contained in:
@@ -4309,6 +4309,18 @@ export default {
|
||||
totalCount: '{n} members',
|
||||
loading: 'Loading members…',
|
||||
retry: 'Retry',
|
||||
empty: 'No members yet. Invite a teammate to get started.',
|
||||
emptySearch: 'No members match "{q}".',
|
||||
searchPlaceholder: 'Search by name or email',
|
||||
permissions: {
|
||||
title: 'Role permissions',
|
||||
desc: 'What each role can do inside this tenant. Server-enforced; UI controls reflect the rules but are not the source of truth.',
|
||||
manageMembers: 'Manage members',
|
||||
manageTenantConfig: 'Edit tenant settings',
|
||||
manageInfra: 'Configure models / vector stores / IM channels',
|
||||
createOwnKB: 'Create and edit own KBs and agents',
|
||||
readAll: 'Read tenant content',
|
||||
},
|
||||
columns: {
|
||||
username: 'Name',
|
||||
email: 'Email',
|
||||
@@ -4337,6 +4349,13 @@ export default {
|
||||
confirm: 'Remove',
|
||||
success: 'Member removed',
|
||||
},
|
||||
leave: {
|
||||
button: 'Leave Tenant',
|
||||
confirmTitle: 'Leave this tenant?',
|
||||
confirmBody: 'You will lose access to all knowledge bases and agents in this tenant. You can be re-invited later.',
|
||||
confirm: 'Leave',
|
||||
success: 'You have left the tenant',
|
||||
},
|
||||
roleChange: {
|
||||
success: 'Role updated',
|
||||
},
|
||||
@@ -4346,9 +4365,10 @@ export default {
|
||||
roleRequired: 'Role is required',
|
||||
userNotFound: 'No registered user with this email. Ask them to sign up first.',
|
||||
alreadyMember: 'This user is already a member of the tenant.',
|
||||
lastOwner: 'Cannot demote or remove the last Owner. Promote another member to Owner first.',
|
||||
lastOwner: 'Cannot demote, remove, or leave as the last Owner. Promote another member to Owner first.',
|
||||
notFound: 'Membership not found.',
|
||||
noTenant: 'No active tenant.',
|
||||
invalidRole: 'Role must be one of owner / admin / contributor / viewer.',
|
||||
generic: 'Something went wrong. Please try again.',
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user