Skip to content

fix: workspace tool folder create error - #7784

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_workspace_tool_folder_create_error
Nov 10, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_workspace_tool_folder_create_error

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: workspace tool folder create error

folderCreateWorkspace: () => can(P.TOOL_FOLDER_CREATE),
debug: () => false,
authToWorkspace: () => false,

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.

Here is the review of the code snippet:

Irregularities & Issues

  1. Indentation & Formatting: The new /** ... */ comment block and the folderCreateWorkspace method are indented with spaces, while the existing import method 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.
  2. Comment Style Consistency: The comment format (/** ... */) is consistent, but verify if other methods in the workspace object use the same JSDoc style. If others use single-line comments //, consider standardizing.

Optimization Suggestions

  1. Naming Convention: folderCreateWorkspace is verbose. Since this is already within a workspace context, createFolder or folderCreate would be more concise and standard.
    • Suggested Name: createFolder: () => can(P.TOOL_FOLDER_CREATE),
  2. 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() vs workspace.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,
};

<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>

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 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:

  1. Logical Regression: The new code calls perm.tool.workspace.folderCreateWorkspace(), which appears to be a different method key than the original folderCreate. Unless folderCreateWorkspace takes 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.
  2. Orphaned Logic: If folderCreateWorkspace does not internally fetch the workspace ID like getWorkspaceId() 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.

@peslyn
peslyn merged commit d2747d5 into v3 Nov 10, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_workspace_tool_folder_create_error branch November 10, 2026 03:04
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