Repository navigation
fix: knowledge document strategy permission - #7745
Conversation
| <el-button v-if="knowledgeExternalServicePermission('knowledgeExternalServiceEdit')" type="primary" class="mt-4" :loading="saving" @click="handleSave">保存</el-button> | ||
| <el-button v-if="knowledgeDocumentStrategyPermission('documentStrategyEdit')" type="primary" class="mt-4" :loading="saving" @click="handleSave">保存</el-button> | ||
| </div> | ||
| </template> |
There was a problem hiding this comment.
The diff is syntactically consistent, but there are a few review points:
-
Likely permission bug for workspace-shared resources
if (isWorkspaceSharedResource()) return false // 共享知识库在工作空间侧只读
This returns
falsefor bothdocumentStrategyReadanddocumentStrategyEdit. If the function is ever called withdocumentStrategyRead, read access is denied, which contradicts the “read-only” comment.
Suggested fix if read should be allowed:if (isWorkspaceSharedResource()) { return method === 'documentStrategyRead' }
Or, if only edit is ever used, narrow the type/function to edit-only to avoid misleading semantics.
-
Permission key rename is a breaking change
The permission methods changed from:knowledgeExternalServiceRead→documentStrategyReadknowledgeExternalServiceEdit→documentStrategyEdit
Ensure
perm.knowledge.systemandperm.knowledge.shareactually expose these new method names. Otherwise:perm.knowledge.system[method]()
can throw if
[method]isundefined. Also check backend permission codes, role configuration, tests, audit logs, and any persisted permissions for migration/backward compatibility. -
Runtime safety for permission lookup
Consider guarding the dynamic call:return Boolean(perm.knowledge?.system?.[method]?.())
and similarly for
perm.knowledge.share. This avoids crashes if permissions are not loaded yet or a key is missing. -
Duplicate permission check
handleSavechecks edit permission, and the button also checks it viav-if. This is acceptable, but a computed property would avoid duplication:const canEditDocumentStrategy = computed(() => knowledgeDocumentStrategyPermission('documentStrategyEdit') )
Then use it in both places.
-
Minor existing issue
max-w-200is not a standard Tailwind utility unless custom-configured. Verify it resolves correctly.
Overall, the rename itself looks internally consistent in the shown diff. The main risks are the workspace-shared read behavior and ensuring the new permission identifiers exist everywhere.
fix: knowledge document strategy permission