Skip to content

fix: knowledge quick create document permission - #7913

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_knowledge_quick_create_document_permission
Nov 13, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_knowledge_quick_create_document_permission

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: knowledge quick create document permission

<MkQuickCreate v-if="knowledgeDocPermission('docCreate')" ref="quickCreateRef" text="快速创建空白文档" placeholder="请输入文档名称" @create="handleCreateDocument" />
</template>

<el-table-column type="selection" width="40" reserve-selection v-if="!isWorkspaceSharedResource()" />

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 code snippet adds a permission check (v-if) to the MkQuickCreate component, which is a good security practice. However, here are some observations and suggestions:

1. Redundant Permission Check?

If showQuickCreate already implies that the user has creation permissions, adding knowledgeDocPermission('docCreate') might be redundant. Ensure that these two conditions are logically distinct or that both are strictly necessary.

2. Performance Optimization

  • Calling knowledgeDocPermission('docCreate') directly in the template may execute the function on every re-render, which can be inefficient if it involves complex logic or API calls.
  • Suggestion: Compute the permission result in <script setup> using a computed property instead of calling it directly in the template.
<script setup>
import { computed } from 'vue';

const canCreateDoc = computed(() => knowledgeDocPermission('docCreate'));
</script>

<template>
  <MkQuickCreate v-if="canCreateDoc" ... />
</template>

3. Consistency with Other Conditions

Ensure this new condition aligns with how other permission checks are handled in the file (e.g., whether they’re always via direct function call vs. computed properties). Consistent style improves maintainability.

4. Accessibility/UX Consideration

If the button is hidden due to lack of permissions, ensure there’s still feedback if users try to access features needing these permissions elsewhere (e.g., disabled buttons + tooltip explaining why). This prevents confusion when UI elements disappear unexpectedly.


If you want a concise review summary:

✅ Fix: Adding fine-grained permissions enhances security/accessibility control.
⚠️ Caution: Avoid direct function invocations inside templates for better performance; prefer computed properties.
💡 Suggestion: Confirm no overlap between existing flags like showQuickCreate and new permission gate for logical clarity.

@peslyn
peslyn merged commit 21cec20 into v3 Nov 13, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_knowledge_quick_create_document_permission branch November 13, 2026 07:46
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