Skip to content

fix: system shared knowledge setting permission - #7761

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

peslyn merged 1 commit into
v3from
pr@v3@fix_system_shared_knowledge_setting_permission

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: system shared knowledge setting permission

<MkDropdownItem v-if="perm.knowledge.share.settingRead()" @click.stop="handleOpenKnowledgeSetting(knowledge)">
<template #icon><MkIcon name="icon_setting" /></template>
设置
</MkDropdownItem>

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 change looks reasonable at a glance, but here are things to verify:

  1. Permission method name mismatch risk – Confirm that perm.knowledge.share.settingRead() actually exists in the perm object/module. If it's a newly added method, ensure it's defined and exported; otherwise this will throw at runtime (or be undefined → falsy → menu item silently hidden).

  2. Naming semantics vs. action – The handler is handleOpenKnowledgeSetting (an edit action). If settingRead() only grants read permission for settings, opening the settings dialog may still allow edits inside it — check that the inner settings UI also enforces write permissions. Otherwise you've only changed the visibility of the entry point, not the actual authorization.

  3. Consistency with sibling items – The item above uses perm.knowledge.share.generate() (a verb). Mixing generate() / edit() / settingRead() naming styles is inconsistent; consider a uniform convention (e.g., canEditSettings vs settingsReadable) to avoid confusion later.

  4. v-if vs v-show – Fine as-is if this is a dropdown that conditionally renders; no issue.

  5. Hardening suggestion – For defense-in-depth, add a guard inside handleOpenKnowledgeSetting:

    if (!perm.knowledge.share.settingRead()) return;

    so permission is enforced even if the template check is accidentally removed or the method is called from elsewhere.

  6. Test coverage – Add/verify unit tests for: user with read-only settings permission (item visible, edit controls disabled), user without any permission (item hidden), and admin (full access).

  7. i18n – The label 设置 is hardcoded Chinese; if the project uses i18n elsewhere in this component, wrap it ({{ $t('...') }}) for consistency. (Pre-existing issue, not introduced by this diff.)

No functional bug is evident in the diff itself, but points 1 and 2 are the ones most likely to bite you.

@peslyn
peslyn merged commit fb92837 into v3 Nov 9, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_system_shared_knowledge_setting_permission branch November 9, 2026 08:48
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