Repository navigation
fix: knowledge tags permission - #7760
Merged
Merged
Conversation
shaohuzhang1
commented
Nov 9, 2026
| <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" /> |
Contributor
Author
There was a problem hiding this comment.
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:
-
Permission semantics
- Importing tags is a bulk-create operation, so reusing
tagCreatemay be intentional. - If import has different authorization requirements, use a dedicated permission such as
tagImportinstead. - Frontend
v-ifis only UI-level protection; the backend must still enforce the same permission.
- Importing tags is a bulk-create operation, so reusing
-
Avoid repeated permission calls
knowledgeTagPermission('tagCreate')is now called twice in the same template.- Prefer a computed property:
Then use:
const canCreateTag = computed(() => knowledgeTagPermission('tagCreate'))
<ButtonImportTags v-if="canCreateTag" ... /> <el-button v-if="canCreateTag" ... />
- This improves readability and keeps both buttons consistent.
-
Ensure reactivity
- Confirm that
knowledgeTagPermission(...)depends on reactive permission state. If permissions load asynchronously, thev-ifshould update automatically once available.
- Confirm that
-
No functional issue with
v-ifon the component- Conditionally mounting
ButtonImportTagsis 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.
- Conditionally mounting
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: knowledge tags permission