Skip to content

fix: knowledge tags permission - #7760

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_knowledge_tags_permission
Nov 9, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_knowledge_tags_permission

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: knowledge tags permission

<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.

@peslyn
peslyn merged commit 5c518b0 into v3 Nov 9, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_knowledge_tags_permission branch November 9, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants