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
This commit is contained in:
@@ -359,9 +359,16 @@
|
||||
</t-tag>
|
||||
</div>
|
||||
<div v-if="isAdmin && !isOwnerMember(member)" class="member-actions">
|
||||
<t-button variant="text" theme="danger" size="small" @click="handleRemoveMember(member)">
|
||||
<t-icon name="delete" />
|
||||
</t-button>
|
||||
<t-popconfirm
|
||||
:content="$t('organization.detail.removeMemberConfirm', { name: memberPrimaryLabel(member) })"
|
||||
:confirm-btn="{ content: $t('common.confirm'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }"
|
||||
placement="left"
|
||||
@confirm="confirmRemoveMember(member)">
|
||||
<t-button variant="text" theme="danger" size="small" @click.stop>
|
||||
<t-icon name="delete" />
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="filteredMembers.length === 0" class="empty-members">
|
||||
@@ -610,12 +617,6 @@
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<!-- 移除成员确认弹窗 -->
|
||||
<t-dialog v-model:visible="showRemoveDialog" :header="$t('organization.detail.removeMemberTitle')" theme="warning"
|
||||
:confirm-btn="$t('common.confirm')" :cancel-btn="$t('common.cancel')" @confirm="confirmRemoveMember">
|
||||
<p>{{ $t('organization.detail.removeMemberConfirm', { name: removingMember?.username }) }}</p>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 申请权限升级弹窗 -->
|
||||
<t-dialog v-model:visible="showUpgradeDialog" :header="$t('organization.upgrade.dialogTitle')"
|
||||
:confirm-btn="{ content: $t('common.confirm'), loading: upgradeSubmitting }" :cancel-btn="$t('common.cancel')"
|
||||
@@ -737,8 +738,6 @@ const submitting = ref(false)
|
||||
const refreshingCode = ref(false)
|
||||
const inviteCode = ref('')
|
||||
const inviteCodeExpiresAt = ref<string | null>(null)
|
||||
const showRemoveDialog = ref(false)
|
||||
const removingMember = ref<OrganizationMember | null>(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'))
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<Settings />
|
||||
<!-- 全局命令面板 (⌘K),随 platform 路由存活 -->
|
||||
<GlobalCommandPalette />
|
||||
<!-- 全局右上角"待处理邀请"铃铛。固定定位,z-index 低于抽屉,业务页面
|
||||
右侧抽屉弹出时会自然覆盖;仅在有待处理邀请时渲染。 -->
|
||||
<GlobalInvitationBell />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@@ -22,6 +25,7 @@ import useKnowledgeBase from '@/hooks/useKnowledgeBase'
|
||||
import UploadMask from '@/components/upload-mask.vue'
|
||||
import Settings from '@/views/settings/Settings.vue'
|
||||
import GlobalCommandPalette from '@/components/GlobalCommandPalette.vue'
|
||||
import GlobalInvitationBell from '@/components/GlobalInvitationBell.vue'
|
||||
import { useCommandPaletteStore } from '@/stores/commandPalette'
|
||||
import { getKnowledgeBaseById } from '@/api/knowledge-base/index'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
|
||||
@@ -69,13 +69,44 @@
|
||||
</div>
|
||||
|
||||
<!-- Tenant description -->
|
||||
<div v-if="tenantInfo?.description" class="setting-row">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('tenant.details.descriptionLabel') }}</label>
|
||||
<p class="desc">{{ $t('tenant.details.descriptionDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<span class="info-value">{{ tenantInfo.description }}</span>
|
||||
<!-- 只读态:显示描述(空时给占位)+ 编辑按钮(owner 才看得见编辑入口)。
|
||||
与名称同款"原地编辑"模式,少一层弹窗打断。 -->
|
||||
<template v-if="!editingDescription">
|
||||
<span class="info-value description-value" :class="{ 'is-empty': !tenantInfo?.description }">
|
||||
{{ tenantInfo?.description || $t('tenant.details.descriptionEmptyPlaceholder') }}
|
||||
</span>
|
||||
<t-button v-if="canEditTenant" theme="default" variant="text" size="small" class="edit-btn"
|
||||
@click="startEditDescription">
|
||||
<template #icon>
|
||||
<t-icon name="edit" />
|
||||
</template>
|
||||
{{ $t('tenant.details.editDescription') }}
|
||||
</t-button>
|
||||
</template>
|
||||
<!-- 编辑态:textarea + 保存/取消。Esc 取消、Ctrl/⌘+Enter 保存;
|
||||
textarea 上 Enter 默认换行更顺手,不接管 Enter 提交。 -->
|
||||
<div v-else class="inline-edit inline-edit-description">
|
||||
<t-textarea v-model="editDescription"
|
||||
:placeholder="$t('tenant.details.editDescriptionPlaceholder')" :maxlength="512"
|
||||
:autosize="{ minRows: 2, maxRows: 6 }" :disabled="savingDescription" autofocus
|
||||
class="inline-edit-textarea" @keydown="onEditDescriptionKeydown" />
|
||||
<div class="inline-edit-actions">
|
||||
<t-button theme="primary" size="small" :loading="savingDescription"
|
||||
:disabled="!canSubmitDescription" @click="saveTenantDescription">
|
||||
{{ $t('tenant.details.editNameConfirm') }}
|
||||
</t-button>
|
||||
<t-button theme="default" variant="outline" size="small" :disabled="savingDescription"
|
||||
@click="cancelEditDescription">
|
||||
{{ $t('tenant.details.editNameCancel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -326,6 +357,70 @@ const onEditKeydown = (_value: any, ctx: { e: KeyboardEvent }) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 原地编辑空间描述:与名称对称的 editing / editValue / saving 三态。
|
||||
// 描述允许为空(业务上是可选字段),所以可提交条件不要求非空,只要内容变了即可。
|
||||
const editingDescription = ref(false)
|
||||
const editDescription = ref('')
|
||||
const savingDescription = ref(false)
|
||||
const editDescriptionTrimmed = computed(() => editDescription.value.trim())
|
||||
const canSubmitDescription = computed(
|
||||
() => !savingDescription.value && editDescriptionTrimmed.value !== (tenantInfo.value?.description || ''),
|
||||
)
|
||||
|
||||
const startEditDescription = () => {
|
||||
editDescription.value = tenantInfo.value?.description || ''
|
||||
editingDescription.value = true
|
||||
}
|
||||
|
||||
const cancelEditDescription = () => {
|
||||
if (savingDescription.value) return
|
||||
editingDescription.value = false
|
||||
editDescription.value = ''
|
||||
}
|
||||
|
||||
// textarea 上 Enter 默认走换行,提交走 Ctrl/⌘+Enter;Esc 取消。
|
||||
const onEditDescriptionKeydown = (_value: any, ctx: { e: KeyboardEvent }) => {
|
||||
const e = ctx?.e
|
||||
if (!e) return
|
||||
if (e.key === 'Escape') {
|
||||
cancelEditDescription()
|
||||
return
|
||||
}
|
||||
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault()
|
||||
void saveTenantDescription()
|
||||
}
|
||||
}
|
||||
|
||||
const saveTenantDescription = async () => {
|
||||
if (!tenantInfo.value?.id) return
|
||||
const newDesc = editDescriptionTrimmed.value
|
||||
if (newDesc === (tenantInfo.value.description || '')) {
|
||||
editingDescription.value = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
savingDescription.value = true
|
||||
const resp = await updateTenantApi(Number(tenantInfo.value.id), { description: newDesc })
|
||||
if (resp.success) {
|
||||
// 本地立即回显,避免等 /auth/me 往返。描述不像名称那样会出现在租户切换器等
|
||||
// 顶部组件里,所以无需同步 authStore.tenant / memberships。
|
||||
if (tenantInfo.value) {
|
||||
tenantInfo.value = { ...tenantInfo.value, description: newDesc }
|
||||
}
|
||||
MessagePlugin.success(t('tenant.details.editDescriptionSuccess'))
|
||||
editingDescription.value = false
|
||||
} else {
|
||||
MessagePlugin.error(resp.message || t('tenant.details.editDescriptionFailed'))
|
||||
}
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.message || t('tenant.details.editDescriptionFailed'))
|
||||
} finally {
|
||||
savingDescription.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const saveTenantName = async () => {
|
||||
const newName = editNameTrimmed.value
|
||||
if (!newName) {
|
||||
@@ -528,8 +623,13 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
max-width: 65%;
|
||||
/* 不再 flex:1:标签列固定到 max-content 的合理范围内(CJK label 一般 4~6 字,
|
||||
再加 desc 文案撑宽),不参与剩余空间分配,避免被长内容挤到单字纵向换行。
|
||||
min-width 兜底,desc 字数稍多时也不会被压缩到一字一行。 */
|
||||
flex: 0 0 auto;
|
||||
width: max-content;
|
||||
min-width: 140px;
|
||||
max-width: 40%;
|
||||
padding-right: 24px;
|
||||
|
||||
label {
|
||||
@@ -549,8 +649,10 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
min-width: 280px;
|
||||
/* 反过来:内容列吃掉剩余空间,并允许收缩 + 内部换行,长字符串不会再撑爆行。
|
||||
去掉原先的 min-width:280px 硬约束(短内容也不需要那么宽的展示槽)。 */
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
@@ -560,7 +662,10 @@ onMounted(() => {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-primary);
|
||||
text-align: right;
|
||||
word-break: break-word;
|
||||
/* anywhere 比 break-word 激进:连无空格的长串("WorkspaceDefault..." 这种)
|
||||
也能强制断行,避免单条内容把整行撑出。 */
|
||||
overflow-wrap: anywhere;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
@@ -583,6 +688,36 @@ onMounted(() => {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 描述行的原地编辑:textarea 自身可换行展开,按钮换到下方右对齐,
|
||||
避免名称行那样横向把按钮挤窄。 */
|
||||
.inline-edit-description {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
max-width: 360px;
|
||||
}
|
||||
|
||||
.inline-edit-textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.inline-edit-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* 只读态的描述:多行可换行;空描述用占位色提示用户可点编辑写入。 */
|
||||
.description-value {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
|
||||
&.is-empty {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
.leave-space-panel {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
@@ -248,10 +248,17 @@
|
||||
</template>
|
||||
<template #joined_at="{ row }">{{ formatDate(row.joined_at) }}</template>
|
||||
<template #actions="{ row }">
|
||||
<t-button v-if="canManage && row.user_id !== currentUserId" theme="danger" variant="text" size="small"
|
||||
@click="confirmRemove(row)">
|
||||
{{ $t('tenantMember.remove.button') }}
|
||||
</t-button>
|
||||
<t-popconfirm
|
||||
v-if="canManage && row.user_id !== currentUserId"
|
||||
:content="$t('tenantMember.remove.confirmBody', { name: row.username || row.email })"
|
||||
:confirm-btn="{ content: $t('tenantMember.remove.confirm'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }"
|
||||
placement="left"
|
||||
@confirm="removeRow(row)">
|
||||
<t-button theme="danger" variant="text" size="small" @click.stop>
|
||||
{{ $t('tenantMember.remove.button') }}
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
</template>
|
||||
</t-table>
|
||||
</div>
|
||||
@@ -354,7 +361,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onUnmounted, reactive, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { DialogPlugin, MessagePlugin } from 'tdesign-vue-next'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import {
|
||||
listMembers,
|
||||
@@ -1121,39 +1128,28 @@ async function onRoleChange(row: TenantMember, newRole: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function confirmRemove(row: TenantMember) {
|
||||
// Use DialogPlugin.confirm rather than t-popconfirm so we can describe
|
||||
// the consequences in a multi-line modal (matches the pattern used in
|
||||
// ApiInfo.vue's reset-API-key flow).
|
||||
const dlg = DialogPlugin.confirm({
|
||||
header: t('tenantMember.remove.confirmTitle'),
|
||||
body: t('tenantMember.remove.confirmBody', { name: row.username || row.email }),
|
||||
confirmBtn: { content: t('tenantMember.remove.confirm'), theme: 'danger' },
|
||||
cancelBtn: t('common.cancel'),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
const resp = await removeMember(activeTenantId.value, row.user_id)
|
||||
if (resp.success) {
|
||||
await loadMembers()
|
||||
MessagePlugin.success(t('tenantMember.remove.success'))
|
||||
} else {
|
||||
MessagePlugin.error(resp.message || t('tenantMember.errors.generic'))
|
||||
}
|
||||
} catch (err: any) {
|
||||
const status = err?.status
|
||||
if (status === 409) {
|
||||
MessagePlugin.error(t('tenantMember.errors.lastOwner'))
|
||||
} else if (status === 404) {
|
||||
MessagePlugin.error(t('tenantMember.errors.notFound'))
|
||||
} else {
|
||||
MessagePlugin.error(err?.message || t('tenantMember.errors.generic'))
|
||||
}
|
||||
} finally {
|
||||
dlg.destroy()
|
||||
}
|
||||
},
|
||||
onClose: () => dlg.destroy(),
|
||||
})
|
||||
// 原地 popconfirm 替代 DialogPlugin 模态确认:与"共享资源删除"等其它列表内
|
||||
// 的删除入口风格统一,避免一个简单的二次确认打断成员管理表格的浏览节奏。
|
||||
// 错误分支保持与旧实现一致(409 last-owner / 404 not-found / 兜底)。
|
||||
async function removeRow(row: TenantMember) {
|
||||
try {
|
||||
const resp = await removeMember(activeTenantId.value, row.user_id)
|
||||
if (resp.success) {
|
||||
await loadMembers()
|
||||
MessagePlugin.success(t('tenantMember.remove.success'))
|
||||
} else {
|
||||
MessagePlugin.error(resp.message || t('tenantMember.errors.generic'))
|
||||
}
|
||||
} catch (err: any) {
|
||||
const status = err?.status
|
||||
if (status === 409) {
|
||||
MessagePlugin.error(t('tenantMember.errors.lastOwner'))
|
||||
} else if (status === 404) {
|
||||
MessagePlugin.error(t('tenantMember.errors.notFound'))
|
||||
} else {
|
||||
MessagePlugin.error(err?.message || t('tenantMember.errors.generic'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Re-load whenever the active tenant resolves (or changes via the
|
||||
|
||||
Reference in New Issue
Block a user