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
2 changes: 1 addition & 1 deletion ui/src/views/knowledge-detail/library/tags/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ onMounted(() => {
<div class="flex-align-center">
<MkSearchInput v-model="searchText" class="mr-3 w-60!" @change="handleSearchChange" />
<!-- 导入标签,成功后刷新列表 -->
<ButtonImportTags :api="resourceApi.tags" :knowledge-id="knowledgeId" :disabled="loading || operationLoading" @refresh="loadTags" />
<ButtonImportTags v-if="knowledgeTagPermission('tagCreate')" :api="resourceApi.tags" :knowledge-id="knowledgeId" :disabled="loading || operationLoading" @refresh="loadTags" />
<!-- 创建标签 -->
<el-button v-if="knowledgeTagPermission('tagCreate')" type="primary" :disabled="loading || operationLoading" @click="handleOpenCreateTag">
<MkIcon name="icon_add_outlined" />

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.

The diff is syntactically valid: adding v-if="knowledgeTagPermission('tagCreate')" to <ButtonImportTags> correctly hides the import entry when the user lacks that permission.

Potential issues / suggestions:

  1. Permission semantics

    • Importing tags is a bulk-create operation, so reusing tagCreate may be intentional.
    • If import has different authorization requirements, use a dedicated permission such as tagImport instead.
    • Frontend v-if is only UI-level protection; the backend must still enforce the same permission.
  2. Avoid repeated permission calls

    • knowledgeTagPermission('tagCreate') is now called twice in the same template.
    • Prefer a computed property:
      const canCreateTag = computed(() => knowledgeTagPermission('tagCreate'))
      Then use:
      <ButtonImportTags v-if="canCreateTag" ... />
      <el-button v-if="canCreateTag" ... />
    • This improves readability and keeps both buttons consistent.
  3. Ensure reactivity

    • Confirm that knowledgeTagPermission(...) depends on reactive permission state. If permissions load asynchronously, the v-if should update automatically once available.
  4. No functional issue with v-if on the component

    • Conditionally mounting ButtonImportTags is fine.
    • If the component manages an open dialog or import state internally, unmounting it when permission changes will reset that state. This is usually acceptable, but worth confirming.
  5. Optional formatting

    • The modified line is long. Consider wrapping attributes for readability.

Overall: the change is reasonable and low-risk, but the permission name should be verified and a computed property is recommended.

Expand Down
Loading