Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { perm } from '@/permission'
/**
* 知识库「文档」权限判断
*/
type KnowledgeDocPermissionMethod = 'docRead' | 'docEdit'
type KnowledgeDocPermissionMethod = 'docRead' | 'docEdit' | 'docTag'

function knowledgeDocPermission(method: KnowledgeDocPermissionMethod): boolean {
if (isSystemResource()) return Boolean(perm.knowledge.system[method]())
Expand Down Expand Up @@ -158,7 +158,7 @@ defineExpose({ open })
</el-tabs>
<div class="flex-between gap-3">
<!-- 批量关联或取消关联文档 -->
<el-button plain :disabled="!selectedDocuments.length || (loading && !knowledgeDocPermission('docEdit'))" @click="handleBatchLinkDocuments">
<el-button v-if="knowledgeDocPermission('docTag')" plain :disabled="!selectedDocuments.length" @click="handleBatchLinkDocuments">
<MkIcon :name="activeTab === 'linked' ? 'icon_unlink_outlined' : 'icon_link-record_outlined'" />
<span>{{ activeTab === 'linked' ? t('common.actions.unrelate') : t('common.actions.relate') }}</span>
</el-button>
Expand Down Expand Up @@ -206,7 +206,7 @@ defineExpose({ open })
display="button"
:label="activeTab === 'linked' ? t('common.actions.unrelate') : t('common.actions.relate')"
:icon="activeTab === 'linked' ? 'icon_unlink_outlined' : 'icon_link-record_outlined'"
:disabled="loading && !knowledgeDocPermission('docEdit')"
v-if="knowledgeDocPermission('docTag')"
@click="handleLinkDocuments([row.id])"
/>
</template>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key observations:

  1. Logic change: disabled → v-if (intentional? verify UX)

    • Previously, the button was rendered but disabled during loading and without docEdit permission. Now it's hidden entirely when docTag permission is absent.
    • Hiding vs. disabling is a UX decision — disabling is usually preferred so users know the action exists but is unavailable. Confirm this is intended.
  2. Loss of loading guard

    • The old condition included loading (prevent double-clicks / actions mid-load). The new :disabled="!selectedDocuments.length" drops the loading check on the toolbar button, so the user can trigger handleBatchLinkDocuments while data is still loading. Likely a regression. Re-add:
      :disabled="!selectedDocuments.length || loading"
    • Same for the per-row dropdown item (line ~209): old had :disabled="loading && ...", now gone entirely. Consider restoring a loading guard.
  3. Attribute order / mixing v-if with other bindings

    • In the second diff, v-if is placed after :icon, which works but is inconsistent style. Also note: v-if + @click + disabled bindings — fine functionally, but keep a consistent ordering (place structural directives first).
    • Better practice: use v-if first in the tag.
  4. Permission naming consistency

    • knowledgeDocPermission is "document" scoped, but you're introducing docTag. If tagging is a distinct capability, consider whether it belongs under this function or a separate guard/namespace (e.g., docTag semantics vs. docEdit). If docTag should imply link/unlink rights, ensure backend perm definitions align.
  5. Inconsistent gating between toolbar and inline action

    • Toolbar uses v-if="knowledgeDocPermission('docTag')"; inline row action also now gates on 'docTag'. Good — they match. But previously both allowed viewing the control regardless of edit perms. Double-check that read-only users don't legitimately need to see these buttons (e.g., greyed out with tooltip).
  6. isSystemResource() branch

    • Verify perm.knowledge.system['docTag'] actually exists; adding a method to the union type without a corresponding runtime permission likely throws undefined is not a function. Ensure both system and non-system perm objects define docTag.
  7. Minor optimization

    • knowledgeDocPermission(...) is called in template; if used in multiple places consider a computed (e.g., canTag) to avoid repeated evaluation and keep template clean:
      const canTag = computed(() => knowledgeDocPermission('docTag'))

Summary of actionable issues: (a) dropped loading guard on both buttons — likely unintended regression; (b) confirm hide-vs-disable UX intent; (c) ensure docTag exists at runtime in all perm branches; (d) consider a computed and consistent directive ordering.

Expand Down
Loading