From b0b05b49c51c26eafd97ad55e3cd04d4044fe7f2 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Mon, 18 May 2026 10:59:12 +0800 Subject: [PATCH] feat(tenant): enhance tenant information update with description field and add global invitation bell component Updated the tenant information API to allow editing of both name and description fields, improving user experience in managing tenant details. Introduced a new GlobalInvitationBell component to display pending invitations in the UI, ensuring users can easily access their invitations without navigating away from their current context. Additionally, updated internationalization files to support new description-related messages. Refs: #1303 --- frontend/src/api/tenant/index.ts | 8 +- .../src/components/GlobalInvitationBell.vue | 72 +++++++++ frontend/src/components/UserMenu.vue | 71 --------- frontend/src/i18n/locales/en-US.ts | 7 +- frontend/src/i18n/locales/ko-KR.ts | 5 + frontend/src/i18n/locales/ru-RU.ts | 7 +- frontend/src/i18n/locales/zh-CN.ts | 5 + .../OrganizationSettingsModal.vue | 33 ++-- frontend/src/views/platform/index.vue | 4 + frontend/src/views/settings/TenantInfo.vue | 149 +++++++++++++++++- frontend/src/views/settings/TenantMembers.vue | 72 ++++----- 11 files changed, 291 insertions(+), 142 deletions(-) create mode 100644 frontend/src/components/GlobalInvitationBell.vue diff --git a/frontend/src/api/tenant/index.ts b/frontend/src/api/tenant/index.ts index f3f1a9c2..645e9551 100644 --- a/frontend/src/api/tenant/index.ts +++ b/frontend/src/api/tenant/index.ts @@ -71,14 +71,14 @@ export async function resetTenantApiKey( } /** - * 更新租户信息(目前仅暴露租户名称编辑入口)。 - * 后端 `PUT /tenants/:id` 走 GORM 的 `Updates(tenant)`,只会写入请求体里 - * 出现的非零字段;这里只发送 `name` 就只会改名字,不会把其它字段清空。 + * 更新租户信息(目前暴露名称、描述两个字段的编辑入口)。 + * 后端 `PUT /tenants/:id` 用指针字段区分"未传"和"显式空串",未传的列不会 + * 被改动;这里也按需选择性传 `name` / `description`,互不影响。 * 权限:owner(与 router.go 中的 g.Owner() 守卫保持一致)。 */ export async function updateTenant( tenantId: number, - payload: { name: string }, + payload: { name?: string; description?: string }, ): Promise<{ success: boolean; data?: TenantInfo; message?: string }> { try { const response = await put(`/api/v1/tenants/${tenantId}`, payload) diff --git a/frontend/src/components/GlobalInvitationBell.vue b/frontend/src/components/GlobalInvitationBell.vue new file mode 100644 index 00000000..0847b644 --- /dev/null +++ b/frontend/src/components/GlobalInvitationBell.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/frontend/src/components/UserMenu.vue b/frontend/src/components/UserMenu.vue index c6671547..f2133c7e 100644 --- a/frontend/src/components/UserMenu.vue +++ b/frontend/src/components/UserMenu.vue @@ -24,19 +24,6 @@
{{ userEmail }}
- - - - @@ -231,7 +218,6 @@ - @@ -245,7 +231,6 @@ import { getCurrentUser, logout as logoutApi } from '@/api/auth' import { useI18n } from 'vue-i18n' import IMChannelsOverviewPanel from '@/components/IMChannelsOverviewPanel.vue' import CreateTenantDialog from '@/components/CreateTenantDialog.vue' -import MyInvitationsDialog from '@/components/MyInvitationsDialog.vue' import { listAllIMChannels, type IMChannelOverview } from '@/api/agent' import { navigateAfterTenantSwitch } from '@/utils/tenantSwitch' import type { TenantInfo } from '@/api/tenant' @@ -327,25 +312,6 @@ const toggleMenu = () => { menuVisible.value = !menuVisible.value } -// Pending invitation count surfaced as the trailing bell on the -// avatar row. Reads directly from the auth store so the App.vue -// poller and any local accept/decline updates flow through here -// without a separate fetch. The visual badge cap (99+) is handled -// by t-badge's max-count, so we just expose the raw count. -const pendingInvitationCount = computed(() => authStore.pendingInvitationCount) - -// Clicking the bell opens the invitations dialog inline. Previously -// this navigated to /platform/invitations, but the inbox is short- -// lived ("see what's pending, accept or decline, dismiss") and a -// dialog keeps the user in whatever context they came from. We -// also close the avatar dropdown if it's open so the modal doesn't -// fight with a stale hover panel. -const invitationsDialogVisible = ref(false) -const goToInvitations = () => { - menuVisible.value = false - invitationsDialogVisible.value = true -} - // 快捷导航到设置的特定部分 const handleQuickNav = (section: string) => { menuVisible.value = false @@ -853,43 +819,6 @@ onUnmounted(() => { transition: transform 0.2s; } -/* Pending-invitations bell, sits between user-info and the chevron. - The button itself is a transparent 28x28 click target sized to - match the avatar row's other trailing affordances; t-badge wraps - it and positions its own counter pill in the top-right via the - :offset prop, so we don't try to recreate badge positioning here. */ -.user-inbox-badge-wrap { - display: inline-flex; - align-items: center; - margin: 0 2px; - flex-shrink: 0; -} - -.user-inbox-btn { - display: inline-flex; - align-items: center; - justify-content: center; - width: 28px; - height: 28px; - padding: 0; - border: none; - border-radius: 8px; - background: transparent; - color: var(--td-text-color-secondary); - cursor: pointer; - transition: background-color 0.18s ease, color 0.18s ease; - - &:hover { - background-color: var(--td-bg-color-secondarycontainer); - color: var(--td-brand-color); - } - - &:focus-visible { - outline: 2px solid var(--td-brand-color-focus); - outline-offset: 1px; - } -} - .user-dropdown { position: absolute; bottom: 100%; diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 3bcf8f9b..ad16e892 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -2411,7 +2411,12 @@ export default { editNameCancel: 'Cancel', editNameRequired: 'Tenant name cannot be empty', editNameSuccess: 'Tenant name updated', - editNameFailed: 'Failed to update tenant name' + editNameFailed: 'Failed to update tenant name', + editDescription: 'Edit description', + editDescriptionPlaceholder: 'Enter the new tenant description', + editDescriptionSuccess: 'Tenant description updated', + editDescriptionFailed: 'Failed to update tenant description', + descriptionEmptyPlaceholder: 'Not set' }, storage: { quotaLabel: 'Storage Quota', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 4c533a4f..ad61a695 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -1662,6 +1662,11 @@ export default { editNameRequired: "테넌트 이름은 비어 있을 수 없습니다", editNameSuccess: "테넌트 이름이 업데이트되었습니다", editNameFailed: "테넌트 이름 업데이트 실패", + editDescription: "설명 수정", + editDescriptionPlaceholder: "새 테넌트 설명을 입력하세요", + editDescriptionSuccess: "테넌트 설명이 업데이트되었습니다", + editDescriptionFailed: "테넌트 설명 업데이트 실패", + descriptionEmptyPlaceholder: "미입력", }, storage: { quotaLabel: "저장소 할당량", diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 7ae39fda..b70e4fb3 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -1459,7 +1459,12 @@ export default { editNameCancel: 'Отмена', editNameRequired: 'Имя арендатора не может быть пустым', editNameSuccess: 'Имя арендатора обновлено', - editNameFailed: 'Не удалось обновить имя арендатора' + editNameFailed: 'Не удалось обновить имя арендатора', + editDescription: 'Изменить описание', + editDescriptionPlaceholder: 'Введите новое описание арендатора', + editDescriptionSuccess: 'Описание арендатора обновлено', + editDescriptionFailed: 'Не удалось обновить описание арендатора', + descriptionEmptyPlaceholder: 'Не указано' }, storage: { quotaLabel: 'Квота хранения', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index c4878b0a..b6e11173 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -1642,6 +1642,11 @@ export default { editNameRequired: "空间名称不能为空", editNameSuccess: "空间名称已更新", editNameFailed: "更新空间名称失败", + editDescription: "修改描述", + editDescriptionPlaceholder: "请输入新的空间描述", + editDescriptionSuccess: "空间描述已更新", + editDescriptionFailed: "更新空间描述失败", + descriptionEmptyPlaceholder: "未填写", }, storage: { quotaLabel: "存储配额", diff --git a/frontend/src/views/organization/OrganizationSettingsModal.vue b/frontend/src/views/organization/OrganizationSettingsModal.vue index 0163cd1b..2605a3d3 100644 --- a/frontend/src/views/organization/OrganizationSettingsModal.vue +++ b/frontend/src/views/organization/OrganizationSettingsModal.vue @@ -359,9 +359,16 @@
- - - + + + + +
@@ -610,12 +617,6 @@
- - -

{{ $t('organization.detail.removeMemberConfirm', { name: removingMember?.username }) }}

-
- (null) -const showRemoveDialog = ref(false) -const removingMember = ref(null) const showUpgradeDialog = ref(false) const upgradeSubmitting = ref(false) const hasPendingUpgrade = ref(false) @@ -1178,19 +1177,13 @@ const handleRoleChange = async (member: OrganizationMember, newRole: string) => } } -const handleRemoveMember = (member: OrganizationMember) => { - removingMember.value = member - showRemoveDialog.value = true -} - -const confirmRemoveMember = async () => { - if (!removingMember.value || !props.orgId) return +const confirmRemoveMember = async (member: OrganizationMember) => { + if (!props.orgId) return try { - const res = await removeMember(props.orgId, removingMember.value.tenant_id) + const res = await removeMember(props.orgId, member.tenant_id) if (res.success) { MessagePlugin.success(t('organization.memberRemoved')) - showRemoveDialog.value = false fetchMembers() } else { MessagePlugin.error(res.message || t('organization.memberRemoveFailed')) diff --git a/frontend/src/views/platform/index.vue b/frontend/src/views/platform/index.vue index 0fd75e3a..9913bf20 100644 --- a/frontend/src/views/platform/index.vue +++ b/frontend/src/views/platform/index.vue @@ -12,6 +12,9 @@ + +