feat(api): enhance organization shared knowledge base and agent functionalities

- Introduced new interfaces for handling shared knowledge bases and agents, including visibility and selection modes for agents.
- Added API functions to list shared knowledge bases and agents within an organization, improving data retrieval for UI components.
- Updated existing components to utilize the new API endpoints and interfaces, ensuring accurate representation of shared resources.
- Enhanced error handling in API calls to provide clearer feedback on failures.

This update improves the functionality and user experience by providing better access to shared resources and enhancing the overall data structure within the application.
This commit is contained in:
wizardchen
2026-02-08 14:32:18 +08:00
committed by lyingbug
parent 1bdd9a4693
commit 9a073d62bf
25 changed files with 1119 additions and 118 deletions
@@ -43,7 +43,7 @@
<div v-if="kbInfo" class="faq-access-meta">
<t-tooltip :content="accessPermissionSummary" placement="top">
<span class="faq-access-meta-inner">
<t-tag size="small" :theme="isOwner ? 'success' : (currentSharedKb?.permission === 'admin' ? 'primary' : currentSharedKb?.permission === 'editor' ? 'warning' : 'default')" class="faq-access-role-tag">
<t-tag size="small" :theme="isOwner ? 'success' : (effectiveKBPermission === 'admin' ? 'primary' : effectiveKBPermission === 'editor' ? 'warning' : 'default')" class="faq-access-role-tag">
{{ accessRoleLabel }}
</t-tag>
<template v-if="currentSharedKb">
@@ -53,6 +53,10 @@
{{ $t('knowledgeBase.accessInfo.sharedAt') }} {{ formatImportTime(currentSharedKb.shared_at) }}
</span>
</template>
<template v-else-if="effectiveKBPermission">
<span class="faq-access-meta-sep">·</span>
<span class="faq-access-meta-text">{{ $t('knowledgeList.detail.sourceTypeAgent') }}</span>
</template>
<template v-else-if="kbLastUpdated">
<span class="faq-access-meta-sep">·</span>
<span class="faq-access-meta-text">{{ $t('knowledgeBase.accessInfo.lastUpdated') }} {{ kbLastUpdated }}</span>
@@ -1304,10 +1308,13 @@ const currentSharedKb = computed(() =>
orgStore.sharedKnowledgeBases.find((s) => s.knowledge_base?.id === props.kbId) ?? null,
)
// Effective permission: from direct org share list or from GET /knowledge-bases/:id (e.g. agent-visible KB)
const effectiveKBPermission = computed(() => orgStore.getKBPermission(props.kbId) || kbInfo.value?.my_permission || '')
// Display role label: owner or org role (admin/editor/viewer)
const accessRoleLabel = computed(() => {
if (isOwner.value) return t('knowledgeBase.accessInfo.roleOwner')
const perm = orgStore.getKBPermission(props.kbId)
const perm = effectiveKBPermission.value
if (perm) return t(`organization.role.${perm}`)
return '--'
})
@@ -1315,7 +1322,7 @@ const accessRoleLabel = computed(() => {
// Permission summary text for current role
const accessPermissionSummary = computed(() => {
if (isOwner.value) return t('knowledgeBase.accessInfo.permissionOwner')
const perm = orgStore.getKBPermission(props.kbId)
const perm = effectiveKBPermission.value
if (perm === 'admin') return t('knowledgeBase.accessInfo.permissionAdmin')
if (perm === 'editor') return t('knowledgeBase.accessInfo.permissionEditor')
if (perm === 'viewer') return t('knowledgeBase.accessInfo.permissionViewer')