Skip to content

feat: knowledge document create permission - #7749

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

peslyn merged 1 commit into
v3from
pr@v3@feat_knowledge_document_create_permission

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: knowledge document create permission

v-if="!showQuickCreate && knowledgeDocPermission('docCreate')"
:api="resourceApi.document"
:knowledge-id="knowledgeId"
:knowledge-type="knowledgeType"

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.

Here is an analysis of the code change:

Irregularities/Issues:

  1. Naming Convention: knowledgeDocPermission looks like a function call rather than a standard computed property or reactive boolean used in Vue templates. If it is a method, calling it directly in v-if will re-execute on every render, which is inefficient for permission checks.
  2. Short-circuit Evaluation: While logically sound, v-if="!showQuickCreate && knowledgeDocPermission('docCreate')" creates two separate reactive dependency traces. If showQuickCreate changes frequently but permissions do not, Vue still evaluates the expression (though short-circuits). It is generally cleaner to consolidate complex conditional logic into a single computed property.

Optimization Suggestions:

  1. Use a Computed Property: Move this logic to a computed block for better readability, maintainability, and performance caching.
    const canShowImportButton = computed(() => {
        return !showQuickCreate.value && knowledgeDocPermission('docCreate');
    });
    Then use it in the template: <ButtonImportDocument v-if="canShowImportButton" ...>
  2. Verify Function Side Effects: Ensure knowledgeDocPermission is a pure function (no side effects) if kept in the template. If it's a method, consider converting it to a computed dependency or ensuring it is sufficiently lightweight.

Summary: The change adds a necessary permission check, but should be refactored into a computed property for best practices in Vue.

@peslyn
peslyn merged commit d9b6e29 into v3 Nov 9, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@feat_knowledge_document_create_permission branch November 9, 2026 06:57
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