Repository navigation
fix: workspace application and knowledge folder create permission #7869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,10 @@ const workspace = { | |
| }, | ||
|
|
||
| // —— 文件夹 —— | ||
| /** | ||
| * 工作空间「知识库」「文件夹」只读权限 | ||
| */ | ||
| folderCreateWorkspace: () => can(P.KNOWLEDGE_FOLDER_CREATE), | ||
| /** | ||
| * 工作空间「知识库」「文件夹」只读权限 | ||
| */ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The shown diff is syntactically valid, but there are a few issues and suggestions:
Overall: the code will run, but the comment/name/permission semantics should be corrected to avoid confusion. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ import ButtonCreateApplication from './components/ButtonCreateApplication.vue' | |
| import ButtonTemplateStore from './components/ButtonTemplateStore.vue' | ||
| import ButtonBatchCleanStrategy from './components/ButtonBatchCleanStrategy.vue' | ||
| import perm from '@/permission/index.ts' | ||
| import { getWorkspaceId } from '@/utils/resource-context.ts' | ||
|
|
||
| const route = useRoute() | ||
| const router = useRouter() | ||
|
|
@@ -201,7 +200,7 @@ function handleBatchDelete() { | |
| <template #aside="{ title, Header }"> | ||
| <component :is="Header"> | ||
| <h4>{{ title }}</h4> | ||
| <MkTooltip v-if="perm.application.workspace.folderCreate(getWorkspaceId() || '')" content="创建文件夹" placement="top"> | ||
| <MkTooltip v-if="perm.application.workspace.folderCreateWorkspace()" content="创建文件夹" placement="top"> | ||
| <el-button @click="handleCreateFolder" text type="primary" class="-mr-1"> | ||
| <MkIcon name="icon_add-folder_outlined" :size="18" /> | ||
| </el-button> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's my review of the diff: 1. Removed import — verify no remaining usages-import { getWorkspaceId } from '@/utils/resource-context.ts'Issue: If 2. Permission API change — semantics may differ-<MkTooltip v-if="perm.application.workspace.folderCreate(getWorkspaceId() || '')" ...>
+<MkTooltip v-if="perm.application.workspace.folderCreateWorkspace()" ...>Potential issues to verify:
3. Minor / optimizations
4. Test checklist
Overall the change looks like a sensible refactor toward encapsulation, but the two biggest risks are the orphaned import and subtle behavior changes in the permission check. |
||
|
|
||
There was a problem hiding this comment.
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 provided code snippet:
1. Critical Irregularity: Duplicate/Orphaned Documentation
The main issue in this patch is a mismatch between the added code and the existing (or unchanged) code context.
folderCreateWorkspace:with a JSDoc comment block above it./** ... */) which seems to be either dormant, misplaced, or part of a previous version that wasn't properly cleaned up.2. Code Style & Consistency
folderCreateWorkspacefollows the naming convention used by other methods likeread,debug, etc., so it’s stylistically consistent.canResvscan:readanddebugusecanRes(P.APPLICATION_READ, id)→ checks permission for a specific resource ID.folderCreateWorkspaceusescan(P.APPLICATION_FOLDER_CREATE)→ checks a global/workspace-level permission without an ID.This is likely correct if folder creation doesn’t depend on a specific folder ID upfront, but ensure this semantic distinction is intentional.
3. Potential Optimization / Suggestion
If multiple similar “create” permissions exist (e.g., agent create, folder create), consider grouping them under a common pattern or factory function to reduce repetition:
This avoids boilerplate if more such methods are added later.
✅ Final Recommendation
can()instead ofcanRes()is correct for your auth model.Let me know if you’d like a cleaned-up version of the entire file section.