Repository navigation
fix: workspace tool folder create error - #7784
Merged
Merged
Conversation
shaohuzhang1
commented
Nov 10, 2026
| folderCreateWorkspace: () => can(P.TOOL_FOLDER_CREATE), | ||
| debug: () => false, | ||
| authToWorkspace: () => false, | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Here is the review of the code snippet:
Irregularities & Issues
- Indentation & Formatting: The new
/** ... */comment block and thefolderCreateWorkspacemethod are indented with spaces, while the existingimportmethod appears to be at the base level (or differently indented depending on context). This inconsistency reduces readability. Ensure consistent indentation (usually 2 or 4 spaces) across all object properties. - Comment Style Consistency: The comment format (
/** ... */) is consistent, but verify if other methods in theworkspaceobject use the same JSDoc style. If others use single-line comments//, consider standardizing.
Optimization Suggestions
- Naming Convention:
folderCreateWorkspaceis verbose. Since this is already within aworkspacecontext,createFolderorfolderCreatewould be more concise and standard.- Suggested Name:
createFolder: () => can(P.TOOL_FOLDER_CREATE),
- Suggested Name:
- Redundancy: The term "Workspace" in the method name is redundant because the object itself is named
workspace. Remove it for cleaner API usage (e.g.,workspace.createFolder()vsworkspace.folderCreateWorkspace()).
Corrected Example
const workspace = {
/**
* 工作空间「工具」导入权限
*/
import: () => can(P.TOOL_IMPORT),
/**
* 工作空间「工具」文件夹创建权限
*/
createFolder: () => can(P.TOOL_FOLDER_CREATE), // Renamed for brevity and clarity
debug: () => false,
authToWorkspace: () => false,
};
shaohuzhang1
commented
Nov 10, 2026
| <MkTooltip v-if="perm.tool.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.
The diff shows a change that likely breaks functionality. The getWorkspaceId import is removed, but the original logic depended on getWorkspaceId() to create a dynamic permission token (e.g., perm.tool.workspace.folderCreate('id')).
Issues:
- Logical Regression: The new code calls
perm.tool.workspace.folderCreateWorkspace(), which appears to be a different method key than the originalfolderCreate. UnlessfolderCreateWorkspacetakes no arguments and handles internal state retrieval itself, this replaces a dynamic check with a static one. If the underlying permission system still requires an ID in the key, the button might always show or hide incorrectly. - Orphaned Logic: If
folderCreateWorkspacedoes not internally fetch the workspace ID likegetWorkspaceId()did, the context of which workspace’s folder creation is being perm-checked is lost. This could lead to security issues (showing the button for unauthorized workspaces) or UX bugs.
Suggestion:
Ensure that perm.tool.workspace.folderCreateWorkspace() correctly encapsulates the logic previously done by folderCreate(getWorkspaceId())). If it doesn’t, retrieve the workspace ID inside the component or pass it explicitly:
<MkTooltip v-if="perm.tool.workspace.folderCreate(currentWorkspaceId)" ...>Verify that the perm object actually exposes folderCreateWorkspace as intended.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: workspace tool folder create error